import React from "react";
import { Outlet, useLocation } from "react-router-dom";
import ModuleHeader from "../../components/common/ModuleHeader";

const AccountingManagement: React.FC = () => {
  const location = useLocation();

  // Define page mappings for breadcrumbs
  const getPageTitle = (pathname: string) => {
    if (
      pathname === "/admin/accounting" ||
      pathname === "/admin/accounting/current-accounts"
    )
      return "Cari Hesap Yönetimi";
    if (pathname === "/admin/accounting/waybills") return "İrsaliye Yönetimi";
    if (pathname === "/admin/accounting/invoices") return "Fatura Yönetimi";
    if (pathname === "/admin/accounting/cash") return "Kasa Yönetimi";
    if (pathname === "/admin/accounting/bank") return "Banka Yönetimi";
    if (pathname === "/admin/accounting/check-note") return "Çek & Senet Takibi";
    return "Muhasebe Yönetimi";
  };

  const pageTitle = getPageTitle(location.pathname);

  // Create breadcrumbs: Anasayfa / CRM Yönetimi / Sayfanın Adı
  const breadcrumbs = [{ name: "CRM Yönetimi", href: "/admin/crm" }];

  return (
    <div className="min-h-screen bg-gray-50">
      <ModuleHeader
        title={pageTitle}
        breadcrumbs={breadcrumbs}
      />

      <div>
        <Outlet />
      </div>
    </div>
  );
};

export default AccountingManagement;
