// import { MaritalStatusEnum } from "@/schema";
import { TOption } from "../types";
import {
  GenderEnum,
  MaritalStatusEnum,
  EmploymentTypeEnum,
  IndustryEnum,
  SeasonalIncomeSourcesEnum,
  CoBorrowerRelationshipEnum,
  EmployerTypeEnum,
  BankNameEnum,
  CurrencyEnum,
  WalletTypeEnum,
  ExistingLoanTypeEnum,
  InformalDebtRepaymentTermsEnum,
  SavingsPatternEnum,
  SavingsFrequencyEnum,
  AssetTypeEnum,
  VehicleOptionEnum,
  LivestockOptionEnum,
  EquipmentToolsOptionEnum,
  LandOptionEnum,
  PropertyOptionEnum,
  ElectronicsOptionEnum,
  InventoryOptionEnum,
  FurnitureOptionEnum,
  LoanPurposeEnum,
  LoanTenureUnitEnum,
  PreferredRepaymentModeEnum,
  PreferredDisbursementModeEnum,
} from "../enums";

export const getStatusBadgeStyle = (status: string) => {
  switch (status) {
    case "visit_pending":
      return "bg-[#FB8C001A] text-[#FB8C00]";
    case "compliance_pending":
      return "bg-[#FAF1D899] text-[#CA9712]";
    case "contract_pending":
      return "bg-[#FBC02D1A] text-[#EDA900]";
    case "disbursement_pending":
      return "bg-[#57CF5C1A] text-[#47D04D]";
    case "active":
      return "bg-[#66F66D1A] text-[#339D39]";
    // case "approved": // TODO: ASK UI TO REMOVE IT OT KEEP IT
    //   return "bg-[#E8F5E8] text-[#2E7D32]";
    case "rejected":
    case "inactive":
      return "bg-[#FFEFF099] text-[#AF3B41]";
    default:
      return "bg-gray-100 text-gray-800";
  }
}

export const statusOptions: TOption[] = [
  { value: 'rejected', label: 'Rejected' },
  { value: 'active', label: 'Active' },
  // { value: 'approved', label: 'Approved' }, // TODO: ASK UI TO REMOVE IT OT KEEP IT
  { value: 'visit_pending', label: 'Visit Pending' },
  { value: 'compliance_pending', label: 'Compliance Pending' },
  { value: 'contract_pending', label: 'Contract Pending' },
  { value: 'disbursement_pending', label: 'Disbursement Pending' },
];

// export const GENDER_OPTIONS = [
//   { label: "Male", value: "male" },
//   { label: "Female", value: "female" },
// ];

// export const MARITAL_STATUS_OPTIONS: { value: MaritalStatusEnum; label: string }[] = [
//   { value: MaritalStatusEnum.SINGLE,    label: "Single" },
//   { value: MaritalStatusEnum.MARRIED,   label: "Married" },
//   { value: MaritalStatusEnum.DIVORCED,  label: "Divorced" },
//   { value: MaritalStatusEnum.WIDOWED,   label: "Widowed" },
//   { value: MaritalStatusEnum.SEPARATED, label: "Separated" },
// ];

// export const EMPLOYMENT_TYPES = [
//   { value: "full_time", label: "Full-time" },
//   { value: "part_time", label: "Part-time" },
//   { value: "contract", label: "Contract" },
//   { value: "temporary", label: "Temporary" },
//   { value: "internship", label: "Internship" },
//   { value: "freelance", label: "Freelance" },
//   { value: "seasonal", label: "Seasonal" },
//   { value: "apprenticeship", label: "Apprenticeship" },
//   { value: "volunteer", label: "Volunteer" }
// ];

export const statusOptionsDecisionEngine: TOption[] = [
  { value: 'inactive', label: 'Inactive' },
  { value: 'active', label: 'Active' }
];

// Generic option type for selects
// export type TOption<T extends string | number = string> = {
//   value: T;
//   label: string;
// };

// ===== Gender
export const GENDER_OPTIONS: TOption<GenderEnum>[] = [
  { value: GenderEnum.Male, label: "Male" },
  { value: GenderEnum.Female, label: "Female" },
];

// ===== Marital Status
export const MARITAL_STATUS_OPTIONS: TOption<MaritalStatusEnum>[] = [
  { value: MaritalStatusEnum.Single, label: "Single" },
  { value: MaritalStatusEnum.Married, label: "Married" },
  { value: MaritalStatusEnum.Divorced, label: "Divorced" },
  { value: MaritalStatusEnum.Widowed, label: "Widowed" },
  { value: MaritalStatusEnum.Separated, label: "Separated" },
];

