diff --git a/README.md b/README.md
index 1a25cd68c..f7b857938 100644
--- a/README.md
+++ b/README.md
@@ -100,7 +100,9 @@ Watch releases of this repository to be notified about future updates:
## Contributors ✨
+
[![All Contributors](https://img.shields.io/badge/all_contributors-73-orange.svg?style=flat-square)](#contributors-)
+
Please check [contributors guide](https://github.com/podkrepi-bg/frontend/blob/master/CONTRIBUTING.md) for:
diff --git a/public/locales/bg/auth.json b/public/locales/bg/auth.json
index de309d026..fd2880268 100644
--- a/public/locales/bg/auth.json
+++ b/public/locales/bg/auth.json
@@ -2,6 +2,7 @@
"alerts": {
"welcome": "Добре дошли!",
"invalid-login": "Грешен потребител / парола.",
+ "register-error": "Моля, попълнете необходимата информация",
"duplicate-email": "Потребител с такъв имейл вече съществува",
"re-login": "Моля, влезте отново в профила си.",
"forgotten-password-error": "Потребителя не е намерен, моля опитайте отново!",
diff --git a/public/locales/en/auth.json b/public/locales/en/auth.json
index 88246118b..d03645475 100644
--- a/public/locales/en/auth.json
+++ b/public/locales/en/auth.json
@@ -2,6 +2,7 @@
"alerts": {
"welcome": "Welcome!",
"invalid-login": "Wrong username / password.",
+ "register-error": "Please, fill in the necessary information",
"re-login": "Please login into your account.",
"forgotten-password-error": "User not found, please try again!",
"forgotten-password-success": "Please check your email!",
diff --git a/src/common/form/validation.ts b/src/common/form/validation.ts
index 40c4ec54f..9de30a63e 100644
--- a/src/common/form/validation.ts
+++ b/src/common/form/validation.ts
@@ -44,6 +44,8 @@ export const customValidators = {
phone: () => ({ key: 'validation:phone' }),
name: () => ({ key: 'validation:invalid' }),
paymentRef: () => ({ key: 'validation:payment-reference' }),
+ terms: () => ({ key: 'validation:terms-of-use' }),
+ gdpr: () => ({ key: 'validation:terms-of-service' }),
}
setLocale({
diff --git a/src/components/client/one-time-donation/RegisterDialog.tsx b/src/components/client/one-time-donation/RegisterDialog.tsx
index c100f111d..d1f0dab29 100644
--- a/src/components/client/one-time-donation/RegisterDialog.tsx
+++ b/src/components/client/one-time-donation/RegisterDialog.tsx
@@ -1,4 +1,4 @@
-import { Button, CircularProgress, Grid, Typography } from '@mui/material'
+import { Button, CircularProgress, FormHelperText, Grid, Typography } from '@mui/material'
import React, { useContext, useState } from 'react'
import { signIn } from 'next-auth/react'
import { useTranslation } from 'next-i18next'
@@ -12,6 +12,9 @@ import { useFormikContext } from 'formik'
import { OneTimeDonation } from 'gql/donations'
import { RegisterFormData } from 'components/client/auth/register/RegisterForm'
import { StepsContext } from './helpers/stepperContext'
+import AcceptPrivacyPolicyField from 'components/common/form/AcceptPrivacyPolicyField'
+import AcceptTermsField from 'components/common/form/AcceptTermsField'
+import AcceptNewsLetterField from 'components/common/form/AcceptNewsletterField'
export default function RegisterForm() {
const { t } = useTranslation()
@@ -28,13 +31,22 @@ export default function RegisterForm() {
confirmPassword: formik.values.confirmPassword as string,
terms: formik.values.terms as boolean,
gdpr: formik.values.gdpr as boolean,
+ newsletter: formik.values.newsletter as boolean,
}
const onClick = async () => {
try {
setLoading(true)
-
// Register in Keycloak
- await register(values)
+
+ if (values.terms && values.gdpr && values.password === values.confirmPassword) {
+ await register(values)
+ } else if (!values.terms) {
+ throw new Error('Terms not accepted')
+ } else if (!values.gdpr) {
+ throw new Error('GDPR not accepted')
+ } else {
+ throw new Error('Confirm password doesn`t match')
+ }
// Authenticate
const resp = await signIn<'credentials'>('credentials', {
@@ -42,6 +54,7 @@ export default function RegisterForm() {
password: values.password,
redirect: false,
})
+
if (resp?.error) {
throw new Error(resp.error)
}
@@ -54,7 +67,7 @@ export default function RegisterForm() {
} catch (error) {
console.error(error)
setLoading(false)
- AlertStore.show(t('auth:alerts.invalid-login'), 'error')
+ AlertStore.show(t('auth:alerts.register-error'), 'error')
}
}
@@ -92,6 +105,25 @@ export default function RegisterForm() {
label="auth:account.confirm-password"
autoComplete="new-password"
/>
+ {formik.values.registerPassword !== formik.values.confirmPassword &&
+ formik.touched.confirmPassword && (
+
+ {t('validation:password-match')}
+
+ )}
+
+
+
+ {!formik.values.terms && formik.touched.terms && (
+ {t('validation:terms-of-use')}
+ )}
+
+ {!formik.values.gdpr && formik.touched.gdpr && (
+
+ {t('validation:terms-of-service')}
+
+ )}
+