Nuevos cambios en el servidor

This commit is contained in:
2026-01-27 13:22:13 -07:00
parent 6215fc40a7
commit 7bb3d1a0ac
33 changed files with 8737 additions and 169 deletions

3974
frontend-internal/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -28,7 +28,7 @@
"postcss": "^8.4.24",
"prettier": "^2.8.0",
"prettier-plugin-svelte": "^2.10.1",
"svelte": "^4.0.5",
"svelte": "^4.2.20",
"svelte-check": "^3.4.3",
"tailwindcss": "^3.3.0",
"tslib": "^2.4.1",
@@ -37,13 +37,13 @@
"vitest": "^0.34.0"
},
"dependencies": {
"@heroicons/react": "^2.0.18",
"@tailwindcss/forms": "^0.5.4",
"@tailwindcss/typography": "^0.5.9",
"@heroicons/react": "^2.0.18",
"heroicons": "^2.0.18",
"zod": "^3.22.2",
"date-fns": "^2.30.0",
"chart.js": "^4.3.0",
"chartjs-adapter-date-fns": "^3.0.0"
"chartjs-adapter-date-fns": "^3.0.0",
"date-fns": "^2.30.0",
"heroicons": "^2.0.18",
"zod": "^3.22.2"
}
}
}

View File

@@ -43,11 +43,15 @@
async function handleSubmit() {
try {
if (editingTenant) {
await api.put(`/tenants/${editingTenant.id}`, formData);
toast.success('Cliente actualizado');
// Asegurarse de enviar el campo "status" correctamente
const updatedData = { ...formData, status: formData.is_active ? 'active' : 'inactive' };
await api.put(`/tenants/${editingTenant.id}`, updatedData);
toast.success(`Cliente ${formData.is_active ? 'activado' : 'desactivado'} correctamente`);
} else {
await api.post('/tenants/', formData);
toast.success('Cliente creado');
// Asegurarse de enviar el campo "status" al crear un cliente
const newData = { ...formData, status: formData.is_active ? 'active' : 'inactive' };
await api.post('/tenants/', newData);
toast.success('Cliente creado correctamente');
}
showModal = false;
loadTenants();
@@ -152,6 +156,11 @@
<button type="button" on:click={() => showModal = false} class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 sm:mt-0 sm:col-start-1 sm:text-sm">
Cancelar
</button>
{#if editingTenant}
<button type="button" on:click={async () => { await api.delete(`/tenants/${editingTenant.id}`); toast.success('Cliente eliminado'); showModal = false; loadTenants(); }} class="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-red-600 text-base font-medium text-white hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 sm:col-start-1 sm:text-sm">
Eliminar
</button>
{/if}
</div>
</form>
</Modal>

View File

@@ -0,0 +1,53 @@
<script lang="ts">
import { onMount } from 'svelte';
import { api } from '$lib/api'; // ajusta el path si es distinto
let tickets: any[] = [];
let loading = true;
let error: string | null = null;
onMount(async () => {
try {
loading = true;
tickets = await api.get('/tickets');
} catch (err: any) {
console.error(err);
error = err.message ?? 'Error cargando tickets';
} finally {
loading = false;
}
});
</script>
<h1>Tickets</h1>
{#if loading}
<p>Cargando tickets...</p>
{:else if error}
<p style="color: red;">{error}</p>
{:else if tickets.length === 0}
<p>No hay tickets</p>
{:else}
<table border="1" cellpadding="8">
<thead>
<tr>
<th>Número</th>
<th>Asunto</th>
<th>Estado</th>
<th>Prioridad</th>
<th>Creado</th>
</tr>
</thead>
<tbody>
{#each tickets as ticket}
<tr>
<td>{ticket.ticket_number}</td>
<td>{ticket.subject}</td>
<td>{ticket.status}</td>
<td>{ticket.priority}</td>
<td>{new Date(ticket.created_at).toLocaleString()}</td>
</tr>
{/each}
</tbody>
</table>
{/if}