Skip to content

Commit

Permalink
add help us improve field to all registrations
Browse files Browse the repository at this point in the history
  • Loading branch information
kdachev97 committed Mar 14, 2024
1 parent b0c1908 commit 17f70be
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 7 deletions.
5 changes: 3 additions & 2 deletions public/locales/bg/validation.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
"legal-entity": "Юридическо лице",
"unique-field-violation": "Полето `{1}` със тази стойност вече съществува в платформата.",
"payment-reference": "Невалиден формат на кода за плащане",
"eik-invalid": "Невалидно ЕИК"
}
"eik-invalid": "Невалидно ЕИК",
"help-us-improve": "Искате ли да ни помогнете да подобрим платформата? Искаме да чуем вашето мнение? Отделете ни 30 мин за подобрите платформа на подкрепи.бг"
}
5 changes: 3 additions & 2 deletions public/locales/en/validation.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
"newsletter": "Please give your consent",
"unique-field-violation": "The field `{1}` with this value already exists in the platform.",
"payment-reference": "Invalid payment code format",
"eik-invalid": "Invalid EIK"
}
"eik-invalid": "Invalid EIK",
"help-us-improve": "Do you want to help us improve the platform? We want to hear from you? Please spare 30 mins to help us improve podkrepi.bg"
}
4 changes: 4 additions & 0 deletions src/components/client/auth/register/CorporateRegisterForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { AcceptNewsLetterField } from 'components/common/form/AcceptNewsletterFi
import { AccountType } from 'gql/user-registration'
import { validateEIK13, validateEIK9 } from 'components/common/validations/EIKValidator'
import { CorporateRegisterFormData } from 'gql/user-registration'
import HelpUsImproveField from 'components/common/form/HelpUsImproveField'

const validationSchema: yup.SchemaOf<CorporateRegisterFormData> = yup
.object()
Expand All @@ -39,6 +40,7 @@ const validationSchema: yup.SchemaOf<CorporateRegisterFormData> = yup
terms: yup.bool().required().oneOf([true], 'validation:terms-of-use'),
gdpr: yup.bool().required().oneOf([true], 'validation:terms-of-service'),
newsletter: yup.bool().required().oneOf([true, false]),
helpUsImprove: yup.bool().required().oneOf([true, false]),
})

export type RegisterFormProps = {
Expand All @@ -59,6 +61,7 @@ export default function CorporateRegisterForm({ onSubmit, loading }: RegisterFor
terms: false,
gdpr: false,
newsletter: false,
helpUsImprove: false,
}
return (
<GenericForm
Expand Down Expand Up @@ -115,6 +118,7 @@ export default function CorporateRegisterForm({ onSubmit, loading }: RegisterFor
<AcceptTermsField name="terms" />
<AcceptPrivacyPolicyField name="gdpr" />
<AcceptNewsLetterField name="newsletter" />
<HelpUsImproveField name='helpUsImprove' />
</Grid>
<Grid item xs={12}>
<SubmitButton fullWidth label="auth:cta.register" loading={loading} />
Expand Down
6 changes: 5 additions & 1 deletion src/components/client/auth/register/RegisterForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { AcceptNewsLetterField } from 'components/common/form/AcceptNewsletterFi

import { AccountType } from 'gql/user-registration'
import { IndividualRegisterFormData } from 'gql/user-registration'
import HelpUsImproveField from 'components/common/form/HelpUsImproveField'

const validationSchema: yup.SchemaOf<IndividualRegisterFormData> = yup
.object()
Expand All @@ -27,6 +28,7 @@ const validationSchema: yup.SchemaOf<IndividualRegisterFormData> = yup
terms: yup.bool().required().oneOf([true], 'validation:terms-of-use'),
gdpr: yup.bool().required().oneOf([true], 'validation:terms-of-service'),
newsletter: yup.bool().required().oneOf([true, false]),
helpUsImprove: yup.bool().required().oneOf([true, false]),
})

export type RegisterFormProps = {
Expand All @@ -45,6 +47,7 @@ export default function RegisterForm({ onSubmit, loading }: RegisterFormProps) {
terms: false,
gdpr: false,
newsletter: false,
helpUsImprove: false,
}
return (
<GenericForm
Expand Down Expand Up @@ -85,11 +88,12 @@ export default function RegisterForm({ onSubmit, loading }: RegisterFormProps) {
<AcceptTermsField name="terms" />
<AcceptPrivacyPolicyField name="gdpr" />
<AcceptNewsLetterField name="newsletter" />
<HelpUsImproveField name='helpUsImprove' />
</Grid>
<Grid item xs={12}>
<SubmitButton fullWidth label="auth:cta.register" loading={loading} />
</Grid>
</Grid>
</GenericForm>
)
}
}
27 changes: 27 additions & 0 deletions src/components/common/form/HelpUsImproveField.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { useTranslation } from 'next-i18next'
import { Typography } from '@mui/material'

// import { routes } from 'common/routes'
// import ExternalLink from 'components/common/ExternalLink'
import CheckboxField from 'components/common/form/CheckboxField'

export type HelpUsImproveFieldProps = {
name: string
}

export default function HelpUsImproveField({ name }: HelpUsImproveFieldProps) {
const { t } = useTranslation()
return (
<CheckboxField
name={name}
label={
<Typography variant="body2">
{t('validation:help-us-improve')}{' '}
{/* <ExternalLink href={routes.helpUsImprove}>
{t('validation:help-us-improve')}
</ExternalLink> */}
</Typography>
}
/>
)
}
5 changes: 3 additions & 2 deletions src/gql/user-registration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ export type IndividualRegisterFormData = {
confirmPassword: string
terms: boolean
gdpr: boolean
newsletter?: boolean
newsletter?: boolean,
helpUsImprove?: boolean,
}

export type CorporateRegisterFormData = IndividualRegisterFormData & {
companyName: string
companyNumber: string
}
}

0 comments on commit 17f70be

Please sign in to comment.