Private
Public Access
18 lines
595 B
TypeScript
18 lines
595 B
TypeScript
import { API_URL } from '../env';
|
|
import { getToken } from './token';
|
|
|
|
export async function agregarSubGrupo(grupoId: number, childGroupId: number): Promise<void> {
|
|
const response = await fetch(`${API_URL}/grupos/${grupoId}/subgrupos`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
Authorization: `Bearer ${getToken()}`
|
|
},
|
|
body: JSON.stringify({ child_group_id: childGroupId })
|
|
});
|
|
if (!response.ok) {
|
|
const error = await response.json().catch(() => ({ message: 'Error desconocido' }));
|
|
throw new Error(error.message || 'Error al agregar subgrupo');
|
|
}
|
|
}
|