-
Notifications
You must be signed in to change notification settings - Fork 7
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
1 parent
604c2be
commit eeb8581
Showing
39 changed files
with
872 additions
and
808 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
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
128 changes: 80 additions & 48 deletions
128
src/components/components-escolasCadastradas/ModalExcluirEscolas.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 |
---|---|---|
@@ -1,54 +1,86 @@ | ||
import { notification } from 'antd'; | ||
import fetchExcluirEscola from '../../service/excluirEscola'; | ||
import './style/ModalExcluirEscolas.css'; | ||
import { useState } from 'react'; | ||
import { useFiltroTabela } from '../../context/FiltroTabela'; | ||
import { notification } from "antd"; | ||
import { useFiltroTabela } from "../../context/FiltroTabela"; | ||
import fetchExcluirEscola from "../../service/excluirEscola"; | ||
import "./style/ModalExcluirEscolas.css"; | ||
|
||
interface ModalExcluirEscolaProps { | ||
open: boolean | ||
id: number | ||
close: () => void | ||
closeModalExcluirEscola: () => void | ||
nomeEscola: string | ||
open: boolean; | ||
id: number; | ||
close: () => void; | ||
closeModalExcluirEscola: () => void; | ||
nomeEscola: string; | ||
} | ||
|
||
const ModalExcluirEscolas = ({open, id, close, closeModalExcluirEscola, nomeEscola}: ModalExcluirEscolaProps) => { | ||
const {fetchEscolasFiltradas} = useFiltroTabela() | ||
const excluirEscola = async () => { | ||
try { | ||
await fetchExcluirEscola({ id_escola: id }); | ||
notification.success({ message: `Escola ${nomeEscola} excluída com sucesso!` }); | ||
close(); | ||
fetchEscolasFiltradas(); | ||
} catch (error) { | ||
notification.error({ message: `Erro ao excluir a escola ${nomeEscola}! ` }); | ||
close(); | ||
} | ||
|
||
const ModalExcluirEscolas = ({ | ||
open, | ||
id, | ||
close, | ||
closeModalExcluirEscola, | ||
nomeEscola, | ||
}: ModalExcluirEscolaProps) => { | ||
const { fetchEscolasFiltradas } = useFiltroTabela(); | ||
const excluirEscola = async () => { | ||
try { | ||
await fetchExcluirEscola({ id_escola: id }); | ||
notification.success({ | ||
message: `Escola ${nomeEscola} excluída com sucesso!`, | ||
}); | ||
close(); | ||
fetchEscolasFiltradas(); | ||
} catch (error) { | ||
notification.error({ | ||
message: `Erro ao excluir a escola ${nomeEscola}! `, | ||
}); | ||
close(); | ||
} | ||
if (!open) { return null } | ||
return ( | ||
< > | ||
<div className='overlay-modal'> | ||
<div style={{ zIndex: 10000, position: 'absolute', top: '31%', left: '31%', right: '31%' }}> | ||
<div className="div br-modal large" style={{ width: '80%', height: '220px' }}> | ||
<div className="br-modal-header content-left">Confirmar Exclusão | ||
</div> | ||
<div className='modal-line'> | ||
</div> | ||
<p className='space-p'> | ||
Deseja excluir a escola permanentemende? A ação não pode ser desfeita. | ||
</p> | ||
<div className="br-modal-footer content-right"> | ||
<button className="br-button secondary" type="button" onClick={closeModalExcluirEscola}>Voltar | ||
</button> | ||
<button className="br-button cancel-button" type="button" onClick={excluirEscola}>Excluir | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
}; | ||
if (!open) { | ||
return null; | ||
} | ||
return ( | ||
<> | ||
<div className="overlay-modal"> | ||
<div | ||
style={{ | ||
zIndex: 10000, | ||
position: "absolute", | ||
top: "31%", | ||
left: "31%", | ||
right: "31%", | ||
}} | ||
> | ||
<div | ||
className="div br-modal large" | ||
style={{ width: "80%", height: "220px" }} | ||
> | ||
<div className="br-modal-header content-left"> | ||
Confirmar Exclusão | ||
</div> | ||
</> | ||
); | ||
} | ||
export default ModalExcluirEscolas; | ||
<div className="modal-line"></div> | ||
<p className="space-p"> | ||
Deseja excluir a escola permanentemende? A ação não pode ser | ||
desfeita. | ||
</p> | ||
<div className="br-modal-footer content-right"> | ||
<button | ||
className="br-button secondary" | ||
type="button" | ||
onClick={closeModalExcluirEscola} | ||
> | ||
Voltar | ||
</button> | ||
<button | ||
className="br-button cancel-button" | ||
type="button" | ||
onClick={excluirEscola} | ||
> | ||
Excluir | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
}; | ||
export default ModalExcluirEscolas; |
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
Oops, something went wrong.