import React from "react";
import { Icons, createMenuItem } from "./menuItemHelpers";
import * as ROUTES from "../../../routes/routes";
import PorvinceGetReportOperations from "../../../features/province/components/province-get-report-operations/PorvinceGetReportOperations";

// Province Menu Items
export const getProvinceMenuItems = () => ({
  collapsibleSections: [
    {
      key: "province",
      icon: Icons.SettingsSuggest,
      text: "پنل مدیریت",
      items: [
        createMenuItem(
          ROUTES.ROUTE_PROVINCE_CITY_NEW_REQUESTS,
          Icons.FeaturedPlayList,
          "مدیریت درخواست ها"
        ),
        createMenuItem(
          ROUTES.ROUTE_PROVINCE_STATEMENTـOFـNEED_REQUESTS,
          Icons.AddShoppingCart,
          "اعلام نیاز خریداران"
        ),
        createMenuItem(
          ROUTES.ROUTE_PROVINCE_ALLOCATION_REQUESTS,
          Icons.Assignment,
          "تخصیصات"
        ),
        createMenuItem(
          ROUTES.ROUTE_PROVINCE_PAYING_FEES_REQUESTS,
          Icons.LocalOffer,
          "تعرفه ها"
        ),
        createMenuItem(
          ROUTES.ROUTE_PROVINCEـFREE_BUY,
          Icons.ShoppingCart,
          "خرید مستقیم"
        ),
        createMenuItem(ROUTES.ROUTE_PROVINCEـEXPORT, Icons.Flight, "صادرات"),
        createMenuItem(
          ROUTES.ROUTE_PROVINCE_FREE_SALES_REQUESTS,
          Icons.Business,
          "فروش به خارج استان"
        ),
        createMenuItem(ROUTES.ROUTE_PROVINCE_CHAINS, Icons.Lan, "زنجیره ها"),
        createMenuItem(
          ROUTES.ROUTE_PROVINCE_ALLOCATED_REQUESTS,
          Icons.AssignmentTurnedIn,
          "مدیریت تخصیصات"
        ),
        createMenuItem(
          ROUTES.ROUTE_PROVINCE_AUTO_ALLOCATION_REQUESTS,
          Icons.AutoFixHigh,
          "تخصیصات خودکار"
        ),
        createMenuItem(
          ROUTES.ROUTE_PROVINCE_ISSUANCE_OF_LETTER,
          Icons.Drafts,
          "صدور نامه"
        ),
        createMenuItem(
          ROUTES.ROUTE_PROVINCE_TRANSACTIONS,
          Icons.CompareArrows,
          "تراکنش ها"
        ),
      ],
    },
  ],
  regularItems: [
    {
      icon: React.createElement(Icons.Summarize),
      text: "گزارش روزانه",
      isModal: true,
      modalContent: PorvinceGetReportOperations,
      modalTitle: "اطلاعات گزارش",
    },
    createMenuItem(
      ROUTES.ROUTE_PROVINCEـVISOR_STATICS,
      Icons.Equalizer,
      "تحلیل داده"
    ),
    createMenuItem(ROUTES.ROUTE_PROVINCE_HATCHING, Icons.Egg, "مدیریت کشتار"),
    createMenuItem(
      ROUTES.ROUTE_PROVINCEـHATCHINGS,
      Icons.SettingsInputComposite,
      "مدیریت جوجه ریزی"
    ),
    createMenuItem(
      ROUTES.ROUTE_PROVINCE_PRICING3,
      Icons.AttachMoney,
      "قیمت روز"
    ),
    createMenuItem(
      ROUTES.ROUTE_PROVINCE_STATICS,
      Icons.PieChart,
      "آمار و اطلاعات"
    ),
    createMenuItem(ROUTES.ROUTE_PROVINCE_REPORT, Icons.FaFile, "گزارشات"),
    createMenuItem(
      ROUTES.ROUTE_PROVINCE_ROUTE_FILES_STATE,
      Icons.AccountTree,
      "پرونده های کشتار"
    ),
    createMenuItem(
      ROUTES.ROUTE_PROVINCE_ROUTE_ALLOCATIONS,
      Icons.LocalShipping,
      "مدیریت بارها"
    ),
    createMenuItem(
      ROUTES.ROUTE_PROVINCE_DISPENSERS,
      Icons.CoPresent,
      "مدیریت توزیع"
    ),
    createMenuItem(
      ROUTES.ROUTE_PROVINCE_ROUTE_MANAGE_GUILDS,
      Icons.CorporateFare,
      "مدیریت اصناف"
    ),
    createMenuItem(ROUTES.ROUTE_PROVINCE_CARS, Icons.DirectionsCar, "خودروها"),
    createMenuItem(ROUTES.ROUTE_PROVINCE_USERS, Icons.PersonAddAlt, "کاربران"),
    createMenuItem(
      ROUTES.ROUTE_PROVINCE_GUILD_TRANSACTIONS,
      Icons.ReceiptLong,
      "مدیریت تراکنش ها"
    ),
    createMenuItem(
      ROUTES.ROUTE_PROVINCE_POULTRIES,
      Icons.PersonAddAlt,
      "مدیریت فارم ها"
    ),
    createMenuItem(ROUTES.ROUTE_PROVINCE_SLAUGHTERS, Icons.Factory, "خریداران"),
    createMenuItem(ROUTES.ROUTE_PROVINCE_PRODUCTS, Icons.Inventory, "محصولات"),
    createMenuItem(
      ROUTES.ROUTE_PROVINCEـBROADCAST_MANAGEMENT,
      Icons.PersonAddAlt,
      "مدیریت پخش"
    ),
    createMenuItem(
      ROUTES.ROUTE_PROVINCE_ASSIGN_VET_FARM,
      Icons.PersonAddAlt,
      "دامپزشکان"
    ),
    createMenuItem(
      ROUTES.ROUTE_PROVINCE_ROUTE_SMS,
      Icons.MailOutline,
      "پنل اطلاع رسانی"
    ),
    createMenuItem(ROUTES.ROUTE_PROVINCE_TICKET, Icons.Support, "تیکت ها"),
  ],
});

