-
Notifications
You must be signed in to change notification settings - Fork 93
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
[Bug] You can click Next if you are both not logged and not anonymous #1134
Changes from 3 commits
ee46373
a6de21c
39e347a
24c7fe0
aaaf227
8298d69
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ import { useCurrentPerson } from 'common/util/useCurrentPerson' | |
|
||
const initialValues: OneTimeDonation = { | ||
message: '', | ||
isAnonymous: true, | ||
isAnonymous: false, | ||
amount: '', | ||
amountWithFees: 0, | ||
cardIncludeFees: false, | ||
|
@@ -64,7 +64,6 @@ export default function DonationStepper({ onStepChange }: DonationStepperProps) | |
return session && session.accessToken ? true : false | ||
} | ||
|
||
initialValues.isAnonymous = !isLogged() | ||
const userEmail = session?.user?.email | ||
|
||
const donate = React.useCallback( | ||
|
@@ -76,7 +75,7 @@ export default function DonationStepper({ onStepChange }: DonationStepperProps) | |
firstName: values?.personsFirstName ? values.personsFirstName : 'Anonymous', | ||
lastName: values?.personsLastName ? values.personsLastName : 'Donor', | ||
personEmail: values?.personsEmail ? values.personsEmail : userEmail, | ||
isAnonymous: values?.isAnonymous ?? !isLogged(), | ||
isAnonymous: values?.isAnonymous !== undefined ? values.isAnonymous : true, | ||
Comment on lines
-79
to
+78
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or here |
||
phone: values?.personsPhone ? values.personsPhone : null, | ||
successUrl: `${baseUrl}${routes.campaigns.oneTimeDonation(campaign.slug)}?success=true`, | ||
cancelUrl: `${baseUrl}${routes.campaigns.oneTimeDonation(campaign.slug)}?success=false`, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import { TabContext, TabList } from '@mui/lab' | ||
import TabPanel from '@mui/lab/TabPanel' | ||
import { Box, Tab, Typography, useMediaQuery } from '@mui/material' | ||
import { useFormikContext } from 'formik' | ||
import { OneTimeDonation } from 'gql/donations' | ||
import { useSession } from 'next-auth/react' | ||
import { useTranslation } from 'next-i18next' | ||
import React, { useState } from 'react' | ||
|
@@ -15,8 +17,13 @@ export default function SecondStep() { | |
const { data: session } = useSession() | ||
|
||
const [value, setValue] = useState('1') | ||
|
||
const formik = useFormikContext<OneTimeDonation>() | ||
const handleChange = (event: React.SyntheticEvent, newValue: string) => { | ||
if (Number(newValue) === 3) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dimitur2204 It's not really clear to me what the constant If we're using that as a number of step let's name it in some kind of enum or similar so it brings more context. Similar to: if (Number(step) === Steps.Anonymous) {
// ...
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I see we can also use names instead of numbers for the tabs. Ex. |
||
formik.setFieldValue('isAnonymous', true) | ||
} else { | ||
formik.setFieldValue('isAnonymous', false) | ||
} | ||
setValue(newValue) | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect the strange behaviour before was coming from either here!