funcionalidad de alta repuesto terminada

This commit is contained in:
fede committed 2026-07-01 01:00:12 -03:00
1 parent d0500dc764
commit 352973d2f5
15 files changed
+218 -38

No files matched your search

@@ -0,0 +1,24 @@
import { API_URL } from '$lib/env';
import type { CrearRepuestoDto } from '../../../types';
import { getToken } from '../token';
export async function crearRepuesto(repuesto: CrearRepuestoDto) {
try {
const req = await fetch(`${API_URL}/repuestos/`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${getToken()}`
},
body: JSON.stringify(repuesto)
});
if (req.ok) {
return 'Ok';
}
const data = await req.json();
return data.error;
} catch {
return 'no se puso alcanzar el servidor';
}
}
@@ -4,7 +4,8 @@ import { getToken } from '../token';
export async function obtenerRepuestos(fetch2?: Function) {
const fetchfn = fetch2 ? fetch2 : fetch;
try {
const req = await fetchfn(`${API_URL}/repuestos`, {
const path = `${API_URL}/repuestos/`;
const req = await fetchfn(path, {
method: 'GET',
headers: {
'Content-Type': 'application/json',