-
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
3 changed files
with
122 additions
and
9 deletions.
There are no files selected for viewing
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,28 @@ | ||
import Cookies from 'js-cookie'; | ||
|
||
export const solicitarBajaAlumno = async (dni: number, motivo: 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({ | ||
dni: dni, | ||
motivo: motivo, | ||
}), | ||
}); | ||
|
||
if (response.ok) { | ||
|
||
return true; | ||
} else { | ||
console.error('Error al solicitar la baja'); | ||
return false; | ||
} | ||
} catch (error) { | ||
console.error('Error al solicitar la baja:', 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
65 changes: 65 additions & 0 deletions
65
FrontAdmin/src/components/Pages-Alumnos/DarseBaja/ModalConfir.tsx
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,65 @@ | ||
import React, { useState } from 'react'; | ||
import { | ||
Modal, | ||
ModalOverlay, | ||
ModalContent, | ||
ModalHeader, | ||
ModalFooter, | ||
ModalBody, | ||
ModalCloseButton, | ||
Text, | ||
Button, | ||
Input, | ||
FormControl, | ||
FormLabel, | ||
} from '@chakra-ui/react'; | ||
|
||
interface ModalComponentProps { | ||
isOpen: boolean; | ||
onClose: () => void; | ||
texto: string; | ||
confirmar: (motivo: string) => void; | ||
} | ||
|
||
export default function ModalConfirmar({ | ||
isOpen, | ||
onClose, | ||
texto, | ||
confirmar, | ||
}: ModalComponentProps) { | ||
const [motivo, setMotivo] = useState(''); | ||
|
||
const handleConfirmar = () => { | ||
confirmar(motivo); | ||
onClose(); | ||
}; | ||
|
||
return ( | ||
<Modal isOpen={isOpen} onClose={onClose}> | ||
<ModalOverlay /> | ||
<ModalContent> | ||
<ModalHeader>Confirmar cambios</ModalHeader> | ||
<ModalCloseButton /> | ||
<ModalBody> | ||
<Text mb={4}>{texto}</Text> | ||
<FormControl> | ||
<FormLabel>Motivo de la baja</FormLabel> | ||
<Input | ||
value={motivo} | ||
onChange={(e) => setMotivo(e.target.value)} | ||
placeholder="Escribe el motivo aquí" | ||
/> | ||
</FormControl> | ||
</ModalBody> | ||
<ModalFooter> | ||
<Button colorScheme="blue" mr={3} onClick={handleConfirmar} size="sm"> | ||
Aceptar | ||
</Button> | ||
<Button colorScheme="blue" mr={3} onClick={onClose} variant="light" size="sm"> | ||
Cancelar | ||
</Button> | ||
</ModalFooter> | ||
</ModalContent> | ||
</Modal> | ||
); | ||
} |