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 (podkrepi-bg#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
sashko9807 authored and RalitsaIlieva committed Dec 14, 2023
1 parent 5515062 commit cf2bbd5
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
@@ -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')

@@ -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 {
@@ -36,6 +38,7 @@ function LoginForm() {
throw new Error(resp.error)
}
if (resp?.ok) {
refetch()
setLoading(false)
formik.setFieldValue('isAnonymous', false)
setStep(2)

0 comments on commit cf2bbd5

Please sign in to comment.