import { AppBreadcrumb, AppContent } from "@repo/rdx-ui/components";
import { Button } from "@repo/shadcn-ui/components";
import { PlusIcon } from "lucide-react";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router-dom";
import { InvoicesGrid } from "../components";

export const InvoicesList = () => {
  const { t } = useTranslation("invoices");
  const navigate = useNavigate();
  const [status, setStatus] = useState("all");

  const InvoiceStatuses = [
    { value: "all", label: t("Invoices.list.tabs.all") },
    { value: "draft", label: t("Invoices.list.tabs.draft") },
    { value: "ready", label: t("Invoices.list.tabs.ready") },
    { value: "delivered", label: t("Invoices.list.tabs.delivered") },
    { value: "accepted", label: t("Invoices.list.tabs.accepted") },
    { value: "rejected", label: t("Invoices.list.tabs.rejected") },
    { value: "archived", label: t("Invoices.list.tabs.archived") },
  ];

  return (
    <>
      <AppBreadcrumb />
      <AppContent>
        <div className='flex items-center justify-between space-y-2'>
          <div>
            <h2 className='text-2xl font-bold tracking-tight'>{t("invoices.list.title")}</h2>
            <p className='text-muted-foreground'>{t("invoices.list.description")}</p>
          </div>
          <div className='flex items-center space-x-2'>
            <Button onClick={() => navigate("/Invoices/add")}>
              <PlusIcon className='w-4 h-4 mr-2' />
              {t("invoices.create.title")}
            </Button>
          </div>
        </div>
        <div className='flex flex-col w-full h-full py-4'>
          <InvoicesGrid />
        </div>
      </AppContent>
    </>
  );
};

/*
  return (
    <>
      <div className='flex items-center justify-between space-y-2'>
        <div>
          <h2 className='text-2xl font-bold tracking-tight'>
            {t('invoices.list.title' />
          </h2>
          <p className='text-muted-foreground'>
            {t('Invoices.list.subtitle' />
          </p>
        </div>
        <div className='flex items-center space-x-2'>
          <Button onClick={() => navigate("/Invoices/add")}>
            <PlusIcon className='w-4 h-4 mr-2' />
            {t("Invoices.create.title")}
          </Button>
        </div>
      </div>

      <Tabs value={status} onValueChange={setStatus}>
        <div className='flex flex-col items-start justify-between mb-4 sm:flex-row sm:items-center'>
          <div className='w-full mb-4 sm:w-auto sm:mb-0'>
            <TabsList className='hidden sm:flex'>
              {InvoiceStatuses.map((s) => (
                <TabsTrigger key={s.value} value={s.value}>
                  {s.label}
                </TabsTrigger>
              ))}
            </TabsList>
            <div className='flex items-center w-full space-x-2 sm:hidden'>
              <Label>{t("Invoices.list.tabs_title")}</Label>
              <Select value={status} onValueChange={setStatus}>
                <SelectTrigger>
                  <SelectValue placeholder='Seleccionar estado' />
                </SelectTrigger>
                <SelectContent>
                  {InvoiceStatuses.map((s) => (
                    <SelectItem key={s.value} value={s.value}>
                      {s.label}
                    </SelectItem>
                  ))}
                </SelectContent>
              </Select>
            </div>
          </div>
        </div>
        {InvoiceStatuses.map((s) => (
          <TabsContent key={s.value} value={s.value}>
            <InvoicesGrid />
          </TabsContent>
        ))}
      </Tabs>
    </>
  );
};
*/
