Skip to content

Commit

Permalink
one-time-donation/LoginForm.tsx: Refetch useCurrentPerson when logged…
Browse files Browse the repository at this point in the history
… in (#1677)

When user logs in trough donation step 2, person's data remains undefined due to data not being updated.
Manually refetch the data coming from useCurrentPerson() after login to refresh the user's data
  • Loading branch information
sashko9807 authored Dec 4, 2023
1 parent 3fda8d8 commit e7b1c5a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/components/client/one-time-donation/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import PasswordField from 'components/common/form/PasswordField'
import LinkButton from 'components/common/LinkButton'
import { StepsContext } from './helpers/stepperContext'
import { AlertStore } from 'stores/AlertStore'
import { useCurrentPerson } from 'common/util/useCurrentPerson'

const onGoogleLogin = () => signIn('google')

Expand All @@ -22,6 +23,7 @@ function LoginForm() {
const [loading, setLoading] = useState(false)
const { setStep } = useContext(StepsContext)
const formik = useFormikContext<OneTimeDonation>()
const { refetch } = useCurrentPerson()

const onClick = async () => {
try {
Expand All @@ -36,6 +38,7 @@ function LoginForm() {
throw new Error(resp.error)
}
if (resp?.ok) {
refetch()
setLoading(false)
formik.setFieldValue('isAnonymous', false)
setStep(2)
Expand Down

0 comments on commit e7b1c5a

Please sign in to comment.