feat(auth): synchronize access token from cookies to localStorage if not present
refactor(dashboard): create dynamic columns for CodePedimentoRegimen with onSuccess callback feat(dashboard): implement create, edit, and delete dialogs for CodePedimentoRegimen feat(dialogs): add reusable dialog components for confirmation and details display style(alert-dialog): improve styling and structure for alert dialog components style(dialog): enhance styling and structure for dialog components
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
import { onMount } from 'svelte';
|
||||
import { codePedimentoRegimensApi, type CodePedimentoRegimen } from '$lib/api/dashboard/refrence_data/code_pedimento_regimens';
|
||||
import DataTable from '$lib/components/dashboard/reference_data/code_pedimento_regimens/data-table.svelte';
|
||||
import { columns } from '$lib/components/dashboard/reference_data/code_pedimento_regimens/columns.js';
|
||||
import { createColumns } from '$lib/components/dashboard/reference_data/code_pedimento_regimens/columns.js';
|
||||
import CreateEditDialog from '$lib/components/dashboard/reference_data/code_pedimento_regimens/create-edit-dialog.svelte';
|
||||
import * as Card from '$lib/components/ui/card';
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import type { PageData } from './$types';
|
||||
@@ -10,6 +11,9 @@
|
||||
|
||||
// Los datos iniciales vienen del servidor
|
||||
let { data }: { data: PageData } = $props();
|
||||
|
||||
// Estado para el diálogo de crear
|
||||
let showCreateDialog = $state(false);
|
||||
|
||||
// Sincronizar token de cookies a localStorage al montar el componente
|
||||
onMount(() => {
|
||||
@@ -92,6 +96,18 @@
|
||||
// Reset y recargar desde el principio
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
function handleCreateClick() {
|
||||
showCreateDialog = true;
|
||||
}
|
||||
|
||||
function handleSuccess() {
|
||||
// Recargar datos después de crear/editar/eliminar
|
||||
reloadData();
|
||||
}
|
||||
|
||||
// Crear columnas con el callback onSuccess
|
||||
const columns = createColumns(handleSuccess);
|
||||
</script>
|
||||
|
||||
<div class="space-y-6">
|
||||
@@ -103,7 +119,7 @@
|
||||
Gestiona las relaciones entre códigos de pedimento y regímenes
|
||||
</p>
|
||||
</div>
|
||||
<Button>
|
||||
<Button onclick={handleCreateClick}>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="16"
|
||||
@@ -175,3 +191,6 @@
|
||||
</Card.Content>
|
||||
</Card.Root>
|
||||
</div>
|
||||
|
||||
<!-- Diálogo de crear/editar -->
|
||||
<CreateEditDialog bind:open={showCreateDialog} onSuccess={handleSuccess} />
|
||||
|
||||
Reference in New Issue
Block a user