Se completo la integracion del celery en la creacion de reportes

This commit is contained in:
2026-01-13 14:22:15 -06:00
parent 9d8e1283a8
commit 0c43c252a4
6 changed files with 39 additions and 26 deletions

View File

@@ -13,7 +13,10 @@ function formatDate(date?: string | null): string {
});
}
export function createColumns(onSuccess?: () => void): ColumnDef<Invoice>[] {
export function createColumns(
onSuccess?: () => void,
onDownload?: (invoice: Invoice) => void
): ColumnDef<Invoice>[] {
return [
{
accessorKey: "operation_type",
@@ -29,8 +32,8 @@ export function createColumns(onSuccess?: () => void): ColumnDef<Invoice>[] {
return {
render: () =>
`<span class="inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${colorClass}">
${label}
</span>`
${label}
</span>`
};
});
return renderSnippet(operationSnippet, { type: operationType });
@@ -149,7 +152,6 @@ export function createColumns(onSuccess?: () => void): ColumnDef<Invoice>[] {
accessorKey: "total_items",
header: "Total Partidas",
cell: ({ row }) => {
// El total de items viene del conteo de details
const totalItems = row.original.details?.length || 0;
const itemsSnippet = createRawSnippet<[{ total: number }]>((getTotal) => {
@@ -198,7 +200,6 @@ export function createColumns(onSuccess?: () => void): ColumnDef<Invoice>[] {
accessorKey: "logistics.weight_type",
header: "Tipo Peso",
cell: ({ row }) => {
// weight_type está en logistics que es un array, tomamos el primer elemento
const weightType = row.original.logistics?.weight_type;
const weightSnippet = createRawSnippet<[{ type?: string | null }]>((getType) => {
@@ -224,8 +225,8 @@ export function createColumns(onSuccess?: () => void): ColumnDef<Invoice>[] {
return {
render: () =>
`<span class="inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${colorClass}">
${label}
</span>`
${label}
</span>`
};
});
return renderSnippet(updatedSnippet, { isUpdated });
@@ -244,8 +245,8 @@ export function createColumns(onSuccess?: () => void): ColumnDef<Invoice>[] {
return {
render: () =>
`<span class="inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${colorClass}">
${label}
</span>`
${label}
</span>`
};
});
return renderSnippet(mixedSnippet, { isMixed });
@@ -267,14 +268,19 @@ export function createColumns(onSuccess?: () => void): ColumnDef<Invoice>[] {
return renderSnippet(relDocSnippet, { relDoc });
}
},
// 2. MODIFICAMOS AQUÍ: Pasamos onDownload al componente
{
id: "actions",
cell: ({ row }) => {
return renderComponent(DataTableActions, { invoice: row.original, onSuccess });
return renderComponent(DataTableActions, {
invoice: row.original,
onSuccess,
onDownload
});
}
}
];
}
// Mantener compatibilidad hacia atrás
export const columns = createColumns();