diff --git a/src/componentes/Globais/CentralDeDownloads/ModalConfirmarExclusaoArquivo.js b/src/componentes/Globais/CentralDeDownloads/ModalConfirmarExclusaoArquivo.js
new file mode 100644
index 000000000..4e06e1e81
--- /dev/null
+++ b/src/componentes/Globais/CentralDeDownloads/ModalConfirmarExclusaoArquivo.js
@@ -0,0 +1,38 @@
+import React from 'react';
+import '../ModalAntDesign/modal-antdesign.scss';
+import { Modal } from 'antd';
+import IconeAvisoVermelho from "../../../assets/img/icone-modal-aviso-vermelho.svg"
+
+export const ModalConfirmarExclusaoArquivo = (props) => {
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
diff --git a/src/componentes/Globais/CentralDeDownloads/index.js b/src/componentes/Globais/CentralDeDownloads/index.js
index 70ffcc412..4dcd6e8f4 100644
--- a/src/componentes/Globais/CentralDeDownloads/index.js
+++ b/src/componentes/Globais/CentralDeDownloads/index.js
@@ -4,6 +4,8 @@ import { TabelaDownloads } from "./TabelaDownloads";
import { getArquivosDownload, getDownloadArquivo, deleteArquivo, putMarcarDesmarcarLido, getArquivosDownloadFiltros, getStatus } from "../../../services/CentralDeDownload.service";
import moment from "moment";
import {CentralDeDownloadContext} from "../../../context/CentralDeDownloads";
+import {ModalConfirmarExclusaoArquivo} from "./ModalConfirmarExclusaoArquivo"
+import {toastCustom} from "../../Globais/ToastCustom";
export const CentralDeDownloads = () => {
@@ -19,6 +21,8 @@ export const CentralDeDownloads = () => {
const [listaArquivos, setListaArquivos] = useState([]);
const [stateFormFiltros, setStateFormFiltros] = useState(initialStateFormFiltros);
const [listaStatus, setListaStatus] = useState([]);
+ const [showModalConfirmarExclusaoArquivo, setShowModalConfirmarExclusaoArquivo] = useState(false);
+ const [arquivoSelecionadoParaExclusao, setArquivoSelecionadoParaExclusao] = useState(null);
useEffect(()=> {
@@ -69,19 +73,17 @@ export const CentralDeDownloads = () => {
}
}
- const excluirArquivo = async(arquivo_download_uuid) => {
- let decisao = window.confirm("Deseja realmente excluir ?");
-
- if(decisao){
- try{
- await deleteArquivo(arquivo_download_uuid);
+ const excluirArquivo = async() => {
+ try {
+ if(arquivoSelecionadoParaExclusao) {
+ await deleteArquivo(arquivoSelecionadoParaExclusao);
await trazerArquivos();
- }catch(e){
- console.log("Erro ao efetuar exclusão ", e.response);
+ setShowModalConfirmarExclusaoArquivo(false);
+ toastCustom.ToastCustomSuccess('Exclusão realizada com sucesso')
}
+ } catch (error) {
+ toastCustom.ToastCustomError('Erro ao tentar excluir arquivo')
}
-
-
}
const marcarDesmarcarLido = async(e, uuid) => {
@@ -118,6 +120,16 @@ export const CentralDeDownloads = () => {
}
}
+ const handleOpenModalExcluirArquivo = (arquivoId) => {
+ setShowModalConfirmarExclusaoArquivo(true);
+ setArquivoSelecionadoParaExclusao(arquivoId);
+ }
+
+ const hangleCloseModalExcluirArquivo = () => {
+ setShowModalConfirmarExclusaoArquivo(false);
+ setArquivoSelecionadoParaExclusao(null);
+ }
+
return (
<>
{
handleOpenModalExcluirArquivo(e)}
marcarDesmarcarLido={marcarDesmarcarLido}
/>
-
+ excluirArquivo()}
+ onCancel={() => hangleCloseModalExcluirArquivo()}
+ titulo="Excluir arquivo"
+ bodyText={"Deseja realmente excluir o arquivo selecionado?"}
+ okText={"Excluir"}
+ cancelText={"Cancelar"}
+ />
>
)
}
\ No newline at end of file