Skip to content

Commit

Permalink
fga-eps-mds/2021.1-Oraculo#88 added modal to confirm forwarding
Browse files Browse the repository at this point in the history
Co-authored-by: Joao Paulo Lima da Silva <jpaulo.on@gmail.com>
  • Loading branch information
GabrielSSAraujo and jpaulohe4rt committed Oct 15, 2021
1 parent f5dae84 commit bac1425
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 21 deletions.
53 changes: 32 additions & 21 deletions src/Pages/ViewProcess/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,48 +34,51 @@ const ViewProcess = (props) => {
const [seiNumber, setSeiNumber] = useState("");
const [documentDate, setDocumentDate] = useState("");
const [requester, setRequester] = useState("");
const [situationReg, setSituation] = useState("");

const [userName, setUserName] = useState("");
const [userSetor, setUserSetor] = useState("");
const [userSectionID, setUserSectionID] = useState("");

const [buttonModal, setButtonModal] = useState("");
const [buttonModalConfirmForward, setButtonModalConfirmForward] =
useState("");
const [buttonDone, setButtonDone] = useState(false);

window.onload = async function getInitInfo() {
const process = await getProcessByID(props.id, toast);

setSeiNumber(process.sei_number);
setDocumentDate(process.document_date);
setRequester(process.requester);
//mostra processo concluido e muda botão

const user = await getInfoUser(toast);

setUserName(user.name);
setUserSetor(user.sections[0].name);

if (process.situation == 1) {
const newFoward = [
...foward,
{
name: "NOME",
name: user.name,
defaultText: "Registro: Concluido",
date: getDate(),
},
];
setFoward(newFoward);
setButtonModal(false);
setButtonDone(true);
document.querySelector(".fowardIcon").style.display = "none";
}

const user = await getInfoUser(toast);

setUserName(user.name);
setUserSetor(user.sections[0].name);
};

const handleButtonProcess = () => {
setButtonModal(true);
const handleFoward = () => {
setButtonModalConfirmForward(true);
};

async function handleFoward() {
const response = await fowardRegisterDep(userSectionID, props.id, toast);
async function handleClickModalConfirmForward() {
//problem: i need know the department number
const response = await fowardRegisterDep(4, props.id, toast);

if (response) {
const newFoward = [
Expand All @@ -90,23 +93,22 @@ const ViewProcess = (props) => {
},
];
setFoward(newFoward);
setButtonModalConfirmForward(false);
}
}

const [buttonDone, setButtonDone] = useState(false);
const handleClickModalRed = () => {
var data = new Date();
var dia = String(data.getDate()).padStart(2, "0");
var mes = String(data.getMonth() + 1).padStart(2, "0");
var ano = data.getFullYear();
var dataAtual = dia + "/" + mes + "/" + ano;
const handleButtonProcess = () => {
setButtonModal(true);
};

const handleClickModalRed = () => {
const newFoward = [
...foward,
{
name: "NOME",
name: userName,

defaultText: "Registro: Concluido",
date: dataAtual,
date: getDate(),
},
];

Expand All @@ -124,6 +126,7 @@ const ViewProcess = (props) => {

const handleClickModalWhite = () => {
setButtonModal(false);
setButtonModalConfirmForward(false);
};

return (
Expand Down Expand Up @@ -187,6 +190,14 @@ const ViewProcess = (props) => {
onClickRedButton={handleClickModalRed}
onClickWhiteButton={handleClickModalWhite}
/>
<ModalDoubleCheck
content="Deseja realmente encaminhar esse registro?"
trigger={buttonModalConfirmForward}
titleRedButton="confirmar"
titleWhiteButton="Cancelar"
onClickRedButton={handleClickModalConfirmForward}
onClickWhiteButton={handleClickModalWhite}
/>
</StyledDivSupProcess>
</>
);
Expand Down
2 changes: 2 additions & 0 deletions src/Services/Axios/processService.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export async function getProcessByID(ID, toast) {

export async function fowardRegisterDep(section_id, id, toast) {
try {
console.log(id);
console.log(section_id);
await APIProcess.post(`/records/${id}/forward`, {
section_id: section_id,
});
Expand Down

0 comments on commit bac1425

Please sign in to comment.