commit parcial con la parte del front del crud almacenes

Signed-off-by: fede <federico.nicolas.polidoro@gmail.com>
This commit is contained in:
fede committed 2026-11-30 02:02:21 -03:00
1 parent ea009e276f
commit 6f375cee45
13 files changed
+565 -4

No files matched your search

@@ -0,0 +1,21 @@
import { API_URL } from '$lib/env';
import { getToken } from '../token';
import type { AlmacenDto } from './crearAlmacen';
export async function actualizarAlmacen(id: number, dto: AlmacenDto) {
try {
const req = await fetch(`${API_URL}/almacenes/${id}`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${getToken()}`
},
body: JSON.stringify(dto)
});
if (req.ok) return 'ok';
const data = await req.json().catch(() => ({}));
return data.error ?? 'No se pudo actualizar el almacén';
} catch {
return 'No se pudo alcanzar el servidor';
}
}