Skip to content

Commit

Permalink
Merge pull request #599 from knowit/feature/597-profilbilde-i-heading
Browse files Browse the repository at this point in the history
[597-Fix] Profilbilde i header
  • Loading branch information
joacimds authored Jun 25, 2024
2 parents 8763721 + d3b1e15 commit d49d9f8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "https://localhost:3000",
"webRoot": "${workspaceFolder}/apps/website"
"webRoot": "${workspaceFolder}/apps/web"
}
]
}
25 changes: 9 additions & 16 deletions apps/web/src/context/UserInfoContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,25 @@ const UserInfoProvider: React.FC<{ children: React.ReactNode }> = ({
try {
const user = await getUserInfo()
setUserInfo(user)

if (user) {
const userEmail = user.email?.toLowerCase()
if (userEmail) {
const employeeProfile = await getEmployeeProfile(userEmail)
setUserEmployeeProfile(employeeProfile)
}
}
} catch (error) {
if (isError(error)) {
setUserInfo(null)
setUserEmployeeProfile(null)
}
}
}

fetchUser()
}, [])

useEffect(() => {
async function fetchEmployeeProfile() {
if (userInfo) {
const userEmail = userInfo.email?.toLowerCase()
if (userEmail) {
const data = await getEmployeeProfile(userEmail)
setUserEmployeeProfile(data)
}
} else {
setUserEmployeeProfile(null)
}
}

fetchEmployeeProfile()
}, [userInfo])

return (
<UserInfoContext.Provider
value={{
Expand Down

0 comments on commit d49d9f8

Please sign in to comment.