Skip to content
Snippets Groups Projects
Verified Commit 29c82b3f authored by Andreas Ellewsen's avatar Andreas Ellewsen
Browse files

Refetch user info after completing registration

If we don't fetch the info again, the frontpage will redirect us back to
/guestregister because the user does not have
registration_completed_date set.
parent b87b4569
No related branches found
No related tags found
1 merge request!259Refetch user info after completing registration
Pipeline #112292 passed
......@@ -5,6 +5,7 @@ interface IUserContext {
user: User
fetchUserInfo: () => void
clearUserInfo: () => void
getUserInfo: () => void
}
function noop() {}
......@@ -29,5 +30,6 @@ export const UserContext = createContext<IUserContext>({
},
fetchUserInfo: noop,
clearUserInfo: noop,
getUserInfo: noop,
})
export const useUserContext = () => useContext(UserContext)
......@@ -126,7 +126,9 @@ function UserProvider(props: UserProviderProps) {
}
return (
<UserContext.Provider value={{ user, fetchUserInfo, clearUserInfo }}>
<UserContext.Provider
value={{ user, fetchUserInfo, clearUserInfo, getUserInfo }}
>
{children}
</UserContext.Provider>
)
......
import React from 'react'
import React, { useEffect } from 'react'
import { useTranslation } from 'react-i18next'
import { useHistory } from 'react-router-dom'
import { Box, Button } from '@mui/material'
import { Button, Typography } from '@mui/material'
import { useUserContext } from 'contexts'
const GuestSuccessStep = () => {
const { t } = useTranslation(['common'])
const history = useHistory()
const { getUserInfo } = useUserContext()
// Refetch user info after submission, so that the front page doesn't redirect us
// back because of outdated info
useEffect(() => {
getUserInfo()
}, [])
return (
<>
<Box
<Typography
sx={{
paddingTop: '1rem',
paddingBottom: '1rem',
typography: 'h3',
}}
variant="h2"
>
{t('thankYou')}
</Box>
<Box sx={{ marginTop: '2rem' }}>{t('guestSubmitSuccessDescription')}</Box>
</Typography>
<Typography sx={{ marginTop: '2rem' }} paragraph>
{t('guestSubmitSuccessDescription')}
</Typography>
<Button
color="secondary"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment