From 0edd25d3dd20a9484f754575953129e825a2271e Mon Sep 17 00:00:00 2001 From: Lucas Schoenfelder <les17@inf.ufpr.br> Date: Tue, 19 Jan 2021 21:54:05 -0300 Subject: [PATCH] added functionality to dispatch user info to Store.js --- src/Pages/UserPage.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Pages/UserPage.js b/src/Pages/UserPage.js index 139f63b6..d8eecc53 100644 --- a/src/Pages/UserPage.js +++ b/src/Pages/UserPage.js @@ -58,7 +58,7 @@ const GetHeaderConfig = () => { } export default function UserPage (props){ - const {state} = useContext(Store) + const {state, dispatch} = useContext(Store) const id = state.currentUser.id const [tabValue, setTabValue] = useState( @@ -81,12 +81,17 @@ export default function UserPage (props){ }) .then( (response) => { console.log(response) - - if((response.data.role_ids.includes(4))) { - setTabs([ - 'Atividades', 'Meus Recursos', 'Favoritos', 'Coleções', 'Rede', 'Curadoria' - ]) + dispatch ( { + type: 'GET_USER', + user: response.data } + ) + + if((response.data.role_ids.includes(4))) { + setTabs([ + 'Atividades', 'Meus Recursos', 'Favoritos', 'Coleções', 'Rede', 'Curadoria' + ]) + } }, (error) => { console.log('error while running ComponentDidMout') -- GitLab