feature/nav-tab-general-catalog
This commit is contained in:
@@ -22,7 +22,6 @@
|
||||
} from 'lucide-svelte';
|
||||
import { fly, scale } from 'svelte/transition';
|
||||
import { cubicOut } from 'svelte/easing';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosFormularioTiposCambio } from '$lib/config/shortcuts/dashboard/general_catalogs/exchange_rate/edit';
|
||||
|
||||
let {
|
||||
@@ -40,13 +39,6 @@
|
||||
} = $props();
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Formulario Tipos de Cambio',
|
||||
obtenerAtajosFormularioTiposCambio({
|
||||
manejarGuardar: handleSubmit,
|
||||
manejarCerrar: () => (open = false)
|
||||
})
|
||||
);
|
||||
|
||||
const isEdit = $derived(!!item);
|
||||
const isMissingRateContext = $derived(!isEdit && initialDate);
|
||||
|
||||
@@ -8,28 +8,23 @@
|
||||
let checked = $state(false);
|
||||
|
||||
async function checkExchangeRate() {
|
||||
console.log('[ExchangeRateGuard] Checking...', companyStore.activeCompany);
|
||||
if (!companyStore.activeCompany?.id) {
|
||||
console.log('[ExchangeRateGuard] No active company');
|
||||
return;
|
||||
}
|
||||
|
||||
// Use local date instead of UTC
|
||||
const today = new Date().toLocaleDateString('fr-CA'); // YYYY-MM-DD
|
||||
console.log('[ExchangeRateGuard] Date:', today);
|
||||
|
||||
try {
|
||||
const response = await getExchangeRates(companyStore.activeCompany.id, {
|
||||
date: today,
|
||||
page_size: 1
|
||||
});
|
||||
console.log('[ExchangeRateGuard] Response (stringified):', JSON.stringify(response, null, 2));
|
||||
|
||||
// api.get returns { data: ..., status: ... } and types now reflect that
|
||||
const items = response.data?.items || [];
|
||||
|
||||
if (items.length === 0) {
|
||||
console.log('[ExchangeRateGuard] No rate found, opening modal');
|
||||
open = true;
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -46,8 +41,6 @@
|
||||
});
|
||||
|
||||
function handleSuccess() {
|
||||
|
||||
console.log('Exchange rate created successfully via guard');
|
||||
checked = true;
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
} from '$lib/api/dashboard/a76/general_catalogs/classification-concepts';
|
||||
// 👇 2. Importamos el Store para el ID de la empresa
|
||||
import { companyStore } from '$lib/stores/company.svelte';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosFormularioClasificacion } from '$lib/config/shortcuts/dashboard/general_catalogs/classification/edit';
|
||||
|
||||
let {
|
||||
@@ -25,13 +24,6 @@
|
||||
} = $props();
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Formulario Clasificación',
|
||||
obtenerAtajosFormularioClasificacion({
|
||||
manejarGuardar: handleSubmit,
|
||||
manejarCerrar: () => (open = false)
|
||||
})
|
||||
);
|
||||
|
||||
const isEdit = $derived(!!item);
|
||||
const title = $derived(isEdit ? 'Editar Clasificación' : 'Nueva Clasificación');
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
type Concept
|
||||
} from '$lib/api/dashboard/a76/general_catalogs/concepts';
|
||||
import { companyStore } from '$lib/stores/company.svelte';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosFormularioConceptos } from '$lib/config/shortcuts/dashboard/general_catalogs/concepts/edit';
|
||||
|
||||
let {
|
||||
@@ -25,13 +24,6 @@
|
||||
} = $props();
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Formulario Conceptos',
|
||||
obtenerAtajosFormularioConceptos({
|
||||
manejarGuardar: handleSubmit,
|
||||
manejarCerrar: () => (open = false)
|
||||
})
|
||||
);
|
||||
|
||||
const isEdit = $derived(!!item);
|
||||
const title = $derived(isEdit ? 'Editar Concepto' : 'Nuevo Concepto');
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
type CustomsBrokerConcept,
|
||||
type CustomsBrokerConceptCreate
|
||||
} from '$lib/api/dashboard/a76/general_catalogs/customs-broker-concepts';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosFormularioConceptosAA } from '$lib/config/shortcuts/dashboard/general_catalogs/customs_broker_concepts/edit';
|
||||
|
||||
let {
|
||||
@@ -25,13 +24,6 @@
|
||||
} = $props();
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Formulario Conceptos AA',
|
||||
obtenerAtajosFormularioConceptosAA({
|
||||
manejarGuardar: handleSubmit,
|
||||
manejarCerrar: () => (open = false)
|
||||
})
|
||||
);
|
||||
|
||||
const isEdit = $derived(!!item);
|
||||
const title = $derived(isEdit ? 'Editar Concepto AA' : 'Nuevo Concepto AA');
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import { deleteCustomsBrokerConcept, type CustomsBrokerConcept } from "$lib/api/dashboard/a76/general_catalogs/customs-broker-concepts";
|
||||
import { companyStore } from "$lib/stores/company.svelte";
|
||||
import { EllipsisVertical, Pencil, LoaderCircle, Trash2 } from 'lucide-svelte';
|
||||
import CreateEditDialog from "./create-edite-dialoge.svelte";
|
||||
import CreateEditDialog from "./create-edit-dialog.svelte";
|
||||
|
||||
let {
|
||||
item,
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
import { companyStore } from '$lib/stores/company.svelte';
|
||||
import { createDoda, updateDoda, type Doda } from '$lib/api/dashboard/a76/general_catalogs/doda';
|
||||
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosFormularioDoda } from '$lib/config/shortcuts/dashboard/general_catalogs/doda/edit';
|
||||
|
||||
let {
|
||||
@@ -65,13 +64,6 @@
|
||||
let error = $state<string | null>(null);
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
obtenerAtajosFormularioDoda({
|
||||
cambiarPestana: (pestana) => (activeTab = pestana),
|
||||
manejarGuardar: handleSubmit,
|
||||
manejarCerrar: () => (open = false)
|
||||
})
|
||||
);
|
||||
|
||||
// Cargar datos
|
||||
$effect(() => {
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
import { Input } from '$lib/components/ui/input';
|
||||
import { Label } from '$lib/components/ui/label';
|
||||
import { companyStore } from '$lib/stores/company.svelte';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosFormularioAvisosElectrónicos } from '$lib/config/shortcuts/dashboard/general_catalogs/electronic_notices/edit';
|
||||
|
||||
let {
|
||||
@@ -18,13 +17,6 @@
|
||||
} = $props();
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Formulario Avisos Electrónicos',
|
||||
obtenerAtajosFormularioAvisosElectrónicos({
|
||||
manejarGuardar: handleSubmit,
|
||||
manejarCerrar: () => (open = false)
|
||||
})
|
||||
);
|
||||
|
||||
const isEdit = $derived(!!item);
|
||||
const title = $derived(
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
updateEquivalency,
|
||||
type Equivalency
|
||||
} from '$lib/api/dashboard/a76/general_catalogs/equivalencies';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosFormularioEquivalencias } from '$lib/config/shortcuts/dashboard/general_catalogs/equivalencies/edit';
|
||||
|
||||
let {
|
||||
@@ -23,13 +22,6 @@
|
||||
} = $props();
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Formulario Equivalencias',
|
||||
obtenerAtajosFormularioEquivalencias({
|
||||
manejarGuardar: handleSubmit,
|
||||
manejarCerrar: () => (open = false)
|
||||
})
|
||||
);
|
||||
|
||||
const isEdit = $derived(!!item);
|
||||
const title = $derived(
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
type ErrorClassification
|
||||
} from '$lib/api/dashboard/a76/general_catalogs/error-catalogs';
|
||||
import { companyStore } from '$lib/stores/company.svelte';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosFormularioErrores } from '$lib/config/shortcuts/dashboard/general_catalogs/error_catalogs/edit';
|
||||
|
||||
let {
|
||||
@@ -26,13 +25,6 @@
|
||||
} = $props();
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Formulario Errores',
|
||||
obtenerAtajosFormularioErrores({
|
||||
manejarGuardar: handleSubmit,
|
||||
manejarCerrar: () => (open = false)
|
||||
})
|
||||
);
|
||||
|
||||
const isEdit = $derived(!!item);
|
||||
const title = $derived(isEdit ? 'Editar Error' : 'Nuevo Error');
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
import { Input } from '$lib/components/ui/input';
|
||||
import { Label } from '$lib/components/ui/label';
|
||||
import { companyStore } from '$lib/stores/company.svelte';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosFormularioIdentificadores } from '$lib/config/shortcuts/dashboard/general_catalogs/identifiers/edit';
|
||||
|
||||
let {
|
||||
@@ -18,13 +17,6 @@
|
||||
} = $props();
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Formulario Identificadores',
|
||||
obtenerAtajosFormularioIdentificadores({
|
||||
manejarGuardar: handleSubmit,
|
||||
manejarCerrar: () => (open = false)
|
||||
})
|
||||
);
|
||||
|
||||
const isEdit = $derived(!!item);
|
||||
const title = $derived(
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
import { Label } from '$lib/components/ui/label';
|
||||
import { companyStore } from '$lib/stores/company.svelte';
|
||||
import { createINPC, updateINPC, type INPC } from '$lib/api/dashboard/a76/general_catalogs/inpc';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosFormularioInpc } from '$lib/config/shortcuts/dashboard/general_catalogs/inpc/edit';
|
||||
|
||||
let {
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { Button } from "$lib/components/ui/button";
|
||||
import * as Dialog from "$lib/components/ui/dialog";
|
||||
import { Input } from "$lib/components/ui/input";
|
||||
import { Label } from "$lib/components/ui/label";
|
||||
import {
|
||||
createINPC,
|
||||
updateINPC,
|
||||
type INPC
|
||||
} from "$lib/api/dashboard/a76/general_catalogs/inpc";
|
||||
import { companyStore } from "$lib/stores/company.svelte";
|
||||
|
||||
let {
|
||||
open = $bindable(false),
|
||||
item = null,
|
||||
onSuccess
|
||||
}: {
|
||||
open: boolean;
|
||||
item?: INPC | null;
|
||||
onSuccess?: () => void;
|
||||
} = $props();
|
||||
|
||||
const isEdit = $derived(!!item);
|
||||
const title = $derived(isEdit ? "Editar INPC" : "Nuevo INPC");
|
||||
|
||||
let formData = $state({
|
||||
year: '',
|
||||
month: '',
|
||||
value: null as number | null
|
||||
});
|
||||
|
||||
let loading = $state(false);
|
||||
let error = $state<string | null>(null);
|
||||
|
||||
// Cargar datos al abrir
|
||||
$effect(() => {
|
||||
if (open) {
|
||||
if (item) {
|
||||
formData = {
|
||||
year: item.year,
|
||||
month: item.month,
|
||||
value: item.value || null
|
||||
};
|
||||
} else {
|
||||
formData = {
|
||||
year: '',
|
||||
month: '',
|
||||
value: null
|
||||
};
|
||||
}
|
||||
error = null;
|
||||
}
|
||||
});
|
||||
|
||||
async function handleSubmit() {
|
||||
loading = true;
|
||||
error = null;
|
||||
|
||||
try {
|
||||
const companyId = companyStore.activeCompany?.id;
|
||||
if (!companyId) throw new Error('No hay una compañía seleccionada');
|
||||
|
||||
// Validaciones
|
||||
if (!formData.year.trim()) throw new Error('El año es requerido');
|
||||
if (formData.year.length !== 4) throw new Error('El año debe tener 4 dígitos');
|
||||
if (!formData.month.trim()) throw new Error('El mes es requerido');
|
||||
|
||||
// Preparar datos (limpios)
|
||||
const dataToSend = {
|
||||
year: formData.year.trim(),
|
||||
month: formData.month.trim(),
|
||||
value: formData.value // Ya es número o null
|
||||
};
|
||||
|
||||
let response;
|
||||
|
||||
|
||||
if (isEdit && item) {
|
||||
response = await updateINPC(item.id, dataToSend, companyId);
|
||||
} else {
|
||||
|
||||
response = await createINPC(dataToSend, companyId);
|
||||
}
|
||||
|
||||
open = false;
|
||||
if (onSuccess) onSuccess();
|
||||
|
||||
} catch (e) {
|
||||
error = e instanceof Error ? e.message : 'Error al guardar el INPC';
|
||||
} finally {
|
||||
loading = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Dialog.Root bind:open>
|
||||
<Dialog.Content class="sm:max-w-[400px]">
|
||||
<Dialog.Header>
|
||||
<Dialog.Title>{title}</Dialog.Title>
|
||||
</Dialog.Header>
|
||||
|
||||
<form onsubmit={(e) => { e.preventDefault(); handleSubmit(); }} class="space-y-4 py-4">
|
||||
{#if error}
|
||||
<div class="rounded-md bg-destructive/15 p-3 text-sm text-destructive">
|
||||
{error}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="grid gap-4">
|
||||
<div class="grid grid-cols-4 items-center gap-4">
|
||||
<Label for="year" class="text-right">Año <span class="text-destructive">*</span></Label>
|
||||
<div class="col-span-3">
|
||||
<Input
|
||||
id="year"
|
||||
bind:value={formData.year}
|
||||
placeholder="Ej: 2025"
|
||||
maxlength={4}
|
||||
disabled={loading}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-4 items-center gap-4">
|
||||
<Label for="month" class="text-right">Mes <span class="text-destructive">*</span></Label>
|
||||
<div class="col-span-3">
|
||||
<Input
|
||||
id="month"
|
||||
bind:value={formData.month}
|
||||
placeholder="Ej: 01"
|
||||
maxlength={2}
|
||||
disabled={loading}
|
||||
required
|
||||
/>
|
||||
<p class="text-[10px] text-muted-foreground mt-1">Formato MM (Ej: 01, 12)</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-4 items-center gap-4">
|
||||
<Label for="value" class="text-right">Valor</Label>
|
||||
<div class="col-span-3">
|
||||
<Input
|
||||
id="value"
|
||||
type="number"
|
||||
step="0.00000001"
|
||||
bind:value={formData.value}
|
||||
placeholder="0.0000"
|
||||
disabled={loading}
|
||||
/>
|
||||
<p class="text-[10px] text-muted-foreground mt-1">Hasta 8 decimales</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Dialog.Footer>
|
||||
<Button type="button" variant="outline" onclick={() => open = false} disabled={loading}>
|
||||
Cancelar
|
||||
</Button>
|
||||
<Button type="submit" disabled={loading}>
|
||||
{loading ? 'Guardando...' : isEdit ? 'Actualizar' : 'Crear'}
|
||||
</Button>
|
||||
</Dialog.Footer>
|
||||
</form>
|
||||
</Dialog.Content>
|
||||
</Dialog.Root>
|
||||
@@ -10,7 +10,6 @@
|
||||
type Legend
|
||||
} from '$lib/api/dashboard/a76/general_catalogs/legends';
|
||||
import { companyStore } from '$lib/stores/company.svelte';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosFormularioLeyendas } from '$lib/config/shortcuts/dashboard/general_catalogs/legends/edit';
|
||||
|
||||
let {
|
||||
@@ -24,13 +23,6 @@
|
||||
} = $props();
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Formulario Leyendas',
|
||||
obtenerAtajosFormularioLeyendas({
|
||||
manejarGuardar: handleSubmit,
|
||||
manejarCerrar: () => (open = false)
|
||||
})
|
||||
);
|
||||
|
||||
const isEdit = $derived(!!item);
|
||||
const title = $derived(isEdit ? 'Editar Leyenda' : 'Nueva Leyenda');
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import { deleteLegend, type Legend } from "$lib/api/dashboard/a76/general_catalogs/legends";
|
||||
import { companyStore } from "$lib/stores/company.svelte";
|
||||
import { EllipsisVertical, Pencil, LoaderCircle, Trash2 } from 'lucide-svelte';
|
||||
import CreateDialog from '$lib/components/dashboard/general_catalogs/legend/create-edite-dialoge.svelte';
|
||||
import CreateDialog from './create-edit-dialog.svelte';
|
||||
|
||||
|
||||
let {
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
type Location
|
||||
} from '$lib/api/dashboard/a76/general_catalogs/locations';
|
||||
import { companyStore } from '$lib/stores/company.svelte';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosFormularioLocalidades } from '$lib/config/shortcuts/dashboard/general_catalogs/locations/edit';
|
||||
|
||||
let {
|
||||
@@ -23,13 +22,6 @@
|
||||
} = $props();
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Formulario Localidades',
|
||||
obtenerAtajosFormularioLocalidades({
|
||||
manejarGuardar: handleSubmit,
|
||||
manejarCerrar: () => (open = false)
|
||||
})
|
||||
);
|
||||
|
||||
const isEdit = $derived(!!item);
|
||||
const title = $derived(isEdit ? 'Editar Ubicación' : 'Nueva Ubicación');
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
type MultiCurrencyType
|
||||
} from '$lib/api/dashboard/a76/general_catalogs/multi-currency-types';
|
||||
import { companyStore } from '$lib/stores/company.svelte';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosFormularioMonedas } from '$lib/config/shortcuts/dashboard/general_catalogs/multi_currency_types/edit';
|
||||
|
||||
let {
|
||||
@@ -24,13 +23,6 @@
|
||||
} = $props();
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Formulario Monedas',
|
||||
obtenerAtajosFormularioMonedas({
|
||||
manejarGuardar: handleSubmit,
|
||||
manejarCerrar: () => (open = false)
|
||||
})
|
||||
);
|
||||
|
||||
const isEdit = $derived(!!item);
|
||||
const title = $derived(
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
updatePrevalidator,
|
||||
type Prevalidator
|
||||
} from '$lib/api/dashboard/a76/general_catalogs/prevalidators';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosFormularioPrevalidadores } from '$lib/config/shortcuts/dashboard/general_catalogs/prevalidators/edit';
|
||||
|
||||
let {
|
||||
@@ -26,13 +25,6 @@
|
||||
const title = $derived(isEdit ? `Editar Prevalidador ${item?.code || ''}` : 'Nuevo Prevalidador');
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Formulario Prevalidadores',
|
||||
obtenerAtajosFormularioPrevalidadores({
|
||||
manejarGuardar: handleSubmit,
|
||||
manejarCerrar: () => (open = false)
|
||||
})
|
||||
);
|
||||
|
||||
// Estado del formulario
|
||||
let formData = $state({
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
type Signature
|
||||
} from '$lib/api/dashboard/a76/general_catalogs/signatures';
|
||||
import { companyStore } from '$lib/stores/company.svelte';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosFormularioFirmas } from '$lib/config/shortcuts/dashboard/general_catalogs/signatures/edit';
|
||||
|
||||
let {
|
||||
@@ -25,13 +24,6 @@
|
||||
} = $props();
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Formulario Firmas',
|
||||
obtenerAtajosFormularioFirmas({
|
||||
manejarGuardar: handleSubmit,
|
||||
manejarCerrar: () => (open = false)
|
||||
})
|
||||
);
|
||||
|
||||
const isEdit = $derived(!!item);
|
||||
const title = $derived(isEdit ? 'Editar Firma' : 'Nueva Firma');
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
type UnitConversion
|
||||
} from '$lib/api/dashboard/a76/general_catalogs/unit-conversions';
|
||||
import { companyStore } from '$lib/stores/company.svelte';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosFormularioConversiones } from '$lib/config/shortcuts/dashboard/general_catalogs/unit_conversions/edit';
|
||||
|
||||
let {
|
||||
@@ -25,13 +24,6 @@
|
||||
} = $props();
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Formulario Conversiones',
|
||||
obtenerAtajosFormularioConversiones({
|
||||
manejarGuardar: handleSubmit,
|
||||
manejarCerrar: () => (open = false)
|
||||
})
|
||||
);
|
||||
|
||||
const isEdit = $derived(mode === 'edit');
|
||||
const title = $derived(isEdit ? 'Editar Conversión' : 'Nueva Conversión');
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
type UnitOfMeasureACE
|
||||
} from '$lib/api/dashboard/a76/general_catalogs/units-of-measure';
|
||||
import { companyStore } from '$lib/stores/company.svelte';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosFormularioUnidadesACE } from '$lib/config/shortcuts/dashboard/general_catalogs/units_of_measure/ace/edit';
|
||||
|
||||
let {
|
||||
@@ -23,13 +22,6 @@
|
||||
} = $props();
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Formulario Unidades ACE',
|
||||
obtenerAtajosFormularioUnidadesACE({
|
||||
manejarGuardar: () => handleSubmit(),
|
||||
manejarCerrar: () => (open = false)
|
||||
})
|
||||
);
|
||||
|
||||
const isEdit = $derived(!!item);
|
||||
const title = $derived(isEdit ? 'Editar Unidad ACE' : 'Nueva Unidad ACE');
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
updateUnitOfMeasureAmerican
|
||||
} from '$lib/api/dashboard/a76/general_catalogs/units-of-measure';
|
||||
import { companyStore } from '$lib/stores/company.svelte';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosFormularioUnidadesAmericanas } from '$lib/config/shortcuts/dashboard/general_catalogs/units_of_measure/american/edit';
|
||||
|
||||
interface Props {
|
||||
@@ -25,13 +24,6 @@
|
||||
let { open = $bindable(), unit, onSuccess }: Props = $props();
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Formulario Unidades Americanas',
|
||||
obtenerAtajosFormularioUnidadesAmericanas({
|
||||
manejarGuardar: (e: any) => handleSubmit(e),
|
||||
manejarCerrar: () => (open = false)
|
||||
})
|
||||
);
|
||||
|
||||
let formData = $state({
|
||||
code: '',
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
updateUnitOfMeasureCustoms
|
||||
} from '$lib/api/dashboard/a76/general_catalogs/units-of-measure';
|
||||
import { companyStore } from '$lib/stores/company.svelte';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosFormularioUnidadesAduanas } from '$lib/config/shortcuts/dashboard/general_catalogs/units_of_measure/customs/edit';
|
||||
|
||||
interface Props {
|
||||
@@ -25,13 +24,6 @@
|
||||
let { open = $bindable(), unit, onSuccess }: Props = $props();
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Formulario Unidades Aduanas',
|
||||
obtenerAtajosFormularioUnidadesAduanas({
|
||||
manejarGuardar: handleSubmit,
|
||||
manejarCerrar: () => (open = false)
|
||||
})
|
||||
);
|
||||
|
||||
let formData = $state({
|
||||
code: '',
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
updateUnitOfMeasureGeneral
|
||||
} from '$lib/api/dashboard/a76/general_catalogs/units-of-measure';
|
||||
import { companyStore } from '$lib/stores/company.svelte';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosFormularioUnidadesGeneral } from '$lib/config/shortcuts/dashboard/general_catalogs/units_of_measure/general/edit';
|
||||
|
||||
interface Props {
|
||||
@@ -25,13 +24,6 @@
|
||||
let { open = $bindable(), unit, onSuccess }: Props = $props();
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Formulario Unidades de Medida',
|
||||
obtenerAtajosFormularioUnidadesGeneral({
|
||||
manejarGuardar: (e: any) => handleSubmit(e),
|
||||
manejarCerrar: () => (open = false)
|
||||
})
|
||||
);
|
||||
|
||||
let formData = $state({
|
||||
code: '',
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
updateUnitOfMeasureOMA
|
||||
} from '$lib/api/dashboard/a76/general_catalogs/units-of-measure';
|
||||
import { companyStore } from '$lib/stores/company.svelte';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosFormularioUnidadesOMA } from '$lib/config/shortcuts/dashboard/general_catalogs/units_of_measure/oma/edit';
|
||||
|
||||
interface Props {
|
||||
@@ -25,13 +24,6 @@
|
||||
let { open = $bindable(), unit, onSuccess }: Props = $props();
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Formulario Unidades OMA',
|
||||
obtenerAtajosFormularioUnidadesOMA({
|
||||
manejarGuardar: (e: any) => handleSubmit(e),
|
||||
manejarCerrar: () => (open = false)
|
||||
})
|
||||
);
|
||||
|
||||
let formData = $state({
|
||||
code: '',
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
type Package
|
||||
} from '$lib/api/dashboard/a76/general_catalogs/packages';
|
||||
import { companyStore } from '$lib/stores/company.svelte';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosFormularioBultos } from '$lib/config/shortcuts/dashboard/general_catalogs/packages/edit';
|
||||
|
||||
let {
|
||||
@@ -27,13 +26,6 @@
|
||||
const title = $derived(isEdit ? 'Editar Bulto' : 'Nuevo Bulto');
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Formulario Bultos',
|
||||
obtenerAtajosFormularioBultos({
|
||||
manejarGuardar: handleSubmit,
|
||||
manejarCerrar: () => (open = false)
|
||||
})
|
||||
);
|
||||
|
||||
// Estado del formulario
|
||||
let formData = $state({
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
PortType
|
||||
} from '$lib/api/dashboard/a76/general_catalogs/ports';
|
||||
import { companyStore } from '$lib/stores/company.svelte';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosFormularioPuertos } from '$lib/config/shortcuts/dashboard/general_catalogs/ports/edit';
|
||||
|
||||
let {
|
||||
@@ -30,13 +29,6 @@
|
||||
const title = $derived(isEdit ? 'Editar Puerto' : 'Nuevo Puerto');
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Formulario Puertos',
|
||||
obtenerAtajosFormularioPuertos({
|
||||
manejarGuardar: handleSubmit,
|
||||
manejarCerrar: () => (open = false)
|
||||
})
|
||||
);
|
||||
|
||||
let formData = $state({
|
||||
port_code: '',
|
||||
|
||||
@@ -62,5 +62,5 @@
|
||||
|
||||
<!-- Dialogs -->
|
||||
<DetailsDialog bind:open={showDetailsDialog} {item} />
|
||||
<CreateEditDialog bind:open={showEditDialog} bind:item {onSuccess} />
|
||||
<CreateEditDialog bind:open={showEditDialog} item={item} {onSuccess} />
|
||||
<DeleteDialog bind:open={showDeleteDialog} {item} {onSuccess} />
|
||||
|
||||
@@ -62,5 +62,5 @@
|
||||
|
||||
<!-- Dialogs -->
|
||||
<DetailsDialog bind:open={showDetailsDialog} {item} />
|
||||
<CreateEditDialog bind:open={showEditDialog} bind:item {onSuccess} />
|
||||
<CreateEditDialog bind:open={showEditDialog} item={item} {onSuccess} />
|
||||
<DeleteDialog bind:open={showDeleteDialog} {item} {onSuccess} />
|
||||
|
||||
@@ -62,5 +62,5 @@
|
||||
|
||||
<!-- Dialogs -->
|
||||
<DetailsDialog bind:open={showDetailsDialog} {item} />
|
||||
<CreateEditDialog bind:open={showEditDialog} bind:item {onSuccess} />
|
||||
<CreateEditDialog bind:open={showEditDialog} item={item} {onSuccess} />
|
||||
<DeleteDialog bind:open={showDeleteDialog} {item} {onSuccess} />
|
||||
|
||||
@@ -62,5 +62,5 @@
|
||||
|
||||
<!-- Dialogs -->
|
||||
<DetailsDialog bind:open={showDetailsDialog} {item} />
|
||||
<CreateEditDialog bind:open={showEditDialog} bind:item {onSuccess} />
|
||||
<CreateEditDialog bind:open={showEditDialog} item={item} {onSuccess} />
|
||||
<DeleteDialog bind:open={showDeleteDialog} {item} {onSuccess} />
|
||||
|
||||
@@ -62,5 +62,5 @@
|
||||
|
||||
<!-- Dialogs -->
|
||||
<DetailsDialog bind:open={showDetailsDialog} {item} />
|
||||
<CreateEditDialog bind:open={showEditDialog} bind:item {onSuccess} />
|
||||
<CreateEditDialog bind:open={showEditDialog} item={item} {onSuccess} />
|
||||
<DeleteDialog bind:open={showDeleteDialog} {item} {onSuccess} />
|
||||
|
||||
@@ -62,5 +62,5 @@
|
||||
|
||||
<!-- Dialogs -->
|
||||
<DetailsDialog bind:open={showDetailsDialog} {item} />
|
||||
<CreateEditDialog bind:open={showEditDialog} bind:item {onSuccess} />
|
||||
<CreateEditDialog bind:open={showEditDialog} item={item} {onSuccess} />
|
||||
<DeleteDialog bind:open={showDeleteDialog} {item} {onSuccess} />
|
||||
|
||||
@@ -62,5 +62,5 @@
|
||||
|
||||
<!-- Dialogs -->
|
||||
<DetailsDialog bind:open={showDetailsDialog} {item} />
|
||||
<CreateEditDialog bind:open={showEditDialog} bind:item {onSuccess} />
|
||||
<CreateEditDialog bind:open={showEditDialog} item={item} {onSuccess} />
|
||||
<DeleteDialog bind:open={showDeleteDialog} {item} {onSuccess} />
|
||||
|
||||
@@ -62,5 +62,5 @@
|
||||
|
||||
<!-- Dialogs -->
|
||||
<DetailsDialog bind:open={showDetailsDialog} {item} />
|
||||
<CreateEditDialog bind:open={showEditDialog} bind:item {onSuccess} />
|
||||
<CreateEditDialog bind:open={showEditDialog} item={item} {onSuccess} />
|
||||
<DeleteDialog bind:open={showDeleteDialog} {item} {onSuccess} />
|
||||
|
||||
@@ -62,5 +62,5 @@
|
||||
|
||||
<!-- Dialogs -->
|
||||
<DetailsDialog bind:open={showDetailsDialog} {item} />
|
||||
<CreateEditDialog bind:open={showEditDialog} bind:item {onSuccess} />
|
||||
<CreateEditDialog bind:open={showEditDialog} item={item} {onSuccess} />
|
||||
<DeleteDialog bind:open={showDeleteDialog} {item} {onSuccess} />
|
||||
|
||||
@@ -62,5 +62,5 @@
|
||||
|
||||
<!-- Dialogs -->
|
||||
<DetailsDialog bind:open={showDetailsDialog} {item} />
|
||||
<CreateEditDialog bind:open={showEditDialog} bind:item {onSuccess} />
|
||||
<CreateEditDialog bind:open={showEditDialog} item={item} {onSuccess} />
|
||||
<DeleteDialog bind:open={showDeleteDialog} {item} {onSuccess} />
|
||||
|
||||
@@ -62,5 +62,5 @@
|
||||
|
||||
<!-- Dialogs -->
|
||||
<DetailsDialog bind:open={showDetailsDialog} {item} />
|
||||
<CreateEditDialog bind:open={showEditDialog} bind:item {onSuccess} />
|
||||
<CreateEditDialog bind:open={showEditDialog} item={item} {onSuccess} />
|
||||
<DeleteDialog bind:open={showDeleteDialog} {item} {onSuccess} />
|
||||
|
||||
@@ -62,5 +62,5 @@
|
||||
|
||||
<!-- Dialogs -->
|
||||
<DetailsDialog bind:open={showDetailsDialog} {item} />
|
||||
<CreateEditDialog bind:open={showEditDialog} bind:item {onSuccess} />
|
||||
<CreateEditDialog bind:open={showEditDialog} item={item} {onSuccess} />
|
||||
<DeleteDialog bind:open={showDeleteDialog} {item} {onSuccess} />
|
||||
|
||||
@@ -62,5 +62,5 @@
|
||||
|
||||
<!-- Dialogs -->
|
||||
<DetailsDialog bind:open={showDetailsDialog} {item} />
|
||||
<CreateEditDialog bind:open={showEditDialog} bind:item {onSuccess} />
|
||||
<CreateEditDialog bind:open={showEditDialog} item={item} {onSuccess} />
|
||||
<DeleteDialog bind:open={showDeleteDialog} {item} {onSuccess} />
|
||||
|
||||
@@ -62,5 +62,5 @@
|
||||
|
||||
<!-- Dialogs -->
|
||||
<DetailsDialog bind:open={showDetailsDialog} {item} />
|
||||
<CreateEditDialog bind:open={showEditDialog} bind:item {onSuccess} />
|
||||
<CreateEditDialog bind:open={showEditDialog} item={item} {onSuccess} />
|
||||
<DeleteDialog bind:open={showDeleteDialog} {item} {onSuccess} />
|
||||
|
||||
@@ -62,5 +62,5 @@
|
||||
|
||||
<!-- Dialogs -->
|
||||
<DetailsDialog bind:open={showDetailsDialog} {item} />
|
||||
<CreateEditDialog bind:open={showEditDialog} bind:item {onSuccess} />
|
||||
<CreateEditDialog bind:open={showEditDialog} item={item} {onSuccess} />
|
||||
<DeleteDialog bind:open={showDeleteDialog} {item} {onSuccess} />
|
||||
|
||||
@@ -62,5 +62,5 @@
|
||||
|
||||
<!-- Dialogs -->
|
||||
<DetailsDialog bind:open={showDetailsDialog} {item} />
|
||||
<CreateEditDialog bind:open={showEditDialog} bind:item {onSuccess} />
|
||||
<CreateEditDialog bind:open={showEditDialog} item={item} {onSuccess} />
|
||||
<DeleteDialog bind:open={showDeleteDialog} {item} {onSuccess} />
|
||||
|
||||
@@ -62,5 +62,5 @@
|
||||
|
||||
<!-- Dialogs -->
|
||||
<DetailsDialog bind:open={showDetailsDialog} {item} />
|
||||
<CreateEditDialog bind:open={showEditDialog} bind:item {onSuccess} />
|
||||
<CreateEditDialog bind:open={showEditDialog} item={item} {onSuccess} />
|
||||
<DeleteDialog bind:open={showDeleteDialog} {item} {onSuccess} />
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
import type { Seal } from '$lib/api/dashboard/a76/general_catalogs/seal';
|
||||
import { createSeal, updateSeal } from '$lib/api/dashboard/a76/general_catalogs/seal';
|
||||
import { companyStore } from '$lib/stores/company.svelte';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosFormularioSellos } from '$lib/config/shortcuts/dashboard/general_catalogs/seal/edit';
|
||||
|
||||
let {
|
||||
@@ -21,13 +20,6 @@
|
||||
} = $props();
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Formulario Sellos',
|
||||
obtenerAtajosFormularioSellos({
|
||||
manejarGuardar: (e: any) => handleSubmit(e),
|
||||
manejarCerrar: () => (open = false)
|
||||
})
|
||||
);
|
||||
|
||||
let loading = $state(false);
|
||||
let error = $state<string | null>(null);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/stores';
|
||||
import { browser } from '$app/environment';
|
||||
import { GLOBAL_NAV } from '$lib/config/shortcuts';
|
||||
import { shortcutStore, activeShortcutsList } from '$lib/stores/shortcut-store';
|
||||
import { focusStore } from '$lib/stores/focus-store';
|
||||
@@ -8,6 +10,16 @@
|
||||
let showHelp = $state(false);
|
||||
let lastShortcutTime = 0;
|
||||
|
||||
// Verificar si el usuario está autenticado
|
||||
function isAuthenticated(): boolean {
|
||||
if (!browser) return false;
|
||||
const currentPath = $page?.url?.pathname || '';
|
||||
const isAuthenticatedRoute = currentPath.startsWith('/dashboard');
|
||||
const hasAccessToken = document.cookie.includes('access_token=') ||
|
||||
localStorage.getItem('access_token');
|
||||
return isAuthenticatedRoute && !!hasAccessToken;
|
||||
}
|
||||
|
||||
function autoFocusFirstInput() {
|
||||
// Small delay to allow Svelte to render the new view
|
||||
setTimeout(() => {
|
||||
@@ -101,6 +113,9 @@
|
||||
});
|
||||
|
||||
function handleKeydown(event: KeyboardEvent) {
|
||||
// Verificar autenticación al inicio
|
||||
const authenticated = isAuthenticated();
|
||||
|
||||
const { key, altKey, ctrlKey, metaKey, shiftKey } = event;
|
||||
const lowerKey = key.toLowerCase();
|
||||
|
||||
@@ -138,6 +153,10 @@
|
||||
|
||||
// 1. HELP: F1
|
||||
if (key === 'F1') {
|
||||
// Solo permitir F1 si está autenticado
|
||||
if (!isAuthenticated()) {
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
showHelp = !showHelp;
|
||||
return;
|
||||
@@ -160,28 +179,30 @@
|
||||
}
|
||||
|
||||
// 3. PRIORITY: LOCAL SHORTCUTS
|
||||
// Match exact combo string against registered shortcuts
|
||||
// Search in REVERSE order (LIFO) so recent contexts (modals) override earlier ones (pages)
|
||||
const reversedShortcuts = [...$activeShortcutsList].reverse();
|
||||
let match = reversedShortcuts.find((s) => s.key === combo);
|
||||
// Solo permitir atajos locales si está autenticado
|
||||
if (authenticated) {
|
||||
// Match exact combo string against registered shortcuts
|
||||
// Search in REVERSE order (LIFO) so recent contexts (modals) override earlier ones (pages)
|
||||
const reversedShortcuts = [...$activeShortcutsList].reverse();
|
||||
let match = reversedShortcuts.find((s) => s.key === combo);
|
||||
|
||||
// Fallback: If no match found by 'key' (e.g. Shift+1 produces 'Alt+Shift+!'),
|
||||
// try matching by 'code' (e.g. 'Alt+Shift+Digit1')
|
||||
if (!match) {
|
||||
const codeCombo = [...modifiers, event.code].join('+');
|
||||
match = reversedShortcuts.find((s) => s.key === codeCombo);
|
||||
}
|
||||
|
||||
if (match) {
|
||||
// Guard: If it's a single key (no modifiers) and we are in input, ignore it
|
||||
// Unless the shortcut explicitly says "allowInInput" (not implemented yet, assuming strictly no inputs for single keys)
|
||||
if (modifiers.length === 0 && isInput) {
|
||||
// allow native typing
|
||||
return;
|
||||
// Fallback: If no match found by 'key' (e.g. Shift+1 produces 'Alt+Shift+!'),
|
||||
// try matching by 'code' (e.g. 'Alt+Shift+Digit1')
|
||||
if (!match) {
|
||||
const codeCombo = [...modifiers, event.code].join('+');
|
||||
match = reversedShortcuts.find((s) => s.key === codeCombo);
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation(); // Stop bubbling
|
||||
if (match) {
|
||||
// Guard: If it's a single key (no modifiers) and we are in input, ignore it
|
||||
// Unless the shortcut explicitly says "allowInInput" (not implemented yet, assuming strictly no inputs for single keys)
|
||||
if (modifiers.length === 0 && isInput) {
|
||||
// allow native typing
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation(); // Stop bubbling
|
||||
lastShortcutTime = Date.now();
|
||||
match.action();
|
||||
|
||||
@@ -200,12 +221,11 @@
|
||||
}
|
||||
return;
|
||||
}
|
||||
} // Fin del bloque authenticated
|
||||
|
||||
// 4. GLOBAL NAV: Alt + Key (Legacy/Default behavior for global nav)
|
||||
// We keep this simple logic for now, or we could move GLOBAL_NAV to be registered in the store too?
|
||||
// Let's keep the hardcoded Alt+Key check for GLOBAL_NAV for simplicity/performance
|
||||
// essentially satisfying the "Central Config" requirement.
|
||||
if (altKey && modifiers.length === 1) {
|
||||
// Solo permitir si está autenticado
|
||||
if (authenticated && altKey && modifiers.length === 1) {
|
||||
// Exactly Alt + Key (no shift/ctrl)
|
||||
// Special: Alt+B -> Focus Search
|
||||
if (lowerKey === 'b') {
|
||||
|
||||
@@ -1,29 +1,4 @@
|
||||
import { obtenerAtajosCatalogoSimple } from '$lib/config/shortcuts/dashboard/general_catalogs/common/factory';
|
||||
import type { ShortcutDef } from '$lib/stores/shortcut-store';
|
||||
|
||||
export const obtenerAtajosListaEmpresa = (acciones: {
|
||||
manejarNuevo: () => void;
|
||||
manejarActualizar: () => void;
|
||||
manejarEditar: () => void;
|
||||
manejarEliminar: () => void;
|
||||
}): ShortcutDef[] => [
|
||||
{
|
||||
key: 'Alt+Shift+N',
|
||||
description: 'Nueva Empresa',
|
||||
action: acciones.manejarNuevo
|
||||
},
|
||||
{
|
||||
key: 'Alt+Shift+R',
|
||||
description: 'Actualizar Lista',
|
||||
action: acciones.manejarActualizar
|
||||
},
|
||||
{
|
||||
key: 'Alt+Shift+E',
|
||||
description: 'Editar Empresa',
|
||||
action: acciones.manejarEditar
|
||||
},
|
||||
{
|
||||
key: 'Alt+Shift+D',
|
||||
description: 'Eliminar Empresa',
|
||||
action: acciones.manejarEliminar
|
||||
}
|
||||
];
|
||||
export const obtenerAtajosListaEmpresa = (acciones: any): ShortcutDef[] => obtenerAtajosCatalogoSimple(acciones);
|
||||
|
||||
@@ -1,29 +1,4 @@
|
||||
import { obtenerAtajosCatalogoSimple } from '$lib/config/shortcuts/dashboard/general_catalogs/common/factory';
|
||||
import type { ShortcutDef } from '$lib/stores/shortcut-store';
|
||||
|
||||
export const obtenerAtajosListaDoda = (acciones: {
|
||||
manejarNuevo: () => void;
|
||||
manejarActualizar: () => void;
|
||||
manejarEditar: () => void;
|
||||
manejarEliminar: () => void;
|
||||
}): ShortcutDef[] => [
|
||||
{
|
||||
key: 'Alt+Shift+N',
|
||||
description: 'Nuevo DODA',
|
||||
action: acciones.manejarNuevo
|
||||
},
|
||||
{
|
||||
key: 'Alt+Shift+R',
|
||||
description: 'Actualizar Lista',
|
||||
action: acciones.manejarActualizar
|
||||
},
|
||||
{
|
||||
key: 'Alt+Shift+E',
|
||||
description: 'Editar DODA',
|
||||
action: acciones.manejarEditar
|
||||
},
|
||||
{
|
||||
key: 'Alt+Shift+D',
|
||||
description: 'Eliminar DODA',
|
||||
action: acciones.manejarEliminar
|
||||
}
|
||||
];
|
||||
export const obtenerAtajosListaDoda = (acciones: any): ShortcutDef[] => obtenerAtajosCatalogoSimple(acciones);
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
import { obtenerAtajosReferenceDataSimple } from '$lib/config/shortcuts/dashboard/reference_data/common/factory';
|
||||
import type { ShortcutDef } from '$lib/stores/shortcut-store';
|
||||
|
||||
export const obtenerAtajosLista = (acciones: any): ShortcutDef[] => obtenerAtajosReferenceDataSimple(acciones);
|
||||
@@ -0,0 +1,22 @@
|
||||
import type { ShortcutDef } from '$lib/stores/shortcut-store';
|
||||
|
||||
/**
|
||||
* Reusable shortcuts for simple reference data catalogs.
|
||||
*/
|
||||
export const obtenerAtajosReferenceDataSimple = (acciones: {
|
||||
manejarNuevo: () => void;
|
||||
manejarActualizar: () => void;
|
||||
}): ShortcutDef[] => {
|
||||
return [
|
||||
{
|
||||
key: 'Alt+Shift+N',
|
||||
description: 'Nuevo Registro',
|
||||
action: acciones.manejarNuevo
|
||||
},
|
||||
{
|
||||
key: 'Alt+Shift+R',
|
||||
description: 'Actualizar Lista',
|
||||
action: acciones.manejarActualizar
|
||||
}
|
||||
];
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
import { obtenerAtajosReferenceDataSimple } from '$lib/config/shortcuts/dashboard/reference_data/common/factory';
|
||||
import type { ShortcutDef } from '$lib/stores/shortcut-store';
|
||||
|
||||
export const obtenerAtajosLista = (acciones: any): ShortcutDef[] => obtenerAtajosReferenceDataSimple(acciones);
|
||||
@@ -0,0 +1,4 @@
|
||||
import { obtenerAtajosReferenceDataSimple } from '$lib/config/shortcuts/dashboard/reference_data/common/factory';
|
||||
import type { ShortcutDef } from '$lib/stores/shortcut-store';
|
||||
|
||||
export const obtenerAtajosLista = (acciones: any): ShortcutDef[] => obtenerAtajosReferenceDataSimple(acciones);
|
||||
@@ -0,0 +1,4 @@
|
||||
import { obtenerAtajosReferenceDataSimple } from '$lib/config/shortcuts/dashboard/reference_data/common/factory';
|
||||
import type { ShortcutDef } from '$lib/stores/shortcut-store';
|
||||
|
||||
export const obtenerAtajosLista = (acciones: any): ShortcutDef[] => obtenerAtajosReferenceDataSimple(acciones);
|
||||
@@ -0,0 +1,4 @@
|
||||
import { obtenerAtajosReferenceDataSimple } from '$lib/config/shortcuts/dashboard/reference_data/common/factory';
|
||||
import type { ShortcutDef } from '$lib/stores/shortcut-store';
|
||||
|
||||
export const obtenerAtajosLista = (acciones: any): ShortcutDef[] => obtenerAtajosReferenceDataSimple(acciones);
|
||||
@@ -0,0 +1,4 @@
|
||||
import { obtenerAtajosReferenceDataSimple } from '$lib/config/shortcuts/dashboard/reference_data/common/factory';
|
||||
import type { ShortcutDef } from '$lib/stores/shortcut-store';
|
||||
|
||||
export const obtenerAtajosLista = (acciones: any): ShortcutDef[] => obtenerAtajosReferenceDataSimple(acciones);
|
||||
@@ -0,0 +1,4 @@
|
||||
import { obtenerAtajosReferenceDataSimple } from '$lib/config/shortcuts/dashboard/reference_data/common/factory';
|
||||
import type { ShortcutDef } from '$lib/stores/shortcut-store';
|
||||
|
||||
export const obtenerAtajosLista = (acciones: any): ShortcutDef[] => obtenerAtajosReferenceDataSimple(acciones);
|
||||
@@ -0,0 +1,4 @@
|
||||
import { obtenerAtajosReferenceDataSimple } from '$lib/config/shortcuts/dashboard/reference_data/common/factory';
|
||||
import type { ShortcutDef } from '$lib/stores/shortcut-store';
|
||||
|
||||
export const obtenerAtajosLista = (acciones: any): ShortcutDef[] => obtenerAtajosReferenceDataSimple(acciones);
|
||||
@@ -0,0 +1,4 @@
|
||||
import { obtenerAtajosReferenceDataSimple } from '$lib/config/shortcuts/dashboard/reference_data/common/factory';
|
||||
import type { ShortcutDef } from '$lib/stores/shortcut-store';
|
||||
|
||||
export const obtenerAtajosLista = (acciones: any): ShortcutDef[] => obtenerAtajosReferenceDataSimple(acciones);
|
||||
@@ -0,0 +1,4 @@
|
||||
import { obtenerAtajosReferenceDataSimple } from '$lib/config/shortcuts/dashboard/reference_data/common/factory';
|
||||
import type { ShortcutDef } from '$lib/stores/shortcut-store';
|
||||
|
||||
export const obtenerAtajosLista = (acciones: any): ShortcutDef[] => obtenerAtajosReferenceDataSimple(acciones);
|
||||
@@ -0,0 +1,4 @@
|
||||
import { obtenerAtajosReferenceDataSimple } from '$lib/config/shortcuts/dashboard/reference_data/common/factory';
|
||||
import type { ShortcutDef } from '$lib/stores/shortcut-store';
|
||||
|
||||
export const obtenerAtajosLista = (acciones: any): ShortcutDef[] => obtenerAtajosReferenceDataSimple(acciones);
|
||||
@@ -0,0 +1,4 @@
|
||||
import { obtenerAtajosReferenceDataSimple } from '$lib/config/shortcuts/dashboard/reference_data/common/factory';
|
||||
import type { ShortcutDef } from '$lib/stores/shortcut-store';
|
||||
|
||||
export const obtenerAtajosLista = (acciones: any): ShortcutDef[] => obtenerAtajosReferenceDataSimple(acciones);
|
||||
@@ -0,0 +1,4 @@
|
||||
import { obtenerAtajosReferenceDataSimple } from '$lib/config/shortcuts/dashboard/reference_data/common/factory';
|
||||
import type { ShortcutDef } from '$lib/stores/shortcut-store';
|
||||
|
||||
export const obtenerAtajosLista = (acciones: any): ShortcutDef[] => obtenerAtajosReferenceDataSimple(acciones);
|
||||
@@ -0,0 +1,4 @@
|
||||
import { obtenerAtajosReferenceDataSimple } from '$lib/config/shortcuts/dashboard/reference_data/common/factory';
|
||||
import type { ShortcutDef } from '$lib/stores/shortcut-store';
|
||||
|
||||
export const obtenerAtajosLista = (acciones: any): ShortcutDef[] => obtenerAtajosReferenceDataSimple(acciones);
|
||||
@@ -0,0 +1,4 @@
|
||||
import { obtenerAtajosReferenceDataSimple } from '$lib/config/shortcuts/dashboard/reference_data/common/factory';
|
||||
import type { ShortcutDef } from '$lib/stores/shortcut-store';
|
||||
|
||||
export const obtenerAtajosLista = (acciones: any): ShortcutDef[] => obtenerAtajosReferenceDataSimple(acciones);
|
||||
@@ -0,0 +1,4 @@
|
||||
import { obtenerAtajosReferenceDataSimple } from '$lib/config/shortcuts/dashboard/reference_data/common/factory';
|
||||
import type { ShortcutDef } from '$lib/stores/shortcut-store';
|
||||
|
||||
export const obtenerAtajosLista = (acciones: any): ShortcutDef[] => obtenerAtajosReferenceDataSimple(acciones);
|
||||
@@ -0,0 +1,4 @@
|
||||
import { obtenerAtajosReferenceDataSimple } from '$lib/config/shortcuts/dashboard/reference_data/common/factory';
|
||||
import type { ShortcutDef } from '$lib/stores/shortcut-store';
|
||||
|
||||
export const obtenerAtajosLista = (acciones: any): ShortcutDef[] => obtenerAtajosReferenceDataSimple(acciones);
|
||||
@@ -1,14 +1,30 @@
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
import { shortcutStore, type ShortcutDef } from '$lib/stores/shortcut-store';
|
||||
import { page } from '$app/stores';
|
||||
import { get } from 'svelte/store';
|
||||
import { browser } from '$app/environment';
|
||||
|
||||
/**
|
||||
* Hook to register shortcuts for a component lifecycle.
|
||||
* Only works when user is authenticated (inside /dashboard routes).
|
||||
* @param context Name of the context (e.g., 'Goods List')
|
||||
* @param shortcuts Array of shortcut definitions
|
||||
*/
|
||||
export function useShortcuts(context: string, shortcuts: ShortcutDef[]) {
|
||||
onMount(() => {
|
||||
shortcutStore.register(context, shortcuts);
|
||||
// Solo registrar atajos si estamos en una ruta autenticada
|
||||
if (!browser) return;
|
||||
|
||||
const currentPath = get(page)?.url?.pathname || '';
|
||||
const isAuthenticatedRoute = currentPath.startsWith('/dashboard');
|
||||
|
||||
// Verificar también que haya un token de acceso
|
||||
const hasAccessToken = document.cookie.includes('access_token=') ||
|
||||
localStorage.getItem('access_token');
|
||||
|
||||
if (isAuthenticatedRoute && hasAccessToken) {
|
||||
shortcutStore.register(context, shortcuts);
|
||||
}
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
|
||||
@@ -20,14 +20,7 @@
|
||||
'Lista Empresas',
|
||||
obtenerAtajosListaEmpresa({
|
||||
manejarNuevo: () => goto('/dashboard/general_catalogs/company_information/edit'),
|
||||
manejarActualizar: () => goto($page.url, { invalidateAll: true }),
|
||||
manejarEditar: () => {
|
||||
// Placeholder: Requiere selección de empresa
|
||||
console.log('Editar empresa seleccionado');
|
||||
},
|
||||
manejarEliminar: () => {
|
||||
console.log('Eliminar empresa seleccionado');
|
||||
}
|
||||
manejarActualizar: () => goto($page.url, { invalidateAll: true })
|
||||
})
|
||||
);
|
||||
let dialogOpen = $state(false);
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
obtenerAtajosListaConceptosAA({
|
||||
manejarNuevo: () => (dialogOpen = true),
|
||||
manejarActualizar: () => goto($page.url, { invalidateAll: true }),
|
||||
manejarEditar: () => console.log('Editar concepto AA'),
|
||||
manejarEliminar: () => console.log('Eliminar concepto AA')
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@@ -29,31 +29,12 @@
|
||||
goto('/dashboard/general_catalogs/doda/edit');
|
||||
}
|
||||
|
||||
function handleEditSelected() {
|
||||
if (selectedId) {
|
||||
goto(`/dashboard/general_catalogs/doda/edit/${selectedId}`);
|
||||
} else {
|
||||
console.log('Seleccione un registro para editar (Alt+Shift+E)');
|
||||
}
|
||||
}
|
||||
|
||||
function handleDelete() {
|
||||
if (selectedId) {
|
||||
// Implement delete logic or dialog
|
||||
console.log('Eliminar no implementado en esta vista. Use el menú de acciones.');
|
||||
} else {
|
||||
console.log('Seleccione un registro para eliminar (Alt+Shift+D)');
|
||||
}
|
||||
}
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Lista DODA',
|
||||
obtenerAtajosListaDoda({
|
||||
manejarNuevo: handleCreateClick,
|
||||
manejarActualizar: handleSuccess,
|
||||
manejarEditar: handleEditSelected,
|
||||
manejarEliminar: handleDelete
|
||||
manejarActualizar: handleSuccess
|
||||
})
|
||||
);
|
||||
|
||||
@@ -75,6 +56,10 @@
|
||||
goto(url, { invalidateAll: true });
|
||||
selectedId = null;
|
||||
}
|
||||
|
||||
function handleRowClick(doda: Doda) {
|
||||
selectedId = doda.id;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-4 p-4">
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
obtenerAtajosListaInpc({
|
||||
manejarNuevo: () => (createDialogOpen = true),
|
||||
manejarActualizar: () => goto($page.url, { invalidateAll: true }),
|
||||
manejarEditar: () => console.log('Editar INPC'),
|
||||
manejarEliminar: () => console.log('Eliminar INPC')
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
obtenerAtajosListaLeyendas({
|
||||
manejarNuevo: () => (dialogOpen = true),
|
||||
manejarActualizar: () => goto($page.url, { invalidateAll: true }),
|
||||
manejarEditar: () => console.log('Editar leyenda'),
|
||||
manejarEliminar: () => console.log('Eliminar leyenda')
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
obtenerAtajosListaMonedas({
|
||||
manejarNuevo: () => (dialogOpen = true),
|
||||
manejarActualizar: () => goto($page.url, { invalidateAll: true }),
|
||||
manejarEditar: () => console.log('Editar moneda'),
|
||||
manejarEliminar: () => console.log('Eliminar moneda')
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@@ -28,8 +28,6 @@
|
||||
obtenerAtajosListaBultos({
|
||||
manejarNuevo: () => (createDialogOpen = true),
|
||||
manejarActualizar: handleSuccess,
|
||||
manejarEditar: () => console.log('Editar bulto'),
|
||||
manejarEliminar: () => console.log('Eliminar bulto')
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
obtenerAtajosListaPuertos({
|
||||
manejarNuevo: () => (createDialogOpen = true),
|
||||
manejarActualizar: () => goto($page.url, { invalidateAll: true }),
|
||||
manejarEditar: () => console.log('Editar puerto'),
|
||||
manejarEliminar: () => console.log('Eliminar puerto')
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
obtenerAtajosListaPrevalidadores({
|
||||
manejarNuevo: () => (dialogOpen = true),
|
||||
manejarActualizar: () => goto($page.url, { invalidateAll: true }),
|
||||
manejarEditar: () => console.log('Editar prevalidador'),
|
||||
manejarEliminar: () => console.log('Eliminar prevalidador')
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
obtenerAtajosListaFirmas({
|
||||
manejarNuevo: () => (dialogOpen = true),
|
||||
manejarActualizar: () => goto($page.url, { invalidateAll: true }),
|
||||
manejarEditar: () => console.log('Editar firma'),
|
||||
manejarEliminar: () => console.log('Eliminar firma')
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
obtenerAtajosListaUnidadesACE({
|
||||
manejarNuevo: () => (createDialogOpen = true),
|
||||
manejarActualizar: () => goto($page.url, { invalidateAll: true }),
|
||||
manejarEditar: () => console.log('Editar unidad ACE'),
|
||||
manejarEliminar: () => console.log('Eliminar unidad ACE')
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
obtenerAtajosListaUnidadesAmericanas({
|
||||
manejarNuevo: () => (createDialogOpen = true),
|
||||
manejarActualizar: () => goto($page.url, { invalidateAll: true }),
|
||||
manejarEditar: () => console.log('Editar unidad americana'),
|
||||
manejarEliminar: () => console.log('Eliminar unidad americana')
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
obtenerAtajosListaUnidadesAduanas({
|
||||
manejarNuevo: () => (createDialogOpen = true),
|
||||
manejarActualizar: () => goto($page.url, { invalidateAll: true }),
|
||||
manejarEditar: () => console.log('Editar unidad aduana'),
|
||||
manejarEliminar: () => console.log('Eliminar unidad aduana')
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
obtenerAtajosListaUnidadesGeneral({
|
||||
manejarNuevo: () => (createDialogOpen = true),
|
||||
manejarActualizar: () => goto($page.url, { invalidateAll: true }),
|
||||
manejarEditar: () => console.log('Editar unidad general'),
|
||||
manejarEliminar: () => console.log('Eliminar unidad general')
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
obtenerAtajosListaUnidadesOMA({
|
||||
manejarNuevo: () => (createDialogOpen = true),
|
||||
manejarActualizar: () => goto($page.url, { invalidateAll: true }),
|
||||
manejarEditar: () => console.log('Editar unidad OMA'),
|
||||
manejarEliminar: () => console.log('Eliminar unidad OMA')
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
import * as Card from '$lib/components/ui/card';
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import type { PageData } from './$types';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosLista } from '$lib/config/shortcuts/dashboard/reference_data/code_pedimento_regimens/list';
|
||||
import { browser } from '$app/environment';
|
||||
import { Plus, RefreshCw } from 'lucide-svelte';
|
||||
|
||||
@@ -16,6 +18,15 @@
|
||||
// Estado para el diálogo de crear
|
||||
let showCreateDialog = $state(false);
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Lista Códigos',
|
||||
obtenerAtajosLista({
|
||||
manejarNuevo: () => (showCreateDialog = true),
|
||||
manejarActualizar: handleRefresh
|
||||
})
|
||||
);
|
||||
|
||||
// Sincronizar token de cookies a localStorage al montar el componente
|
||||
onMount(() => {
|
||||
if (browser) {
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
import * as Card from '$lib/components/ui/card';
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import type { PageData } from './$types';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosLista } from '$lib/config/shortcuts/dashboard/reference_data/containers/list';
|
||||
import { browser } from '$app/environment';
|
||||
import { Plus, RefreshCw } from 'lucide-svelte';
|
||||
|
||||
@@ -16,6 +18,15 @@
|
||||
// Estado para el diálogo de crear
|
||||
let showCreateDialog = $state(false);
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Lista Contenedores',
|
||||
obtenerAtajosLista({
|
||||
manejarNuevo: () => (showCreateDialog = true),
|
||||
manejarActualizar: handleRefresh
|
||||
})
|
||||
);
|
||||
|
||||
// Sincronizar token de cookies a localStorage al montar el componente
|
||||
onMount(() => {
|
||||
if (browser) {
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import { Plus, RefreshCw } from 'lucide-svelte';
|
||||
import type { PageData } from './$types';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosLista } from '$lib/config/shortcuts/dashboard/reference_data/countries/list';
|
||||
import { browser } from '$app/environment';
|
||||
|
||||
// Los datos iniciales vienen del servidor
|
||||
@@ -15,6 +17,15 @@
|
||||
// Estado para el diálogo de crear
|
||||
let showCreateDialog = $state(false);
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Lista Países',
|
||||
obtenerAtajosLista({
|
||||
manejarNuevo: () => (showCreateDialog = true),
|
||||
manejarActualizar: handleRefresh
|
||||
})
|
||||
);
|
||||
|
||||
// Sincronizar token de cookies a localStorage al montar el componente
|
||||
onMount(() => {
|
||||
if (browser) {
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import { Plus, RefreshCw } from 'lucide-svelte';
|
||||
import type { PageData } from './$types';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosLista } from '$lib/config/shortcuts/dashboard/reference_data/currency_types/list';
|
||||
import { browser } from '$app/environment';
|
||||
|
||||
// Los datos iniciales vienen del servidor
|
||||
@@ -15,6 +17,15 @@
|
||||
// Estado para el diálogo de crear
|
||||
let showCreateDialog = $state(false);
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Lista Tipos de Moneda',
|
||||
obtenerAtajosLista({
|
||||
manejarNuevo: () => (showCreateDialog = true),
|
||||
manejarActualizar: handleRefresh
|
||||
})
|
||||
);
|
||||
|
||||
// Sincronizar token de cookies a localStorage al montar el componente
|
||||
onMount(() => {
|
||||
if (browser) {
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
import CreateEditDialog from '$lib/components/dashboard/reference_data/customs_warehouses/create-edit-dialog.svelte';
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import type { PageData } from './$types';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosLista } from '$lib/config/shortcuts/dashboard/reference_data/customs_warehouses/list';
|
||||
import { browser } from '$app/environment';
|
||||
import { Plus, RefreshCw } from 'lucide-svelte';
|
||||
|
||||
@@ -15,6 +17,15 @@
|
||||
// Estado para el diálogo de crear
|
||||
let showCreateDialog = $state(false);
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Lista Almacenes Aduanales',
|
||||
obtenerAtajosLista({
|
||||
manejarNuevo: () => (showCreateDialog = true),
|
||||
manejarActualizar: handleRefresh
|
||||
})
|
||||
);
|
||||
|
||||
// Sincronizar token de cookies a localStorage al montar el componente
|
||||
onMount(() => {
|
||||
if (browser) {
|
||||
|
||||
@@ -8,11 +8,22 @@
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import { Input } from '$lib/components/ui/input';
|
||||
import { Plus } from 'lucide-svelte';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosLista } from '$lib/config/shortcuts/dashboard/reference_data/incoterms/list';
|
||||
import type { PageData } from './$types';
|
||||
|
||||
let { data }: { data: PageData } = $props();
|
||||
|
||||
let createDialogOpen = $state(false);
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Lista Incoterms',
|
||||
obtenerAtajosLista({
|
||||
manejarNuevo: () => (createDialogOpen = true),
|
||||
manejarActualizar: handleSuccess
|
||||
})
|
||||
);
|
||||
|
||||
// Filtros
|
||||
let searchCode = $state($page.url.searchParams.get('code') || '');
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import { Plus, RefreshCw } from 'lucide-svelte';
|
||||
import type { PageData } from './$types';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosLista } from '$lib/config/shortcuts/dashboard/reference_data/invoice_types/list';
|
||||
import { browser } from '$app/environment';
|
||||
|
||||
// Los datos iniciales vienen del servidor
|
||||
@@ -15,6 +17,15 @@
|
||||
// Estado para el diálogo de crear
|
||||
let showCreateDialog = $state(false);
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Lista Tipos de Factura',
|
||||
obtenerAtajosLista({
|
||||
manejarNuevo: () => (showCreateDialog = true),
|
||||
manejarActualizar: handleRefresh
|
||||
})
|
||||
);
|
||||
|
||||
// Sincronizar token de cookies a localStorage al montar el componente
|
||||
onMount(() => {
|
||||
if (browser) {
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
import * as Card from '$lib/components/ui/card';
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import type { PageData } from './$types';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosLista } from '$lib/config/shortcuts/dashboard/reference_data/material_types/list';
|
||||
import { browser } from '$app/environment';
|
||||
import { Plus, RefreshCw } from 'lucide-svelte';
|
||||
|
||||
@@ -16,6 +18,15 @@
|
||||
// Estado para el diálogo de crear
|
||||
let showCreateDialog = $state(false);
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Lista Tipos de Material',
|
||||
obtenerAtajosLista({
|
||||
manejarNuevo: () => (showCreateDialog = true),
|
||||
manejarActualizar: handleRefresh
|
||||
})
|
||||
);
|
||||
|
||||
// Sincronizar token de cookies a localStorage al montar el componente
|
||||
onMount(() => {
|
||||
if (browser) {
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import { Plus, RefreshCw } from 'lucide-svelte';
|
||||
import type { PageData } from './$types';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosLista } from '$lib/config/shortcuts/dashboard/reference_data/sectors/list';
|
||||
import { browser } from '$app/environment';
|
||||
|
||||
// Los datos iniciales vienen del servidor
|
||||
@@ -16,6 +18,15 @@
|
||||
// Estado para el diálogo de crear
|
||||
let showCreateDialog = $state(false);
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Lista Sectores',
|
||||
obtenerAtajosLista({
|
||||
manejarNuevo: () => (showCreateDialog = true),
|
||||
manejarActualizar: handleRefresh
|
||||
})
|
||||
);
|
||||
|
||||
// Sincronizar token de cookies a localStorage al montar el componente
|
||||
onMount(() => {
|
||||
if (browser) {
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
import * as Card from '$lib/components/ui/card';
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import type { PageData } from './$types';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosLista } from '$lib/config/shortcuts/dashboard/reference_data/states/list';
|
||||
import { browser } from '$app/environment';
|
||||
import { Plus, RefreshCw } from 'lucide-svelte';
|
||||
|
||||
@@ -16,6 +18,15 @@
|
||||
// Estado para el diálogo de crear
|
||||
let showCreateDialog = $state(false);
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Lista Estados',
|
||||
obtenerAtajosLista({
|
||||
manejarNuevo: () => (showCreateDialog = true),
|
||||
manejarActualizar: handleRefresh
|
||||
})
|
||||
);
|
||||
|
||||
// Sincronizar token de cookies a localStorage al montar el componente
|
||||
onMount(() => {
|
||||
if (browser) {
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
import * as Card from '$lib/components/ui/card';
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import type { PageData } from './$types';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosLista } from '$lib/config/shortcuts/dashboard/reference_data/transport_modes/list';
|
||||
import { browser } from '$app/environment';
|
||||
import { Plus, RefreshCw } from 'lucide-svelte';
|
||||
|
||||
@@ -16,6 +18,15 @@
|
||||
// Estado para el diálogo de crear
|
||||
let showCreateDialog = $state(false);
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Lista Modos de Transporte',
|
||||
obtenerAtajosLista({
|
||||
manejarNuevo: () => (showCreateDialog = true),
|
||||
manejarActualizar: handleRefresh
|
||||
})
|
||||
);
|
||||
|
||||
// Sincronizar token de cookies a localStorage al montar el componente
|
||||
onMount(() => {
|
||||
if (browser) {
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import { Plus, RefreshCw } from 'lucide-svelte';
|
||||
import type { PageData } from './$types';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosLista } from '$lib/config/shortcuts/dashboard/reference_data/transport_types/list';
|
||||
import { browser } from '$app/environment';
|
||||
|
||||
// Los datos iniciales vienen del servidor
|
||||
@@ -16,6 +18,15 @@
|
||||
// Estado para el diálogo de crear
|
||||
let showCreateDialog = $state(false);
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Lista Tipos de Transporte',
|
||||
obtenerAtajosLista({
|
||||
manejarNuevo: () => (showCreateDialog = true),
|
||||
manejarActualizar: handleRefresh
|
||||
})
|
||||
);
|
||||
|
||||
// Sincronizar token de cookies a localStorage al montar el componente
|
||||
onMount(() => {
|
||||
if (browser) {
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
import CreateEditDialog from '$lib/components/dashboard/reference_data/valuation_methods/create-edit-dialog.svelte';
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import { Plus, RefreshCw } from 'lucide-svelte';
|
||||
import { useShortcuts } from '$lib/hooks/use-shortcuts';
|
||||
import { obtenerAtajosLista } from '$lib/config/shortcuts/dashboard/reference_data/valuation_methods/list';
|
||||
import type { PageData } from './$types';
|
||||
import { browser } from '$app/environment';
|
||||
|
||||
@@ -15,6 +17,15 @@
|
||||
// Estado para el diálogo de crear
|
||||
let showCreateDialog = $state(false);
|
||||
|
||||
// Atajos
|
||||
useShortcuts(
|
||||
'Lista Métodos de Valoración',
|
||||
obtenerAtajosLista({
|
||||
manejarNuevo: () => (showCreateDialog = true),
|
||||
manejarActualizar: handleRefresh
|
||||
})
|
||||
);
|
||||
|
||||
// Sincronizar token de cookies a localStorage al montar el componente
|
||||
onMount(() => {
|
||||
if (browser) {
|
||||
|
||||
Reference in New Issue
Block a user