// City Menu Items
export const getCityMenuItems = () => ({
  collapsibleSections: [
    {
      key: "city",
      icon: Icons.SettingsSuggest,
      text: "پنل مدیریت",
      items: [
        createMenuItem(
          ROUTES.ROUTE_CITY_NEW_REQUESTS,
          Icons.NewReleases,
          "درخواست های جدید"
        ),
        createMenuItem(
          ROUTES.ROUTE_CITY_ACTIVE_REQUESTS,
          Icons.TaskAlt,
          "درخواست های فعال"
        ),
        createMenuItem(
          ROUTES.ROUTE_CITY_AWAITING_PAYMENT_REQUESTS,
          Icons.Payment,
          "در انتظار پرداخت"
        ),
        createMenuItem(
          ROUTES.ROUTE_CITY_AWAITING_INSPECTION_REQUESTS,
          Icons.Report,
          "در انتظار بازرسی"
        ),
        createMenuItem(
          ROUTES.ROUTE_CITY_REJECTED_REQUESTS,
          Icons.Report,
          "درخواست های رد شده"
        ),
        createMenuItem(
          ROUTES.ROUTE_CITY_FREE_SALES_REQUESTS,
          Icons.FolderOpen,
          "فروش خارج از استان"
        ),
        createMenuItem(
          ROUTES.ROUTE_CITY_ARCHIVED_REQUESTS,
          Icons.Archive,
          "بایگانی"
        ),
      ],
    },
  ],
  regularItems: [
    createMenuItem(
      ROUTES.ROUTE_CITY_VISOR_STATICS,
      Icons.Equalizer,
      "تحلیل داده"
    ),
    createMenuItem(ROUTES.ROUTE_CITY_HATCHING, Icons.Egg, "مدیریت کشتار"),
    createMenuItem(
      ROUTES.ROUTE_CITY_ROUTE_FILES_STATE,
      Icons.AccountTree,
      "پرونده های کشتار"
    ),
    createMenuItem(
      ROUTES.ROUTE_CITYـHATCHINGS,
      Icons.SettingsInputComposite,
      "مدیریت جوجه ریزی"
    ),
    createMenuItem(
      ROUTES.ROUTE_CITY_ROUTE_ALLOCATIONS,
      Icons.LocalShipping,
      "مدیریت بارها"
    ),
    createMenuItem(ROUTES.ROUTE_CITY_PRICING, Icons.AttachMoney, "قیمت روز"),
    createMenuItem(
      ROUTES.ROUTE_CITY_POULTRIES,
      Icons.PersonAddAlt,
      "مدیریت فارم ها"
    ),
    createMenuItem(
      ROUTES.ROUTE_CITY_POULTRY_FARMS,
      Icons.Warehouse,
      "مرغداران"
    ),
    createMenuItem(ROUTES.ROUTE_CITY_STATICS, Icons.PieChart, "آمار و اطلاعات"),
    createMenuItem(
      ROUTES.ROUTE_CITY_USER_MANAGEMENT,
      Icons.PersonAddAlt,
      "کاربران"
    ),
    createMenuItem(ROUTES.ROUTE_CITY_TICKET, Icons.Support, "تیکت ها"),
  ],
});