// ===== Employment Type
export const EMPLOYMENT_TYPE_OPTIONS: TOption<EmploymentTypeEnum>[] = [
  { value: EmploymentTypeEnum.FullTime, label: "Employed - Full-time" },
  { value: EmploymentTypeEnum.PartTime, label: "Employed - Part-time" },
  { value: EmploymentTypeEnum.SelfEmployed, label: "Self-employed" },
  { value: EmploymentTypeEnum.Freelancer, label: "Freelancer" },
  { value: EmploymentTypeEnum.InformalWorker, label: "Informal worker" },
  { value: EmploymentTypeEnum.Student, label: "Student" },
  { value: EmploymentTypeEnum.Retired, label: "Retired" },
  { value: EmploymentTypeEnum.Unemployed, label: "Unemployed" },
];

// ===== Industry
export const INDUSTRY_OPTIONS: TOption<IndustryEnum>[] = [
  { value: IndustryEnum.Agricultural, label: "Agricultural" },
  { value: IndustryEnum.RetailTrading, label: "Retail & Trading" },
  { value: IndustryEnum.Services, label: "Services" },
  { value: IndustryEnum.Manufacturing, label: "Manufacturing" },
  { value: IndustryEnum.Construction, label: "Construction" },
  { value: IndustryEnum.TransportationLogistics, label: "Transportation & Logistics" },
  { value: IndustryEnum.FoodBeverage, label: "Food & Beverage" },
  { value: IndustryEnum.Education, label: "Education" },
  { value: IndustryEnum.Healthcare, label: "Healthcare" },
  { value: IndustryEnum.Technology, label: "Technology" },
  { value: IndustryEnum.Other, label: "Other" },
];

// ===== Seasonal Income Sources
export const SEASONAL_INCOME_SOURCES_OPTIONS: TOption<SeasonalIncomeSourcesEnum>[] = [
  { value: SeasonalIncomeSourcesEnum.Ramadan, label: "Ramadan" },
  { value: SeasonalIncomeSourcesEnum.Christmas, label: "Christmas" },
  { value: SeasonalIncomeSourcesEnum.Eid, label: "Eid" },
  { value: SeasonalIncomeSourcesEnum.SummerHarvest, label: "Summer Harvest" },
];

// ===== Co-Borrower Relationship
export const CO_BORROWER_RELATIONSHIP_OPTIONS: TOption<CoBorrowerRelationshipEnum>[] = [
  { value: CoBorrowerRelationshipEnum.None, label: "None" },
  { value: CoBorrowerRelationshipEnum.Spouse, label: "Spouse" },
  { value: CoBorrowerRelationshipEnum.Parent, label: "Parent" },
  { value: CoBorrowerRelationshipEnum.Sibling, label: "Sibling" },
  { value: CoBorrowerRelationshipEnum.BusinessPartner, label: "Business partner" },
  { value: CoBorrowerRelationshipEnum.Friend, label: "Friend" },
  { value: CoBorrowerRelationshipEnum.Guarantor, label: "Guarantor" },
];

// ===== Employer Type
export const EMPLOYER_TYPE_OPTIONS: TOption<EmployerTypeEnum>[] = [
  { value: EmployerTypeEnum.Company, label: "Company" },
  { value: EmployerTypeEnum.Government, label: "Government" },
  { value: EmployerTypeEnum.NGO, label: "NGO" },
  { value: EmployerTypeEnum.SoleProprietorship, label: "Sole Proprietorship" },
  { value: EmployerTypeEnum.FamilyBusiness, label: "Family Business" },
  { value: EmployerTypeEnum.Cooperative, label: "Cooperative" },
];

// ===== Bank Names
export const BANK_NAME_OPTIONS: TOption<BankNameEnum>[] = Object.values(BankNameEnum).map((label) => ({
  value: label as BankNameEnum,
  label,
}));

// ===== Currency
export const CURRENCY_OPTIONS: TOption<CurrencyEnum>[] = [
  { value: CurrencyEnum.EGP, label: "EGP" },
  { value: CurrencyEnum.USD, label: "USD" },
  { value: CurrencyEnum.EUR, label: "EUR" },
];

// ===== Wallet Type
export const WALLET_TYPE_OPTIONS: TOption<WalletTypeEnum>[] = [
  { value: WalletTypeEnum.VodafoneCash, label: "Vodafone Cash" },
  { value: WalletTypeEnum.OrangeMoney, label: "Orange Money" },
  { value: WalletTypeEnum.EtisalatCash, label: "Etisalat Cash" },
  { value: WalletTypeEnum.MeezaDigital, label: "Meeza Digital" },
];

