From ab332518826eb80bf2cd15f614e365fbf414e6e5 Mon Sep 17 00:00:00 2001 From: ericoBandeira Date: Mon, 8 Nov 2021 13:13:35 -0300 Subject: [PATCH 1/3] #182 Fix user bug Co-authored-by: Lucas Vieira de Jesus --- src/Pages/ViewRecord/index.js | 8 ++++---- src/Services/Axios/profileService.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Pages/ViewRecord/index.js b/src/Pages/ViewRecord/index.js index 791a6c2..3d98395 100644 --- a/src/Pages/ViewRecord/index.js +++ b/src/Pages/ViewRecord/index.js @@ -91,8 +91,8 @@ const ViewRecord = () => { }; const previousForward = async (response) => { - const infoUser = await getInfoUserbyID(response.forwarded_by); - + const infoUser = await getInfoUserbyID(); + console.log(infoUser); const destinationID = response.destination_id; const allSections2 = await getSections(); console.log("Allsec", allSections2); @@ -117,10 +117,10 @@ const ViewRecord = () => { const newForward = { setor: destinationSection[0].name, - setorOrigin: infoUser.user.sections[0].name, + setorOrigin: infoUser.sections[0].name, date: dataFormatadaCreatedAt, dateForward: dataFormatadaUpdatedAt, - name: infoUser.user.name, + name: infoUser.name, }; return newForward; }; diff --git a/src/Services/Axios/profileService.js b/src/Services/Axios/profileService.js index 463e329..9304263 100644 --- a/src/Services/Axios/profileService.js +++ b/src/Services/Axios/profileService.js @@ -158,7 +158,7 @@ export async function getUserAccessLevel(user, toast) { export async function getInfoUserbyID(id) { try { - const response = await APIProfile.get(`/user/${id}/info`, { + const response = await APIProfile.get(`/user/info`, { headers: { "X-Access-Token": getToken(), }, From 9ddd75426abfa6b86a86f58242544c46f4cc3646 Mon Sep 17 00:00:00 2001 From: ericoBandeira Date: Mon, 8 Nov 2021 13:37:24 -0300 Subject: [PATCH 2/3] #182 remove hardcode of sections list --- src/Components/DropDownButton/index.js | 50 +++++++++----------------- src/Pages/ViewRecord/index.js | 6 ++-- 2 files changed, 20 insertions(+), 36 deletions(-) diff --git a/src/Components/DropDownButton/index.js b/src/Components/DropDownButton/index.js index 32be00e..bb3156b 100644 --- a/src/Components/DropDownButton/index.js +++ b/src/Components/DropDownButton/index.js @@ -1,42 +1,26 @@ +import { useEffect, useState } from "react"; +import { getSections } from "../../Services/Axios/profileService"; import DivSelectSetor from "./DivSelectSetor"; const DropDownButton = ({ onChangeOpt }) => { + const [sections, setSections] = useState([]); + + useEffect(() => { + async function fetchSections() { + const sectionsList = await getSections(); + setSections(sectionsList); + console.log("SecList", sectionsList); + } + + fetchSections(); + }, []); + return ( ); diff --git a/src/Pages/ViewRecord/index.js b/src/Pages/ViewRecord/index.js index 3d98395..9c5aa48 100644 --- a/src/Pages/ViewRecord/index.js +++ b/src/Pages/ViewRecord/index.js @@ -80,9 +80,10 @@ const ViewRecord = () => { }; const handleForward = async () => { + const infoUser = await getInfoUserbyID(); const forwardRecInfo = { id: id, - forwarded_by: userID, + forwarded_by: infoUser.email, origin_id: userSectorNum, destination_id: sector, }; @@ -91,11 +92,10 @@ const ViewRecord = () => { }; const previousForward = async (response) => { + // Get user data to send record const infoUser = await getInfoUserbyID(); - console.log(infoUser); const destinationID = response.destination_id; const allSections2 = await getSections(); - console.log("Allsec", allSections2); const destinationSection = allSections2.filter((indice) => { return indice.id == destinationID; }); From 7e605eafa5b1698dd147197d90248872cfd9cf53 Mon Sep 17 00:00:00 2001 From: ericoBandeira Date: Mon, 8 Nov 2021 13:43:54 -0300 Subject: [PATCH 3/3] #182 remove none --- src/Components/DropDownButton/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Components/DropDownButton/index.js b/src/Components/DropDownButton/index.js index bb3156b..fdff601 100644 --- a/src/Components/DropDownButton/index.js +++ b/src/Components/DropDownButton/index.js @@ -18,9 +18,10 @@ const DropDownButton = ({ onChangeOpt }) => { return ( );