-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
179 changed files
with
5,183 additions
and
9,156 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import Cookies from 'js-cookie'; | ||
|
||
export const solicitarBajaAlumno = async (dni: number, motivo: string) => { | ||
try { | ||
const response = await fetch(`http://localhost:8000/api/alumnos/${dni}/solicitar-baja/`, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Authorization: `Bearer ${Cookies.get('tokennn')}`, | ||
}, | ||
body: JSON.stringify({ | ||
motivo: motivo, | ||
}), | ||
}); | ||
|
||
if (response.ok) { | ||
console.log('Baja solicitada correctamente'); | ||
return true; | ||
} else { | ||
console.error('Error al solicitar la baja'); | ||
return false; | ||
} | ||
} catch (error) { | ||
console.error('Error al solicitar la baja:', error); | ||
return false; | ||
} | ||
}; | ||
|
||
export const verficarBajaAlumno = async (dni: number) => { | ||
try { | ||
const response = await fetch(`http://localhost:8000/api/alumnos/${dni}/puede-solicitar-baja/`, { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Authorization: `Bearer ${Cookies.get('tokennn')}`, | ||
}, | ||
}); | ||
|
||
if (response.ok) { | ||
const data = await response.json(); | ||
return data.puede_solicitar; | ||
} else { | ||
console.error('Error al verificar si el alumno puede solicitar la baja'); | ||
return false; | ||
} | ||
} catch (error) { | ||
console.error('Error al verificar si el alumno puede solicitar la baja:', error); | ||
return false; | ||
} | ||
}; | ||
|
||
export const bajasSolicitadas = async () => { | ||
try { | ||
const response = await fetch(`http://localhost:8000/api/alumnos/bajas_solicitadas/`, { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Authorization: `Bearer ${Cookies.get('tokennn')}`, | ||
}, | ||
}); | ||
|
||
if (response.ok) { | ||
const data = await response.json(); | ||
return data; | ||
} else { | ||
console.error('Error al verificar si el alumno puede solicitar la baja'); | ||
return false; | ||
} | ||
} catch (error) { | ||
console.error('Error al verificar si el alumno puede solicitar la baja:', error); | ||
return false; | ||
} | ||
}; | ||
|
||
export const responderBaja = async (dni: number, respuesta: string) => { | ||
try { | ||
const response = await fetch(`http://localhost:8000/api/alumnos/baja/${dni}/`, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Authorization: `Bearer ${Cookies.get('tokennn')}`, | ||
}, | ||
body: JSON.stringify({ | ||
estado: respuesta, | ||
}), | ||
|
||
}); | ||
|
||
if (response.ok) { | ||
|
||
return true; | ||
} else { | ||
|
||
return false; | ||
} | ||
} catch (error) { | ||
console.error( error); | ||
return false; | ||
} | ||
}; | ||
|
||
export const dadosDeBaja = async () => { | ||
try { | ||
const response = await fetch(`http://localhost:8000/api/alumnos/baja/`, { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Authorization: `Bearer ${Cookies.get('tokennn')}`, | ||
}, | ||
|
||
}); | ||
|
||
if (response.ok) { | ||
const data = await response.json(); | ||
return data; | ||
} | ||
} catch (error) { | ||
console.error( error); | ||
return false; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import Cookies from 'js-cookie'; | ||
|
||
export const inhabilitacionesA = async ( | ||
dni: number, | ||
) => { | ||
try { | ||
const token = Cookies.get('tokennn'); | ||
|
||
const response = await fetch(`http://localhost:8000/api/alumnos/${dni}/inhabilitaciones/`, { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
}); | ||
|
||
if (response.ok) { | ||
const data = await response.json(); | ||
return data; | ||
} else { | ||
const errorData = await response.json(); | ||
throw new Error( | ||
`Error en la respuesta del servidor: ${errorData.message}` | ||
); | ||
} | ||
} catch (error) { | ||
console.error('Network error:', error); | ||
throw error; | ||
} | ||
|
||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.