Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OneTimeDonationPage: Render DonationStepper only on client #1543

Merged
merged 2 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/components/client/one-time-donation/AnonymousForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ import { useTranslation } from 'next-i18next'
import { Grid, Typography } from '@mui/material'
import EmailField from 'components/common/form/EmailField'
import { useSession } from 'next-auth/react'
import { useFormikContext } from 'formik'
import { OneTimeDonation } from 'gql/donations'

export default function AnonymousForm() {
const { t } = useTranslation('one-time-donation')
const { data: session } = useSession()
const formik = useFormikContext<OneTimeDonation>()
const isLogged = session?.accessToken ? true : false
return (
<>
Expand All @@ -23,7 +26,13 @@ export default function AnonymousForm() {
name="personsEmail"
label="Email"
fullWidth
value={isLogged ? session?.user?.email : null}
value={
isLogged
? session?.user?.email
: formik.values.personsEmail
? formik.values.personsEmail
: ''
}
disabled={isLogged ? true : false}
/>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { beneficiaryCampaignPictureUrl } from 'common/util/campaignImageUrls'
import Layout from 'components/client/layout/Layout'
import { useViewCampaign } from 'common/hooks/campaigns'
import CenteredSpinner from 'components/common/CenteredSpinner'
import DonationStepper from '../Steps'
import dynamic from 'next/dynamic'

import {
BeneficiaryAvatar,
Expand All @@ -24,6 +24,8 @@ const scrollWindow = () => {
window.scrollTo({ top: 200, behavior: 'smooth' })
}

const DonationStepper = dynamic(() => import('../Steps'), { ssr: false })

export default function OneTimeDonation({ slug }: { slug: string }) {
const { data, isLoading } = useViewCampaign(slug)
// const paymentIntentMutation = useCreatePaymentIntent({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export default function SecondStep() {
const mobile = useMediaQuery('(max-width:575px)')
const { data: session } = useSession()

const [value, setValue] = useState('1')
const formik = useFormikContext<OneTimeDonation>()
const [value, setValue] = useState(formik.values.isAnonymous ? '3' : '1')
const handleChange = (event: React.SyntheticEvent, newTab: string) => {
if (newTab === Tabs.Anonymous) {
formik.setFieldValue('isAnonymous', true)
Expand Down