From dd4eec56f8849fad75bb871e50f93f1889cb6cc1 Mon Sep 17 00:00:00 2001 From: Kevin_Ramirez Date: Fri, 27 Mar 2026 09:15:58 -0500 Subject: [PATCH] Limpieza y correcion de warnings en ultimos cambios --- .../dashboard/goods/parts/columns.ts | 10 +- .../components/dashboard/invoices/columns.ts | 4 +- .../dashboard/invoices/data-table.svelte | 14 +- .../invoices/edit/items/fa/tab-series.svelte | 19 +- .../src/lib/components/help/HelpDrawer.svelte | 179 +++++++++--------- .../ui/data-table/data-table.svelte.ts | 6 +- 6 files changed, 121 insertions(+), 111 deletions(-) diff --git a/frontend/src/lib/components/dashboard/goods/parts/columns.ts b/frontend/src/lib/components/dashboard/goods/parts/columns.ts index 02a3b42f..b7b98ed7 100644 --- a/frontend/src/lib/components/dashboard/goods/parts/columns.ts +++ b/frontend/src/lib/components/dashboard/goods/parts/columns.ts @@ -34,7 +34,7 @@ export function createColumns(onSuccess?: () => void): ColumnDef[] { // Usamos el componente Checkbox si es posible, pero para snippets crudos en TanStack 5 // a veces es más directo un input o un Snippet de Svelte. // Aquí usaremos renderComponent para el Checkbox real. - return ""; + return ""; } }; }); @@ -162,9 +162,7 @@ export function createColumns(onSuccess?: () => void): ColumnDef[] { const { um } = getUm(); return { render: () => - ` - ${um || '-'} - ` + `${um || '-'}` }; }); return renderSnippet(umSnippet, { um: row.original.unit_of_measure }); @@ -246,7 +244,7 @@ export function createColumns(onSuccess?: () => void): ColumnDef[] { const { weight, type } = getWeight(); return { render: () => { - if (weight === null || weight === undefined) return '-'; + if (weight === null || weight === undefined) return '-'; return `
${Number(weight).toFixed(4)} ${type || ''}
`; } }; @@ -281,7 +279,7 @@ export function createColumns(onSuccess?: () => void): ColumnDef[] { cell: ({ row }) => { const dateSnippet = createRawSnippet<[{ date: string }]>((getDate) => { const { date } = getDate(); - if (!date) return { render: () => '-' }; + if (!date) return { render: () => '-' }; const formatted = new Date(date).toLocaleDateString('es-MX', { year: 'numeric', month: '2-digit', diff --git a/frontend/src/lib/components/dashboard/invoices/columns.ts b/frontend/src/lib/components/dashboard/invoices/columns.ts index 8b19c99a..a035b954 100644 --- a/frontend/src/lib/components/dashboard/invoices/columns.ts +++ b/frontend/src/lib/components/dashboard/invoices/columns.ts @@ -152,9 +152,7 @@ export function createColumns( const { type, colorClass } = getProps(); return { render: () => - ` - ${type || '-'} - ` + `${type || '-'}` }; }); return renderSnippet(typeSnippet, { type: invoiceType, colorClass }); diff --git a/frontend/src/lib/components/dashboard/invoices/data-table.svelte b/frontend/src/lib/components/dashboard/invoices/data-table.svelte index a5e37186..870a2c38 100644 --- a/frontend/src/lib/components/dashboard/invoices/data-table.svelte +++ b/frontend/src/lib/components/dashboard/invoices/data-table.svelte @@ -53,11 +53,15 @@ }, onStateChange: (updater: any) => { if (onSortingChange) { - const nextSorting = typeof updater === 'function' ? updater(sorting) : updater; - if (nextSorting.sorting !== undefined) { - onSortingChange(nextSorting.sorting); - } else { - onSortingChange(nextSorting); + const currentState = table.getState(); + const nextState = typeof updater === 'function' ? updater(currentState) : updater; + + // Identify if this was a sorting update or at least contains sorting + if (nextState && nextState.sorting !== undefined) { + onSortingChange(nextState.sorting); + } else if (Array.isArray(nextState)) { + // Fallback for when updater might return just the array slice + onSortingChange(nextState); } } }, diff --git a/frontend/src/lib/components/dashboard/invoices/edit/items/fa/tab-series.svelte b/frontend/src/lib/components/dashboard/invoices/edit/items/fa/tab-series.svelte index f362937f..08671076 100644 --- a/frontend/src/lib/components/dashboard/invoices/edit/items/fa/tab-series.svelte +++ b/frontend/src/lib/components/dashboard/invoices/edit/items/fa/tab-series.svelte @@ -64,12 +64,14 @@ : null ); - // Ensure descriptions.has_serial has default - $effect(() => { - if (descriptions && descriptions.has_serial === undefined) { - descriptions.has_serial = false; + const internalHasSerial = $derived(descriptions?.has_serial === true); + function toggleHasSerial() { + if (descriptions) { + descriptions.has_serial = !descriptions.has_serial; } - }); + } + + const hasSerial = $derived(internalHasSerial); // Ensure current serie has defaults for form fields $effect(() => { @@ -83,7 +85,6 @@ } }); - const hasSerial = $derived(Boolean(descriptions?.has_serial)); const invoiceNumber = $derived(invoice?.invoice_number || ''); const invoiceLine = $derived(lineItem?.line_number != null ? String(lineItem.line_number) : ''); const partNumber = $derived((lineItem as any)?.part_number_display || lineItem?.part_number || ''); @@ -137,7 +138,11 @@
- + { if (descriptions) descriptions.has_serial = v; }} + />
- {/if} - Base de Conocimientos - - + + {#if selectedArticle} + + {/if} + Base de Conocimientos + + -
- {#if !selectedArticle} -
-
-

Artículos Disponibles

- {#if isAdmin} - +
+ {#if !selectedArticle} +
+
+

Artículos Disponibles

+ {#if isAdmin} + + {/if} +
+ {#if isLoading} +

Cargando...

+ {:else if articles.length === 0} +

+ No hay artículos de ayuda disponibles. +

+ {/if} +
+ {#each articles as article (article.uuid)} + + {/each} +
+
+ {:else} +
+ {#if isEditing} +
+ + +
+ + +
+
+ {:else} +
+
+

{selectedArticle.title}

+ {#if isAdmin} + + {/if} +
+
+ {#if browser} + {@html renderMarkdown(selectedArticle.content)} + {:else} +
{selectedArticle.content}
+ {/if} +
+
{/if}
- {#if isLoading} -

Cargando...

- {:else if articles.length === 0} -

- No hay artículos de ayuda disponibles. -

- {/if} -
- {#each articles as article} - - {/each} -
-
- {:else} -
- {#if isEditing} -
- - -
- - -
-
- {:else} -
-
-

{selectedArticle.title}

- {#if isAdmin} - - {/if} -
-
- {@html renderMarkdown(selectedArticle.content)} -
-
- {/if} -
- {/if} -
+ {/if} +
diff --git a/frontend/src/lib/components/ui/data-table/data-table.svelte.ts b/frontend/src/lib/components/ui/data-table/data-table.svelte.ts index 5b7985e7..01f55af7 100644 --- a/frontend/src/lib/components/ui/data-table/data-table.svelte.ts +++ b/frontend/src/lib/components/ui/data-table/data-table.svelte.ts @@ -49,7 +49,8 @@ export function createSvelteTable(options: TableOptions>(table.initialState); + // Use JSON parse/stringify to ensure we get a clean, non-proxy initial state object + let state = $state>(JSON.parse(JSON.stringify(table.initialState))); function updateOptions() { table.setOptions((prev) => { @@ -105,8 +106,7 @@ export function mergeObjects[]>( return new Proxy(Object.create(null), { get(_, key) { const src = findSourceWithKey(key); - - return src?.[key as never]; + return src ? src[key as never] : undefined; }, has(_, key) {