export interface CustomerOption {
  id: string;
  code: string;
  label: string;
  value: string | null;
  parentId?: string | null;
}

export interface BranchOption {
  id: string;
  code: string;
  name: string;
  value: string | null;
}

export interface CustomerRecord {
  id: string;
  organizationId: string;
  branchId: string | null;
  code: string;
  name: string;
  abbr: string | null;
  taxId: string | null;
  customerType: string;
  customerStatus: string;
  address: string | null;
  province: string | null;
  district: string | null;
  subDistrict: string | null;
  postalCode: string | null;
  country: string | null;
  phone: string | null;
  fax: string | null;
  email: string | null;
  website: string | null;
  leadChannel: string | null;
  customerGroup: string | null;
  customerSubGroup: string | null;
  notes: string | null;
  isActive: boolean;
  createdAt: string;
  updatedAt: string;
  deletedAt: string | null;
  createdBy: string;
  updatedBy: string;
}

export interface CustomerListItem extends CustomerRecord {
  contactCount: number;
}

export interface CustomerContactRecord {
  id: string;
  organizationId: string;
  customerId: string;
  name: string;
  position: string | null;
  department: string | null;
  phone: string | null;
  mobile: string | null;
  email: string | null;
  isPrimary: boolean;
  notes: string | null;
  isActive: boolean;
  createdAt: string;
  updatedAt: string;
  deletedAt: string | null;
  createdBy: string;
  updatedBy: string;
}

export interface CustomerActivityRecord {
  id: string;
  action: string;
  entityType: string;
  entityId: string;
  createdAt: string;
  userId: string;
  actorName: string | null;
}

export interface CustomerRelatedEnquiryItem {
  id: string;
  code: string;
  title: string;
  status: string;
  productType: string;
  updatedAt: string;
}

export interface CustomerReferenceData {
  branches: BranchOption[];
  customerTypes: CustomerOption[];
  customerStatuses: CustomerOption[];
  leadChannels: CustomerOption[];
  customerGroups: CustomerOption[];
  customerSubGroups: CustomerOption[];
}

export interface CustomerFilters {
  page?: number;
  limit?: number;
  search?: string;
  customerStatus?: string;
  customerType?: string;
  branch?: string;
  sort?: string;
}

export interface CustomerListResponse {
  success: boolean;
  time: string;
  message: string;
  totalItems: number;
  offset: number;
  limit: number;
  items: CustomerListItem[];
}

export interface CustomerDetailResponse {
  success: boolean;
  time: string;
  message: string;
  customer: CustomerRecord;
  activity: CustomerActivityRecord[];
}

export interface CustomerContactsResponse {
  success: boolean;
  time: string;
  message: string;
  items: CustomerContactRecord[];
}

export interface CustomerMutationPayload {
  name: string;
  abbr?: string;
  taxId?: string;
  customerType: string;
  customerStatus: string;
  branchId?: string | null;
  address?: string;
  province?: string;
  district?: string;
  subDistrict?: string;
  postalCode?: string;
  country?: string;
  phone?: string;
  fax?: string;
  email?: string;
  website?: string;
  leadChannel?: string | null;
  customerGroup?: string | null;
  customerSubGroup?: string | null;
  notes?: string;
  isActive?: boolean;
}

export interface CustomerContactMutationPayload {
  name: string;
  position?: string;
  department?: string;
  phone?: string;
  mobile?: string;
  email?: string;
  isPrimary?: boolean;
  notes?: string;
  isActive?: boolean;
}

export interface MutationSuccessResponse {
  success: boolean;
  message: string;
}