// Inspector Menu Items
export const getInspectorMenuItems = () => ({
  collapsibleSections: [
    {
      key: "inspector",
      icon: Icons.SettingsSuggest,
      text: "پنل مدیریت",
      items: [
        createMenuItem(
          ROUTES.ROUTE_INSPECTOR_REQUESTS_NEW_REQUESTS,
          Icons.Folder,
          "درخواست های جدید"
        ),
        createMenuItem(
          ROUTES.ROUTE_PROVINCE_INSPECTOR_AWAITING_PAYMENT_REQUESTS,
          Icons.AttachMoneyIcon,
          "در انتظار پرداخت"
        ),
        createMenuItem(
          ROUTES.ROUTE_PROVINCE_INSPECTOR_AWAITING_INSPECTION_REQUESTS,
          Icons.FileCopy,
          "در انتظار بازرسی"
        ),
        createMenuItem(
          ROUTES.ROUTE_INSPECTOR_REJECTED_REQUESTS,
          Icons.WarningIcon,
          "درخواست های رد شده"
        ),
        createMenuItem(
          ROUTES.ROUTE_INSPECTOR_ARCHIVED_REQUESTS,
          Icons.ArchiveIcon,
          "بایگانی"
        ),
      ],
    },
  ],
  regularItems: [
    createMenuItem(
      ROUTES.ROUTE_INSPECTOR_STATICS,
      Icons.PieChart,
      "آمار و اطلاعات"
    ),
    createMenuItem(
      ROUTES.ROUTE_PROVINCE_INSPECTOR_REPORTING,
      Icons.NoteAlt,
      "گزارشات"
    ),
    createMenuItem(
      ROUTES.ROUTE_PROVINCE_INSPECTOR_TICKET,
      Icons.Support,
      "تیکت ها"
    ),
  ],
});

// Aviculture Menu Items
export const getAvicultureMenuItems = () => ({
  collapsibleSections: [
    {
      key: "avicuture",
      icon: Icons.SettingsSuggest,
      text: "پنل مدیریت",
      items: [
        createMenuItem(
          ROUTES.ROUTE_AVICULTURE_HATCHING,
          Icons.Egg,
          "جوجه ریزی"
        ),
        createMenuItem(
          ROUTES.ROUTE_AVICULTURE_SUBMIT_REQUEST,
          Icons.AttachFile,
          "درخواست های کشتار"
        ),
        createMenuItem(
          ROUTES.ROUTE_AVICULTURE_AWAITING_PAYMENT_REQUESTS,
          Icons.Payment,
          "در انتظار پرداخت"
        ),
        createMenuItem(
          ROUTES.ROUTE_AVICULTURE_AWAITING_INSPECTION_REQUESTS,
          Icons.AssignmentLate,
          "در انتظار بازرسی"
        ),
        createMenuItem(
          ROUTES.ROUTE_AVICULTURE_REJECTED_REQUESTS,
          Icons.Warning,
          "درخواست های رد شده"
        ),
        createMenuItem(
          ROUTES.ROUTE_AVICULTURE_ARCHIVED_REQUESTS,
          Icons.Archive,
          "بایگانی"
        ),
        createMenuItem(
          ROUTES.ROUTE_AVICULTURE_GIVE_PERMISSION,
          Icons.Archive,
          "وکالت"
        ),
      ],
    },
  ],
  regularItems: [
    createMenuItem(
      ROUTES.ROUTE_AVICULTURE_PRICING,
      Icons.AttachMoney,
      "قیمت روز"
    ),
    createMenuItem(
      ROUTES.ROUTE_AVICULTURE_ROUTE_HALLS,
      Icons.MeetingRoom,
      "سالن ها"
    ),
    createMenuItem(ROUTES.ROUTE_AVICULTURE_TICKET, Icons.Support, "تیکت ها"),
  ],
});

