import { Money3 } from "iconsax-react";
import { FC } from "react";
import { useTranslation } from "react-i18next";
import { useLocation } from "react-router-dom";
import { Pages } from "../../config/Pages";
import SubMenuItem from "./SubMenuItem";

const FinancialSubMenu: FC = () => {
  const location = useLocation();
  const { t } = useTranslation("global");

  const isActive = (name: string) => location.pathname.includes(name);

  return (
    <div className="py-12">
      <div className="flex gap-3 items-center border-b pb-10 px-6">
        <Money3
          size={24}
          color="#000"
          variant="Bold"
        />
        <div className="text-xs">{t("sidebar.financial")}</div>
      </div>

      <div className="flex flex-col mt-10 gap-4">
        <SubMenuItem
          title={t("sidebar.payments")}
          isActive={isActive("payments")}
          link={Pages.payment.list}
          activeName="payments"
        />
        <SubMenuItem
          title={t("sidebar.receipt_list")}
          isActive={isActive("receipts")}
          link={Pages.receipts.index}
          activeName="invoices"
        />
        <SubMenuItem
          title={t("sidebar.transactions")}
          isActive={isActive("transactions")}
          link={Pages.transactions}
          activeName="transactions"
        />
        <SubMenuItem
          title={t("sidebar.discounts")}
          isActive={isActive("discounts")}
          link={Pages.discount.list}
          activeName="discounts"
        />
        <SubMenuItem
          title={t("sidebar.card")}
          isActive={isActive("card-bank")}
          link={Pages.cardBank.list}
          activeName="bank_accounts"
        />
      </div>
    </div>
  );
};

export default FinancialSubMenu;
