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 { ...@@ -5,6 +5,7 @@ interface IUserContext {
user: User user: User
fetchUserInfo: () => void fetchUserInfo: () => void
clearUserInfo: () => void clearUserInfo: () => void
getUserInfo: () => void
} }
function noop() {} function noop() {}
...@@ -29,5 +30,6 @@ export const UserContext = createContext<IUserContext>({ ...@@ -29,5 +30,6 @@ export const UserContext = createContext<IUserContext>({
}, },
fetchUserInfo: noop, fetchUserInfo: noop,
clearUserInfo: noop, clearUserInfo: noop,
getUserInfo: noop,
}) })
export const useUserContext = () => useContext(UserContext) export const useUserContext = () => useContext(UserContext)
...@@ -126,7 +126,9 @@ function UserProvider(props: UserProviderProps) { ...@@ -126,7 +126,9 @@ function UserProvider(props: UserProviderProps) {
} }
return ( return (
<UserContext.Provider value={{ user, fetchUserInfo, clearUserInfo }}> <UserContext.Provider
value={{ user, fetchUserInfo, clearUserInfo, getUserInfo }}
>
{children} {children}
</UserContext.Provider> </UserContext.Provider>
) )
......
import React from 'react' import React, { useEffect } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { useHistory } from 'react-router-dom' 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 GuestSuccessStep = () => {
const { t } = useTranslation(['common']) const { t } = useTranslation(['common'])
const history = useHistory() 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 ( return (
<> <>
<Box <Typography
sx={{ sx={{
paddingTop: '1rem', paddingTop: '1rem',
paddingBottom: '1rem', paddingBottom: '1rem',
typography: 'h3',
}} }}
variant="h2"
> >
{t('thankYou')} {t('thankYou')}
</Box> </Typography>
<Typography sx={{ marginTop: '2rem' }} paragraph>
<Box sx={{ marginTop: '2rem' }}>{t('guestSubmitSuccessDescription')}</Box> {t('guestSubmitSuccessDescription')}
</Typography>
<Button <Button
color="secondary" 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