feat:añadido quitar y asignar grupos a un usuario

This commit is contained in:
fede committed 2026-06-07 19:02:36 -03:00
1 parent 38e040354a
commit 22b2b7d2d0
14 files changed
+486 -9

No files matched your search

@@ -0,0 +1,30 @@
import { invalidate } from '$app/navigation';
import { API_URL } from '$lib/env';
import { getToken } from './token';
export async function quitarGrupoAUsuario(
dto: { grupo_id: number; usuario_id: number },
callback: Function
) {
if (!dto.grupo_id || !dto.usuario_id) return 'Faltan cargar datos';
try {
const req = await fetch(`${API_URL}/usuarios/grupos/quitar`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${getToken()}`
},
body: JSON.stringify(dto)
});
if (!req.ok) {
return 'Error';
}
callback();
return 'Ok';
} catch (e) {
console.log(e);
return 'No se pudo conectar con el servidor';
}
}