fix/conceptos-catalogo-general

This commit is contained in:
2026-04-22 07:44:07 -06:00
parent 41e262b577
commit ff1ff30e23
7 changed files with 66 additions and 10 deletions

View File

@@ -4,6 +4,7 @@ import type { ApiResponse } from '$lib/api';
export interface ClassificationConcept {
id: number;
classification: string;
description?: string;
tenant_id: number;
company_id: number;
created_at: string;
@@ -12,6 +13,7 @@ export interface ClassificationConcept {
export interface ClassificationConceptCreate {
classification: string;
description?: string;
}
export interface ClassificationConceptUpdate extends Partial<ClassificationConceptCreate> {}

View File

@@ -30,7 +30,8 @@
// 👇 3. Estado limpio: Solo lo que existe en la BD
let formData = $state({
classification: ''
classification: '',
description: ''
});
let loading = $state(false);
@@ -38,14 +39,18 @@
// Cargar datos al abrir
$effect(() => {
if (item) {
formData = {
classification: item.classification || ''
};
} else {
formData = {
classification: ''
};
if (open) {
if (item) {
formData = {
classification: item.classification || '',
description: item.description || ''
};
} else {
formData = {
classification: '',
description: ''
};
}
}
});
@@ -63,7 +68,8 @@
throw new Error('El nombre de la clasificación es requerido');
const dataToSend = {
classification: formData.classification.trim()
classification: formData.classification.trim(),
description: formData.description ? formData.description.trim() : null
};
// 👇 5. Llamar a la API pasando el companyId
@@ -112,6 +118,15 @@
maxlength={30}
/>
</div>
<div class="grid gap-2">
<Label for="description">Descripción</Label>
<Input
id="description"
bind:value={formData.description}
placeholder="Ej: Descripción general"
maxlength={255}
/>
</div>
</div>
<Dialog.Footer>