// Slaughter House Menu Items
export const getSlaughterHouseMenuItems = (slaughterPermissionState) => ({
  collapsibleSections: [
    {
      key: "slaughter",
      icon: Icons.SettingsSuggest,
      text: "پنل مدیریت",
      items: [
        createMenuItem(
          ROUTES.ROUTE_SLAUGHTER_NEW_REQUESTS,
          Icons.FeaturedPlayList,
          "ثبت درخواست"
        ),
        createMenuItem(
          ROUTES.ROUTE_SLAUGHTERـFREE_BUY,
          Icons.ShoppingCart,
          "خرید مستقیم"
        ),
        createMenuItem(ROUTES.ROUTE_SLAUGHTERـEXPORT, Icons.Flight, "صادرات"),
        createMenuItem(
          ROUTES.ROUTE_SLAUGHTER_PENDING_REQUESTS,
          Icons.PendingActions,
          "سفارش های دریافت شده"
        ),
        createMenuItem(
          ROUTES.ROUTE_SLAUGHTER_ALLOCATION_REQUESTS,
          Icons.AssignmentTurnedIn,
          "تخصیصات"
        ),
        createMenuItem(
          ROUTES.ROUTE_SLAUGHTER_ALLOCATE_CAR_REQUESTS,
          Icons.LocalShipping,
          "تخصیص خودرو"
        ),
        createMenuItem(
          ROUTES.ROUTE_SLAUGHTER_ENTER_BAR_INFO,
          Icons.LocalShipping,
          "وارد کردن اطلاعات بار"
        ),
        createMenuItem(
          ROUTES.ROUTE_SLAUGHTER_PAYING_FEES_REQUESTS,
          Icons.MonetizationOn,
          "مدیریت تعرفه ها"
        ),
        createMenuItem(
          ROUTES.ROUTE_SLAUGHTER_WALLET,
          Icons.AccountBalanceWallet,
          "کیف پول"
        ),
        createMenuItem(
          ROUTES.ROUTE_SLAUGHTER_FINANCIAL_TRANSACTIONS,
          Icons.SwapHorizontalCircle,
          "مدیریت تراکنش ها"
        ),
        createMenuItem(
          ROUTES.ROUTE_SLAUGHTER_PAY_FACTORS_REQUESTS,
          Icons.Receipt,
          "مدیریت فاکتورها"
        ),
      ],
    },
  ],
  regularItems: [
    {
      ...createMenuItem(
        ROUTES.ROUTE_SLAUGHTER_ROUTE_MANAGE_BARS,
        Icons.CorporateFare,
        "مدیریت بارها"
      ),
      disabled: !slaughterPermissionState,
    },
    {
      ...createMenuItem(
        ROUTES.ROUTE_SLAUGHTER_ROUTE_MANAGE_GUILDS,
        Icons.CorporateFare,
        "مدیریت اصناف"
      ),
      disabled: !slaughterPermissionState,
    },
    {
      ...createMenuItem(
        ROUTES.ROUTE_SLAUGHTER_PRICING,
        Icons.AttachMoney,
        "قیمت روز"
      ),
      disabled: !slaughterPermissionState,
    },
    {
      ...createMenuItem(
        ROUTES.ROUTE_SLAUGHTER_CAR_MANAGEMENT,
        Icons.DirectionsCar,
        "خودروها"
      ),
      disabled: !slaughterPermissionState,
    },
    {
      ...createMenuItem(
        ROUTES.ROUTE_SLAUGHTER_DISPENSERS,
        Icons.CoPresent,
        "مدیریت توزیع"
      ),
      disabled: true,
    },
    {
      ...createMenuItem(
        ROUTES.ROUTE_SLAUGHTER_INVENTORY,
        Icons.Warehouse,
        "انبار و توزیع"
      ),
      disabled: !slaughterPermissionState,
    },
    {
      ...createMenuItem(ROUTES.ROUTE_SLAUGHTER_MORGUE, Icons.AcUnit, "سردخانه"),
      disabled: !slaughterPermissionState,
    },
  ],
});