// ===== Existing Loan Type
export const EXISTING_LOAN_TYPE_OPTIONS: TOption<ExistingLoanTypeEnum>[] = [
  { value: ExistingLoanTypeEnum.MicroFinance, label: "Micro Finance" },
  { value: ExistingLoanTypeEnum.BankLoan, label: "Bank Loan" },
  { value: ExistingLoanTypeEnum.SMELoan, label: "SME Loan" },
  { value: ExistingLoanTypeEnum.CreditCard, label: "Credit Card" },
  { value: ExistingLoanTypeEnum.NGOLoan, label: "NGO Loan" },
  { value: ExistingLoanTypeEnum.InformalLoan, label: "Informal Loan" },
];

// ===== Informal Debt Repayment Terms
export const INFORMAL_DEBT_REPAYMENT_TERMS_OPTIONS: TOption<InformalDebtRepaymentTermsEnum>[] = [
  { value: InformalDebtRepaymentTermsEnum.DailyPayments, label: "Daily Payments" },
  { value: InformalDebtRepaymentTermsEnum.WeeklyPayments, label: "Weekly Payments" },
  { value: InformalDebtRepaymentTermsEnum.BiweeklyPayments, label: "Biweekly Payments" },
  { value: InformalDebtRepaymentTermsEnum.MonthlyPayments, label: "Monthly Payments" },
];

// ===== Savings Pattern
export const SAVINGS_PATTERN_OPTIONS: TOption<SavingsPatternEnum>[] = [
  { value: SavingsPatternEnum.VSLA, label: "VSLA" },
  { value: SavingsPatternEnum.ROSCA, label: "ROSCA" },
  { value: SavingsPatternEnum.SavingsGroup, label: "Savings Group" },
  { value: SavingsPatternEnum.PersonalAccount, label: "Personal Account" },
  { value: SavingsPatternEnum.BankAccount, label: "Bank Account" },
];

// ===== Savings Frequency
export const SAVINGS_FREQUENCY_OPTIONS: TOption<SavingsFrequencyEnum>[] = [
  { value: SavingsFrequencyEnum.Daily, label: "Daily" },
  { value: SavingsFrequencyEnum.Weekly, label: "Weekly" },
  { value: SavingsFrequencyEnum.Biweekly, label: "Biweekly" },
  { value: SavingsFrequencyEnum.Monthly, label: "Monthly" },
];

// ===== Asset Type
export const ASSET_TYPE_OPTIONS: TOption<AssetTypeEnum>[] = [
  { value: AssetTypeEnum.Vehicle, label: "Vehicle" },
  { value: AssetTypeEnum.Livestock, label: "Livestock" },
  { value: AssetTypeEnum.EquipmentTools, label: "Equipment & Tools" },
  { value: AssetTypeEnum.Land, label: "Land" },
  { value: AssetTypeEnum.Property, label: "Property" },
  { value: AssetTypeEnum.Electronics, label: "Electronics" },
  { value: AssetTypeEnum.Inventory, label: "Inventory" },
  { value: AssetTypeEnum.Furniture, label: "Furniture" },
];

// ===== Asset Options by Category
export const VEHICLE_OPTIONS: TOption<VehicleOptionEnum>[] = [
  { value: VehicleOptionEnum.Motorcycle, label: "Motorcycle" },
  { value: VehicleOptionEnum.Car, label: "Car" },
  { value: VehicleOptionEnum.TukTuk, label: "TukTuk" },
  { value: VehicleOptionEnum.Tractor, label: "Tractor" },
  { value: VehicleOptionEnum.Truck, label: "Truck" },
  { value: VehicleOptionEnum.Bicycle, label: "Bicycle" },
];

export const LIVESTOCK_OPTIONS: TOption<LivestockOptionEnum>[] = [
  { value: LivestockOptionEnum.Cow, label: "Cow" },
  { value: LivestockOptionEnum.Goat, label: "Goat" },
  { value: LivestockOptionEnum.Sheep, label: "Sheep" },
  { value: LivestockOptionEnum.Poultry, label: "Poultry" },
];

export const EQUIPMENT_TOOLS_OPTIONS: TOption<EquipmentToolsOptionEnum>[] = [
  { value: EquipmentToolsOptionEnum.IrrigationPump, label: "Irrigation Pump" },
  { value: EquipmentToolsOptionEnum.Generator, label: "Generator" },
  { value: EquipmentToolsOptionEnum.SewingMachine, label: "Sewing Machine" },
  { value: EquipmentToolsOptionEnum.POSMachine, label: "POS Machine" },
];

export const LAND_OPTIONS: TOption<LandOptionEnum>[] = [
  { value: LandOptionEnum.AgriculturalLand, label: "Agricultural Land" },
  { value: LandOptionEnum.ResidentialPlot, label: "Residential Plot" },
];

export const PROPERTY_OPTIONS: TOption<PropertyOptionEnum>[] = [
  { value: PropertyOptionEnum.House, label: "House" },
  { value: PropertyOptionEnum.Shop, label: "Shop" },
  { value: PropertyOptionEnum.Warehouse, label: "Warehouse" },
];

