Feature/Integracion de navegacion free mouse a pedimentos

This commit is contained in:
hreyes
2026-02-03 13:27:06 -06:00
parent 78adde9737
commit b7a99d7393
11 changed files with 1130 additions and 859 deletions

View File

@@ -1,6 +1,9 @@
<script lang="ts">
import { onMount } from 'svelte';
import { customsSectionsApi, type CustomsSection } from '$lib/api/dashboard/refrence_data/customs_sections';
import {
customsSectionsApi,
type CustomsSection
} from '$lib/api/dashboard/refrence_data/customs_sections';
import DataTable from '$lib/components/dashboard/reference_data/customs_sections/data-table.svelte';
import { createColumns } from '$lib/components/dashboard/reference_data/customs_sections/columns.js';
import CreateEditDialog from '$lib/components/dashboard/reference_data/customs_sections/create-edit-dialog.svelte';
@@ -9,10 +12,11 @@
import type { PageData } from './$types';
import { browser } from '$app/environment';
import { Plus, RefreshCw } from 'lucide-svelte';
import { useShortcuts } from '$lib/hooks/use-shortcuts';
// Los datos iniciales vienen del servidor
let { data }: { data: PageData } = $props();
// Estado para el diálogo de crear
let showCreateDialog = $state(false);
@@ -60,12 +64,12 @@
loading = true;
error = null;
try {
try {
const response = await customsSectionsApi.list(currentPage + 1, pageSize);
if (response.error) {
console.error('📊 [Page] Error en loadMore:', response.error, 'Status:', response.status);
// Si es un error de autenticación (401 o 403) y no se pudo refrescar, mostrar mensaje específico
if (response.status === 401 || response.status === 403) {
error = 'Sesión expirada. Recargando página...';
@@ -79,7 +83,7 @@
return;
}
if (response.data?.items) {
if (response.data?.items) {
// Agregar los nuevos items al array existente
allItems = [...allItems, ...response.data.items];
currentPage++;
@@ -107,6 +111,20 @@
reloadData();
}
// Keyboard Shortcuts
useShortcuts('Secciones Aduanales', [
{
key: 'Alt+Shift+N',
description: 'Nueva Sección',
action: handleCreateClick
},
{
key: 'Alt+Shift+R',
description: 'Actualizar Lista',
action: reloadData
}
]);
// Crear columnas con el callback onSuccess
const columns = createColumns(handleSuccess);
</script>
@@ -116,9 +134,7 @@
<div class="flex items-center justify-between">
<div>
<h1 class="text-3xl font-bold tracking-tight">Secciones Aduanales</h1>
<p class="text-muted-foreground">
Gestiona las secciones aduanales del sistema
</p>
<p class="text-muted-foreground">Gestiona las secciones aduanales del sistema</p>
</div>
<Button onclick={handleCreateClick}>
<Plus class="mr-2" size={16} />
@@ -154,13 +170,7 @@
</Card.Header>
<Card.Content>
<!-- TanStack DataTable con Infinite Scroll -->
<DataTable
data={allItems}
{columns}
{loading}
{hasMore}
{loadMore}
/>
<DataTable data={allItems} {columns} {loading} {hasMore} {loadMore} />
</Card.Content>
</Card.Root>
</div>

View File

@@ -1,6 +1,9 @@
<script lang="ts">
import { onMount } from 'svelte';
import { paymentMethodsApi, type PaymentMethod } from '$lib/api/dashboard/refrence_data/payment_methods';
import {
paymentMethodsApi,
type PaymentMethod
} from '$lib/api/dashboard/refrence_data/payment_methods';
import DataTable from '$lib/components/dashboard/reference_data/payment_methods/data-table.svelte';
import { createColumns } from '$lib/components/dashboard/reference_data/payment_methods/columns.js';
import CreateEditDialog from '$lib/components/dashboard/reference_data/payment_methods/create-edit-dialog.svelte';
@@ -9,10 +12,11 @@
import type { PageData } from './$types';
import { browser } from '$app/environment';
import { Plus, RefreshCw } from 'lucide-svelte';
import { useShortcuts } from '$lib/hooks/use-shortcuts';
// Los datos iniciales vienen del servidor
let { data }: { data: PageData } = $props();
// Estado para el diálogo de crear
let showCreateDialog = $state(false);
@@ -60,12 +64,12 @@
loading = true;
error = null;
try {
try {
const response = await paymentMethodsApi.list(currentPage + 1, pageSize);
if (response.error) {
console.error('📊 [Page] Error en loadMore:', response.error, 'Status:', response.status);
// Si es un error de autenticación (401 o 403) y no se pudo refrescar, mostrar mensaje específico
if (response.status === 401 || response.status === 403) {
error = 'Sesión expirada. Recargando página...';
@@ -79,7 +83,7 @@
return;
}
if (response.data?.items) {
if (response.data?.items) {
// Agregar los nuevos items al array existente
allItems = [...allItems, ...response.data.items];
currentPage++;
@@ -107,6 +111,20 @@
reloadData();
}
// Keyboard Shortcuts
useShortcuts('Métodos de Pago', [
{
key: 'Alt+Shift+N',
description: 'Nuevo Método',
action: handleCreateClick
},
{
key: 'Alt+Shift+R',
description: 'Actualizar Lista',
action: reloadData
}
]);
// Crear columnas con el callback onSuccess
const columns = createColumns(handleSuccess);
</script>
@@ -116,9 +134,7 @@
<div class="flex items-center justify-between">
<div>
<h1 class="text-3xl font-bold tracking-tight">Métodos de Pago</h1>
<p class="text-muted-foreground">
Gestiona las formas de pago disponibles en el sistema
</p>
<p class="text-muted-foreground">Gestiona las formas de pago disponibles en el sistema</p>
</div>
<Button onclick={handleCreateClick}>
<Plus class="mr-2" size={16} />
@@ -154,13 +170,7 @@
</Card.Header>
<Card.Content>
<!-- TanStack DataTable con Infinite Scroll -->
<DataTable
data={allItems}
{columns}
{loading}
{hasMore}
{loadMore}
/>
<DataTable data={allItems} {columns} {loading} {hasMore} {loadMore} />
</Card.Content>
</Card.Root>
</div>

View File

@@ -1,18 +1,22 @@
<script lang="ts">
import { onMount } from 'svelte';
import { pedimentoCodesApi, type PedimentoCode } from '$lib/api/dashboard/refrence_data/pedimento_codes';
import {
pedimentoCodesApi,
type PedimentoCode
} from '$lib/api/dashboard/refrence_data/pedimento_codes';
import DataTable from '$lib/components/dashboard/reference_data/pedimento_codes/data-table.svelte';
import { createColumns } from '$lib/components/dashboard/reference_data/pedimento_codes/columns.js';
import CreateEditDialog from '$lib/components/dashboard/reference_data/pedimento_codes/create-edit-dialog.svelte';
import * as Card from '$lib/components/ui/card';
import { Button } from '$lib/components/ui/button';
import { Plus, RefreshCw } from 'lucide-svelte';
import { useShortcuts } from '$lib/hooks/use-shortcuts';
import type { PageData } from './$types';
import { browser } from '$app/environment';
// Los datos iniciales vienen del servidor
let { data }: { data: PageData } = $props();
// Estado para el diálogo de crear
let showCreateDialog = $state(false);
@@ -60,12 +64,12 @@
loading = true;
error = null;
try {
try {
const response = await pedimentoCodesApi.list(currentPage + 1, pageSize);
if (response.error) {
console.error('📊 [Page] Error en loadMore:', response.error, 'Status:', response.status);
// Si es un error de autenticación (401 o 403) y no se pudo refrescar, mostrar mensaje específico
if (response.status === 401 || response.status === 403) {
error = 'Sesión expirada. Recargando página...';
@@ -79,7 +83,7 @@
return;
}
if (response.data?.items) {
if (response.data?.items) {
// Agregar los nuevos items al array existente
allItems = [...allItems, ...response.data.items];
currentPage++;
@@ -107,6 +111,20 @@
reloadData();
}
// Keyboard Shortcuts
useShortcuts('Claves de Pedimento', [
{
key: 'Alt+Shift+N',
description: 'Nueva Clave',
action: handleCreateClick
},
{
key: 'Alt+Shift+R',
description: 'Actualizar Lista',
action: reloadData
}
]);
// Crear columnas con el callback onSuccess
const columns = createColumns(handleSuccess);
</script>
@@ -116,9 +134,7 @@
<div class="flex items-center justify-between">
<div>
<h1 class="text-3xl font-bold tracking-tight">Claves de Pedimento</h1>
<p class="text-muted-foreground">
Gestiona las claves de pedimento del sistema aduanero
</p>
<p class="text-muted-foreground">Gestiona las claves de pedimento del sistema aduanero</p>
</div>
<Button onclick={handleCreateClick}>
<Plus class="mr-2" size={16} />
@@ -154,13 +170,7 @@
</Card.Header>
<Card.Content>
<!-- TanStack DataTable con Infinite Scroll -->
<DataTable
data={allItems}
{columns}
{loading}
{hasMore}
{loadMore}
/>
<DataTable data={allItems} {columns} {loading} {hasMore} {loadMore} />
</Card.Content>
</Card.Root>
</div>

View File

@@ -1,6 +1,9 @@
<script lang="ts">
import { onMount } from 'svelte';
import { pedimentoRegimensApi, type PedimentoRegimen } from '$lib/api/dashboard/refrence_data/pedimento_regimens';
import {
pedimentoRegimensApi,
type PedimentoRegimen
} from '$lib/api/dashboard/refrence_data/pedimento_regimens';
import DataTable from '$lib/components/dashboard/reference_data/pedimento_regimens/data-table.svelte';
import { createColumns } from '$lib/components/dashboard/reference_data/pedimento_regimens/columns.js';
import CreateEditDialog from '$lib/components/dashboard/reference_data/pedimento_regimens/create-edit-dialog.svelte';
@@ -9,10 +12,11 @@
import type { PageData } from './$types';
import { browser } from '$app/environment';
import { Plus, RefreshCw } from 'lucide-svelte';
import { useShortcuts } from '$lib/hooks/use-shortcuts';
// Los datos iniciales vienen del servidor
let { data }: { data: PageData } = $props();
// Estado para el diálogo de crear
let showCreateDialog = $state(false);
@@ -60,12 +64,12 @@
loading = true;
error = null;
try {
try {
const response = await pedimentoRegimensApi.list(currentPage + 1, pageSize);
if (response.error) {
console.error('📊 [Page] Error en loadMore:', response.error, 'Status:', response.status);
// Si es un error de autenticación (401 o 403) y no se pudo refrescar, mostrar mensaje específico
if (response.status === 401 || response.status === 403) {
error = 'Sesión expirada. Recargando página...';
@@ -79,7 +83,7 @@
return;
}
if (response.data?.items) {
if (response.data?.items) {
// Agregar los nuevos items al array existente
allItems = [...allItems, ...response.data.items];
currentPage++;
@@ -107,6 +111,20 @@
reloadData();
}
// Keyboard Shortcuts
useShortcuts('Regímenes', [
{
key: 'Alt+Shift+N',
description: 'Nuevo Régimen',
action: handleCreateClick
},
{
key: 'Alt+Shift+R',
description: 'Actualizar Lista',
action: reloadData
}
]);
// Crear columnas con el callback onSuccess
const columns = createColumns(handleSuccess);
</script>
@@ -116,9 +134,7 @@
<div class="flex items-center justify-between">
<div>
<h1 class="text-3xl font-bold tracking-tight">Regímenes de Pedimento</h1>
<p class="text-muted-foreground">
Gestiona los regímenes aduaneros de pedimento
</p>
<p class="text-muted-foreground">Gestiona los regímenes aduaneros de pedimento</p>
</div>
<Button onclick={handleCreateClick}>
<Plus class="mr-2" size={16} />
@@ -154,13 +170,7 @@
</Card.Header>
<Card.Content>
<!-- TanStack DataTable con Infinite Scroll -->
<DataTable
data={allItems}
{columns}
{loading}
{hasMore}
{loadMore}
/>
<DataTable data={allItems} {columns} {loading} {hasMore} {loadMore} />
</Card.Content>
</Card.Root>
</div>