Facturas de cliente
This commit is contained in:
parent
07047f9984
commit
ad79b0dbc4
@ -8,7 +8,7 @@ import { useNavigate } from "react-router-dom";
|
||||
import { useTranslation } from "../../../i18n";
|
||||
|
||||
import { useIssuedInvoicesList } from "./hooks";
|
||||
import { IssuedInvoicesGrid } from "./ui/proformas-grid";
|
||||
import { IssuedInvoicesGrid } from "./ui/issued-invoices-grid";
|
||||
|
||||
export const IssuedInvoiceListPage = () => {
|
||||
const { t } = useTranslation();
|
||||
@ -51,7 +51,6 @@ export const IssuedInvoiceListPage = () => {
|
||||
onPageChange={list.setPageIndex}
|
||||
onPageSizeChange={list.setPageSize}
|
||||
onSearchChange={list.setSearchValue}
|
||||
onStatusFilterChange={list.setStatusFilter}
|
||||
pageIndex={list.pageIndex}
|
||||
pageSize={list.pageSize}
|
||||
searchValue={list.search}
|
||||
|
||||
@ -1,2 +1 @@
|
||||
export * from "./issued-invoice-status-badge";
|
||||
export * from "./issued-invoices-grid";
|
||||
|
||||
@ -1,14 +1,5 @@
|
||||
import { SimpleSearchInput } from "@erp/core/components";
|
||||
import { DataTable, SkeletonDataTable } from "@repo/rdx-ui/components";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@repo/shadcn-ui/components";
|
||||
import { FilterIcon } from "lucide-react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
import { useTranslation } from "../../../../i18n";
|
||||
import type { IssuedInvoiceSummaryPageData } from "../../../schema/issued-invoice-summary.web.schema";
|
||||
@ -25,7 +16,6 @@ interface IssuedInvoicesGridProps {
|
||||
onPageSizeChange: (s: number) => void;
|
||||
onRowClick?: (id: string) => void;
|
||||
onExportClick?: () => void;
|
||||
onStatusFilterChange?: (newStatus: string) => void;
|
||||
}
|
||||
|
||||
export const IssuedInvoicesGrid = ({
|
||||
@ -39,18 +29,13 @@ export const IssuedInvoicesGrid = ({
|
||||
onPageSizeChange,
|
||||
onRowClick,
|
||||
onExportClick,
|
||||
onStatusFilterChange,
|
||||
}: IssuedInvoicesGridProps) => {
|
||||
const navigate = useNavigate();
|
||||
const { t } = useTranslation();
|
||||
const { items, total_items } = data;
|
||||
|
||||
const columns = useIssuedInvoicesGridColumns({
|
||||
onEdit: (proforma) => navigate(`/issued-invoices/${proforma.id}/edit`),
|
||||
onDuplicate: (proforma) => null, //duplicateInvoice(inv.id),
|
||||
onDownloadPdf: (proforma) => null, //downloadInvoicePdf(inv.id),
|
||||
onSendEmail: (proforma) => null, //sendInvoiceEmail(inv.id),
|
||||
onDelete: (proforma) => null, //confirmDelete(inv.id),
|
||||
onDownloadPdf: (invoice) => null, //downloadInvoicePdf(inv.id),
|
||||
onSendEmail: (invoice) => null, //sendInvoiceEmail(inv.id),
|
||||
});
|
||||
|
||||
if (loading)
|
||||
@ -67,20 +52,6 @@ export const IssuedInvoicesGrid = ({
|
||||
<div className="flex flex-col gap-4">
|
||||
<div className="flex flex-col sm:flex-row gap-4">
|
||||
<SimpleSearchInput loading={loading} onSearchChange={onSearchChange} />
|
||||
<Select defaultValue="all" onValueChange={onStatusFilterChange}>
|
||||
<SelectTrigger className="w-full sm:w-48">
|
||||
<FilterIcon aria-hidden className="mr-2 size-4" />
|
||||
<SelectValue placeholder={t("filters.status")} />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="all">{t("catalog.proformas.status.all")}</SelectItem>
|
||||
<SelectItem value="draft">{t("catalog.proformas.status.draft")}</SelectItem>
|
||||
<SelectItem value="sent">{t("catalog.proformas.status.sent")}</SelectItem>
|
||||
<SelectItem value="approved">{t("catalog.proformas.status.approved")}</SelectItem>
|
||||
<SelectItem value="rejected">{t("catalog.proformas.status.rejected")}</SelectItem>
|
||||
<SelectItem value="issued">{t("catalog.proformas.status.issued")}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<DataTable
|
||||
@ -1,68 +0,0 @@
|
||||
import { Badge } from "@repo/shadcn-ui/components";
|
||||
import { cn } from "@repo/shadcn-ui/lib/utils";
|
||||
import { forwardRef } from "react";
|
||||
|
||||
import { useTranslation } from "../../../../i18n";
|
||||
|
||||
export type IssuedInvoiceStatus = "draft" | "sent" | "approved" | "rejected" | "issued";
|
||||
|
||||
export type IssuedInvoiceStatusBadgeProps = {
|
||||
status: string | IssuedInvoiceStatus; // permitir cualquier valor
|
||||
dotVisible?: boolean;
|
||||
className?: string;
|
||||
};
|
||||
|
||||
const statusColorConfig: Record<IssuedInvoiceStatus, { badge: string; dot: string }> = {
|
||||
draft: {
|
||||
badge:
|
||||
"bg-gray-500/10 dark:bg-gray-500/20 hover:bg-gray-500/10 text-gray-600 border-gray-400/60",
|
||||
dot: "bg-gray-500",
|
||||
},
|
||||
sent: {
|
||||
badge:
|
||||
"bg-amber-500/10 dark:bg-amber-500/20 hover:bg-amber-500/10 text-amber-500 border-amber-600/60",
|
||||
dot: "bg-amber-500",
|
||||
},
|
||||
approved: {
|
||||
badge:
|
||||
"bg-emerald-500/10 dark:bg-emerald-500/20 hover:bg-emerald-500/10 text-emerald-500 border-emerald-600/60",
|
||||
dot: "bg-emerald-500",
|
||||
},
|
||||
rejected: {
|
||||
badge: "bg-red-500/10 dark:bg-red-500/20 hover:bg-red-500/10 text-red-500 border-red-600/60",
|
||||
dot: "bg-red-500",
|
||||
},
|
||||
issued: {
|
||||
badge:
|
||||
"bg-blue-600/10 dark:bg-blue-600/20 hover:bg-blue-600/10 text-blue-500 border-blue-600/60",
|
||||
dot: "bg-blue-500",
|
||||
},
|
||||
};
|
||||
|
||||
export const IssuedInvoiceStatusBadge = forwardRef<HTMLDivElement, IssuedInvoiceStatusBadgeProps>(
|
||||
({ status, dotVisible, className, ...props }, ref) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const normalizedStatus = status.toLowerCase() as IssuedInvoiceStatus;
|
||||
const config = statusColorConfig[normalizedStatus];
|
||||
const commonClassName =
|
||||
"transition-colors duration-200 cursor-pointer shadow-none rounded-full";
|
||||
|
||||
if (!config) {
|
||||
return (
|
||||
<Badge className={cn(commonClassName, className)} ref={ref} {...props}>
|
||||
{status}
|
||||
</Badge>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Badge className={cn(commonClassName, config.badge, className)} {...props}>
|
||||
{dotVisible && <div className={cn("h-1.5 w-1.5 rounded-full mr-2", config.dot)} />}
|
||||
{t(`catalog.proformas.status.${normalizedStatus}`, { defaultValue: status })}
|
||||
</Badge>
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
IssuedInvoiceStatusBadge.displayName = "IssuedInvoiceStatusBadge";
|
||||
Loading…
Reference in New Issue
Block a user