From c47514ff3de24401b25459d58f78f38b101edbdf Mon Sep 17 00:00:00 2001 From: quantum-grit Date: Fri, 15 Jul 2022 20:39:30 +0300 Subject: [PATCH] added: isAnonymous in request to backend --- public/locales/bg/one-time-donation.json | 2 +- public/locales/en/one-time-donation.json | 2 +- .../one-time-donation/AnonymousForm.tsx | 19 ----------- .../one-time-donation/FormikStepper.tsx | 2 ++ src/components/one-time-donation/Steps.tsx | 4 +-- .../helpers/validation-schema.ts | 33 ++++++++----------- src/gql/donations.d.ts | 7 ++-- 7 files changed, 22 insertions(+), 47 deletions(-) diff --git a/public/locales/bg/one-time-donation.json b/public/locales/bg/one-time-donation.json index 88ea93c93..6d1c6c1fa 100644 --- a/public/locales/bg/one-time-donation.json +++ b/public/locales/bg/one-time-donation.json @@ -7,7 +7,7 @@ }, "anonymous-menu": { "checkbox-label": "Дарение без регистрация", - "info-start": "При дарение без регистрация, няма да можем да ви изпратим сертификат за дарение или списък с вашите дарения. Ако все пак искате да получите сертификат, моля да споделите вашите данни - те няма да бъдат видими в платформата.", + "info-start": "При дарение без регистрация, няма да можем да ви изпратим сертификат за дарение или списък с вашите дарения. Ако все пак искате да получите сертификат, моля да споделите вашият имейл - той няма да бъде видим в платформата.", "firstName": "Име", "lastName": "Фамилия", "phone": "Телефон", diff --git a/public/locales/en/one-time-donation.json b/public/locales/en/one-time-donation.json index 5128b05dc..cc4d45626 100644 --- a/public/locales/en/one-time-donation.json +++ b/public/locales/en/one-time-donation.json @@ -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", diff --git a/src/components/one-time-donation/AnonymousForm.tsx b/src/components/one-time-donation/AnonymousForm.tsx index 125bbad9d..df6a28e48 100644 --- a/src/components/one-time-donation/AnonymousForm.tsx +++ b/src/components/one-time-donation/AnonymousForm.tsx @@ -15,28 +15,9 @@ export default function AnonymousForm() { {t('anonymous-menu.info-start')} - - - - - - - - {t('anonymous-menu.info-end')} - ) diff --git a/src/components/one-time-donation/FormikStepper.tsx b/src/components/one-time-donation/FormikStepper.tsx index 4ec471e7f..0631ccbd7 100644 --- a/src/components/one-time-donation/FormikStepper.tsx +++ b/src/components/one-time-donation/FormikStepper.tsx @@ -43,6 +43,7 @@ export function FormikStepper({ children, ...props }: GenericFormProps { if (isLastStep()) { + values.isAnonymous = !isLogged() await props.onSubmit(values, helpers) } else if (isFirstStep() && isLogged()) { if (values.payment === 'bank') { diff --git a/src/components/one-time-donation/Steps.tsx b/src/components/one-time-donation/Steps.tsx index 444d17af7..d968e4f72 100644 --- a/src/components/one-time-donation/Steps.tsx +++ b/src/components/one-time-donation/Steps.tsx @@ -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: '', @@ -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`, diff --git a/src/components/one-time-donation/helpers/validation-schema.ts b/src/components/one-time-donation/helpers/validation-schema.ts index 2874af749..ed5f09e20 100644 --- a/src/components/one-time-donation/helpers/validation-schema.ts +++ b/src/components/one-time-donation/helpers/validation-schema.ts @@ -18,27 +18,20 @@ export const validateFirst: yup.SchemaOf = yup }), }) -export const validateSecond: yup.SchemaOf = 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 = 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 = yup.object().defined().shape({ message: yup.string().notRequired(), - anonymous: yup.bool().required(), }) diff --git a/src/gql/donations.d.ts b/src/gql/donations.d.ts index 39979f393..0ad72dfca 100644 --- a/src/gql/donations.d.ts +++ b/src/gql/donations.d.ts @@ -21,6 +21,7 @@ export type CheckoutSessionInput = { firstName?: string lastName?: string personEmail?: string + isAnonymous: boolean phone?: string | null } @@ -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 @@ -123,7 +123,7 @@ export type FirstStep = { } export type SecondStep = { - anonymousDonation?: boolean + isAnonymous: boolean personsFirstName?: string personsLastName?: string personsPhone?: string @@ -132,7 +132,6 @@ export type SecondStep = { export type ThirdStep = { message?: string - anonymous: boolean } export type BankTransactionsUploadImage = { bankTransactionsFileId: string