// Province Financial Menu Items
export const getProvinceFinancialMenuItems = () => ({
  collapsibleSections: [
    {
      key: "provinceFinancial",
      icon: Icons.SettingsSuggest,
      text: "پنل مدیریت",
      items: [
        createMenuItem(
          ROUTES.ROUTE_PROVINCE_FINANCIAL_PENDING_REQUESTS,
          Icons.PendingActions,
          "صدور فاکتور"
        ),
        createMenuItem(
          ROUTES.ROUTE_PROVINCE_FINANCIAL_AWAITING_PAYMENT_REQUESTS,
          Icons.AttachMoney,
          "در انتظار پرداخت"
        ),
        createMenuItem(
          ROUTES.ROUTE_PROVINCE_FINANCIAL_CHECK_PAYED_FACTOR_REQUESTS,
          Icons.Paid,
          "فاکتورهای پرداخت شده"
        ),
        createMenuItem(
          ROUTES.ROUTE_PROVINCE_FINANCIAL_TRANSACTIONS,
          Icons.Loop,
          "تراکنش ها"
        ),
        createMenuItem(
          ROUTES.ROUTE_PROVINCE_FINANCIAL_FINAL_FACTORS_REQUESTS,
          Icons.FactCheck,
          "اسناد مالی"
        ),
        createMenuItem(
          ROUTES.ROUTE_PROVINCE_FINANCIAL_ACTIVE_REQUESTS,
          Icons.FolderOpen,
          "درخواست های فعال"
        ),
        createMenuItem(
          ROUTES.ROUTE_PROVINCE_FINANCIAL_AWAITING_INSPECTION_REQUESTS,
          Icons.PendingActions,
          "در انتظار بازرسی"
        ),
        createMenuItem(
          ROUTES.ROUTE_PROVINCE_FINANCIAL_ARCHIVED_REQUESTS,
          Icons.Archive,
          "بایگانی"
        ),
      ],
    },
  ],
  regularItems: [
    createMenuItem(
      ROUTES.ROUTE_PROVINCE_FINANCIAL_SETTLEMENT,
      Icons.CreditScore,
      "تسویه حساب"
    ),
    createMenuItem(
      ROUTES.ROUTE_PROVINCE_PRICING,
      Icons.AttachMoney,
      "قیمت گذاری"
    ),
    createMenuItem(
      ROUTES.ROUTE_PROVINCE_FINANCIAL_STATICS,
      Icons.PieChart,
      "آمار و اطلاعات"
    ),
    createMenuItem(
      ROUTES.ROUTE_PROVINCE_FINANCIAL_TICKET,
      Icons.Support,
      "تیکت ها"
    ),
    createMenuItem(
      ROUTES.ROUTE_PROVINCE_FINANCIAL_DOCUMENT_REGISTRATION,
      Icons.AttachMoney,
      "ثبت سند مالی"
    ),
  ],
});

// Vet Farm Menu Items
export const getVetFarmMenuItems = () => ({
  regularItems: [
    createMenuItem(
      ROUTES.ROUTE_VETFARM_ROUTE_ALLOCATIONS,
      Icons.SettingsSuggest,
      "کدرهگیری قرنطینه"
    ),
    createMenuItem(
      ROUTES.ROUTE_VETFARM_REGISTER_INFO,
      Icons.Vaccines,
      "مدیریت فارم"
    ),
  ],
});

// Driver Menu Items
export const getDriverMenuItems = () => ({
  regularItems: [
    createMenuItem(
      ROUTES.ROUTE_DRIVER_REQUESTS,
      Icons.SettingsSuggest,
      "پنل مدیریت"
    ),
  ],
});

// Dispenser Menu Items
export const getDispenserMenuItems = () => ({
  regularItems: [
    createMenuItem(
      ROUTES.ROUTE_DISPENSER_DASHBOARD,
      Icons.SettingsSuggest,
      "پنل مدیریت"
    ),
  ],
});

// Factory function to get menu items by role
export const getMenuItemsByRole = (role, additionalProps = {}) => {
  switch (role) {
    case "ProvinceOperator":
      return getProvinceMenuItems();
    case "CityOperator":
      return getCityMenuItems();
    case "ProvinceInspector":
    case "Admin":
      return getInspectorMenuItems();
    case "Poultry":
      return getAvicultureMenuItems();
    case "KillHouse":
      return getSlaughterHouseMenuItems(
        additionalProps.slaughterPermissionState
      );
    case "ProvinceFinancial":
      return getProvinceFinancialMenuItems();
    case "VetFarm":
      return getVetFarmMenuItems();
    case "Driver":
      return getDriverMenuItems();
    case "Dispenser":
      return getDispenserMenuItems();
    default:
      return { collapsibleSections: [], regularItems: [] };
  }
};