export const ELECTRONICS_OPTIONS: TOption<ElectronicsOptionEnum>[] = [
  { value: ElectronicsOptionEnum.Laptop, label: "Laptop" },
  { value: ElectronicsOptionEnum.Phone, label: "Phone" },
  { value: ElectronicsOptionEnum.TV, label: "TV" },
  { value: ElectronicsOptionEnum.Refrigerator, label: "Refrigerator" },
];

export const INVENTORY_OPTIONS: TOption<InventoryOptionEnum>[] = [
  { value: InventoryOptionEnum.RawMaterials, label: "Raw Materials" },
  { value: InventoryOptionEnum.FinishedGoods, label: "Finished Goods" },
];

export const FURNITURE_OPTIONS: TOption<FurnitureOptionEnum>[] = [
  { value: FurnitureOptionEnum.DisplayUnits, label: "Display Units" },
  { value: FurnitureOptionEnum.Shelves, label: "Shelves" },
  { value: FurnitureOptionEnum.OfficeFurniture, label: "Office Furniture" },
];

// Unified accessor
export const ASSET_OPTIONS_BY_TYPE: Record<AssetTypeEnum, TOption[]> = {
  [AssetTypeEnum.Vehicle]: VEHICLE_OPTIONS,
  [AssetTypeEnum.Livestock]: LIVESTOCK_OPTIONS,
  [AssetTypeEnum.EquipmentTools]: EQUIPMENT_TOOLS_OPTIONS,
  [AssetTypeEnum.Land]: LAND_OPTIONS,
  [AssetTypeEnum.Property]: PROPERTY_OPTIONS,
  [AssetTypeEnum.Electronics]: ELECTRONICS_OPTIONS,
  [AssetTypeEnum.Inventory]: INVENTORY_OPTIONS,
  [AssetTypeEnum.Furniture]: FURNITURE_OPTIONS,
};

// ===== Loan Purpose
export const LOAN_PURPOSE_OPTIONS: TOption<LoanPurposeEnum>[] = [
  { value: LoanPurposeEnum.AgricultureInput, label: "Agriculture input" },
  { value: LoanPurposeEnum.WorkingCapital, label: "Working Capital" },
  { value: LoanPurposeEnum.AssetPurchase, label: "Asset Purchase" },
  { value: LoanPurposeEnum.Education, label: "Education" },
  { value: LoanPurposeEnum.Healthcare, label: "Healthcare" },
  { value: LoanPurposeEnum.HomeImprovement, label: "Home Improvement" },
  { value: LoanPurposeEnum.Rent, label: "Rent" },
  { value: LoanPurposeEnum.DebtConsolidation, label: "Debt Consolidation" },
  { value: LoanPurposeEnum.Emergency, label: "Emergency" },
  { value: LoanPurposeEnum.Wedding, label: "Wedding" },
];

// ===== Loan Tenure Unit
export const LOAN_TENURE_UNIT_OPTIONS: TOption<LoanTenureUnitEnum>[] = [
  { value: LoanTenureUnitEnum.Weeks, label: "Weeks" },
  { value: LoanTenureUnitEnum.Months, label: "Months" },
];

// ===== Loan Tenure Months
export const LOAN_TENURE_MONTHS_LIST = [1, 3, 6, 9, 12, 18, 24] as const;
export type LoanTenureMonth = typeof LOAN_TENURE_MONTHS_LIST[number];
export const LOAN_TENURE_MONTHS_OPTIONS: TOption<LoanTenureMonth>[] =
  LOAN_TENURE_MONTHS_LIST.map((m) => ({ value: m, label: String(m) }));

// ===== Preferred Repayment Mode
export const PREFERRED_REPAYMENT_MODE_OPTIONS: TOption<PreferredRepaymentModeEnum>[] = [
  { value: PreferredRepaymentModeEnum.Agent, label: "Agent" },
  { value: PreferredRepaymentModeEnum.Cash, label: "Cash" },
  { value: PreferredRepaymentModeEnum.MobileWallet, label: "Mobile Wallet" },
  { value: PreferredRepaymentModeEnum.BankTransfer, label: "Bank Transfer" },
  { value: PreferredRepaymentModeEnum.StandingOrderPayroll, label: "Standing Order / Payroll" },
];

// ===== Preferred Disbursement Mode
export const PREFERRED_DISBURSEMENT_MODE_OPTIONS: TOption<PreferredDisbursementModeEnum>[] = [
  { value: PreferredDisbursementModeEnum.Cash, label: "Cash" },
  { value: PreferredDisbursementModeEnum.MobileWallet, label: "Mobile Wallet" },
  { value: PreferredDisbursementModeEnum.BankTransfer, label: "Bank Transfer" },
  { value: PreferredDisbursementModeEnum.Cheque, label: "Cheque" },
];
