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'; } }