Skip to content

Commit

Permalink
added: isAnonymous in request to backend
Browse files Browse the repository at this point in the history
  • Loading branch information
quantum-grit authored and igoychev committed Jul 15, 2022
1 parent 46cb2de commit c47514f
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 47 deletions.
2 changes: 1 addition & 1 deletion public/locales/bg/one-time-donation.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"anonymous-menu": {
"checkbox-label": "Дарение без регистрация",
"info-start": "При дарение без регистрация, няма да можем да ви изпратим сертификат за дарение или списък с вашите дарения. Ако все пак искате да получите сертификат, моля да споделите вашите данни - те няма да бъдат видими в платформата.",
"info-start": "При дарение без регистрация, няма да можем да ви изпратим сертификат за дарение или списък с вашите дарения. Ако все пак искате да получите сертификат, моля да споделите вашият имейл - той няма да бъде видим в платформата.",
"firstName": "Име",
"lastName": "Фамилия",
"phone": "Телефон",
Expand Down
2 changes: 1 addition & 1 deletion public/locales/en/one-time-donation.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"anonymous-menu": {
"checkbox-label": "Donate anonymously",
"info-start": "When donating without registration we won't be able to send you back a donation certificate or a list of your donations. If you still want to receive a certificate, please share at least your contact data - it will not be visible in the platform.",
"info-start": "When donating without registration we won't be able to send you back a donation certificate or a list of your donations. If you still want to receive a certificate, please share at least your email - it will not be visible in the platform.",
"firstName": "First name",
"lastName": "Last name",
"phone": "Telephone",
Expand Down
19 changes: 0 additions & 19 deletions src/components/one-time-donation/AnonymousForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,9 @@ export default function AnonymousForm() {
<Grid item xs={12} color="#343434" sx={{ opacity: 0.9 }}>
<Typography>{t('anonymous-menu.info-start')}</Typography>
</Grid>
<Grid item xs={12} md={6}>
<FormTextField
name="personsFirstName"
type="text"
label={t('anonymous-menu.firstName')}
fullWidth
/>
</Grid>
<Grid item xs={12} md={6}>
<FormTextField
name="personsLastName"
type="text"
label={t('anonymous-menu.lastName')}
fullWidth
/>
</Grid>
<Grid item xs={12} md={12}>
<FormTextField name="personsEmail" type="text" label="Email" fullWidth />
</Grid>
<Grid item xs={12}>
<Typography>{t('anonymous-menu.info-end')}</Typography>
</Grid>
</Grid>
</>
)
Expand Down
2 changes: 2 additions & 0 deletions src/components/one-time-donation/FormikStepper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export function FormikStepper({ children, ...props }: GenericFormProps<OneTimeDo
}, [router.query.success])
const currentChild = childrenArray[step]
const { data: session } = useSession()

function isLastStep() {
return step === childrenArray.length - 2
}
Expand All @@ -66,6 +67,7 @@ export function FormikStepper({ children, ...props }: GenericFormProps<OneTimeDo
validationSchema={currentChild.props.validationSchema}
onSubmit={async (values, helpers) => {
if (isLastStep()) {
values.isAnonymous = !isLogged()
await props.onSubmit(values, helpers)
} else if (isFirstStep() && isLogged()) {
if (values.payment === 'bank') {
Expand Down
4 changes: 2 additions & 2 deletions src/components/one-time-donation/Steps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ import { toMoney } from 'common/util/money'

const initialValues: OneTimeDonation = {
message: '',
anonymous: false,
isAnonymous: true,
amount: '',
otherAmount: 0,
anonymousDonation: false,
personsFirstName: '',
personsLastName: '',
personsEmail: '',
Expand Down Expand Up @@ -64,6 +63,7 @@ export default function DonationStepper() {
firstName: values?.personsFirstName ? values.personsFirstName : 'Anonymous',
lastName: values?.personsLastName ? values.personsLastName : 'Donor',
personEmail: values?.personsEmail ? values.personsEmail : userEmail,
isAnonymous: values?.isAnonymous ?? true,
phone: values?.personsPhone ? values.personsPhone : null,
successUrl: `${baseUrl}${routes.campaigns.oneTimeDonation(campaign.slug)}?success=true`,
cancelUrl: `${baseUrl}${routes.campaigns.oneTimeDonation(campaign.slug)}?success=false`,
Expand Down
33 changes: 13 additions & 20 deletions src/components/one-time-donation/helpers/validation-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,20 @@ export const validateFirst: yup.SchemaOf<FirstStep> = yup
}),
})

export const validateSecond: yup.SchemaOf<SecondStep> = yup
.object()
.defined()
.shape({
anonymousDonation: yup.boolean().when('anonymous', {
is: false,
then: yup.boolean().required(),
}),
personsEmail: email.notRequired(),
personsFirstName: name.notRequired(),
personsLastName: name.notRequired(),
personsPhone: phone.notRequired(),
loginEmail: email.notRequired(),
loginPassword: password.notRequired(),
registerEmail: email.notRequired(),
registerFirstName: yup.string().notRequired(),
registerLastName: yup.string().notRequired(),
registerPassword: password.notRequired(),
})
export const validateSecond: yup.SchemaOf<SecondStep> = yup.object().defined().shape({
isAnonymous: yup.boolean().required(),
personsEmail: email.notRequired(),
personsFirstName: name.notRequired(),
personsLastName: name.notRequired(),
personsPhone: phone.notRequired(),
loginEmail: email.notRequired(),
loginPassword: password.notRequired(),
registerEmail: email.notRequired(),
registerFirstName: yup.string().notRequired(),
registerLastName: yup.string().notRequired(),
registerPassword: password.notRequired(),
})

export const validateThird: yup.SchemaOf<ThirdStep> = yup.object().defined().shape({
message: yup.string().notRequired(),
anonymous: yup.bool().required(),
})
7 changes: 3 additions & 4 deletions src/gql/donations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type CheckoutSessionInput = {
firstName?: string
lastName?: string
personEmail?: string
isAnonymous: boolean
phone?: string | null
}

Expand Down Expand Up @@ -94,10 +95,9 @@ export type UserDonationResult = {

export type OneTimeDonation = {
message?: string
anonymous: boolean
isAnonymous: boolean
amount: string
otherAmount: number
anonymousDonation: boolean
personsFirstName: string
personsLastName: string
personsEmail: string
Expand All @@ -123,7 +123,7 @@ export type FirstStep = {
}

export type SecondStep = {
anonymousDonation?: boolean
isAnonymous: boolean
personsFirstName?: string
personsLastName?: string
personsPhone?: string
Expand All @@ -132,7 +132,6 @@ export type SecondStep = {

export type ThirdStep = {
message?: string
anonymous: boolean
}
export type BankTransactionsUploadImage = {
bankTransactionsFileId: string
Expand Down

0 comments on commit c47514f

Please sign in to comment.