Skip to content

Commit

Permalink
Merge branch 'development' of github.com:UNICEFECAR/USupport-client-u…
Browse files Browse the repository at this point in the history
…i into staging
  • Loading branch information
vasilen-7DIGIT committed Nov 28, 2024
2 parents 0bef78b + 3b76212 commit 4e61475
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 17 deletions.
15 changes: 11 additions & 4 deletions src/blocks/RegisterAnonymous/RegisterAnonymous.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from "react";
import { useNavigate, Link } from "react-router-dom";
import { useMutation, useQuery } from "@tanstack/react-query";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { useTranslation } from "react-i18next";
import { toast } from "react-toastify";
import Joi from "joi";
Expand Down Expand Up @@ -36,6 +36,9 @@ import "./register-anonymous.scss";
export const RegisterAnonymous = () => {
const navigate = useNavigate();
const { t } = useTranslation("register-anonymous");
const queryClient = useQueryClient();

const countriesData = queryClient.getQueryData(["countries"]);

const schema = Joi.object({
password: Joi.string()
Expand All @@ -60,6 +63,10 @@ export const RegisterAnonymous = () => {
const [isConfirmationModalOpen, setIsConfirmationModalOpen] = useState(false);
const [hasCopied, setHasCopied] = useState(false);

const country = localStorage.getItem("country");
const selectedCountry = countriesData?.find((c) => c.value === country);
const minAge = selectedCountry?.minAge;

// On page load send a request to the server
// to generate a user acces token
const fetchUserAccessToken = async () => {
Expand Down Expand Up @@ -256,11 +263,11 @@ export const RegisterAnonymous = () => {
textFour={t("terms_agreement_text_4")}
Link={Link}
/>
{/* <TermsAgreement
<TermsAgreement
isChecked={data.isAgeTermsSelected}
setIsChecked={(val) => handleChange("isAgeTermsSelected", val)}
textOne={t("age_terms_agreement_text_1")}
/> */}
textOne={t("age_terms_agreement_text_1", { age: minAge })}
/>
<Button
label={t("register_button_label")}
size="lg"
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/RegisterAnonymous/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
"copy_success": "Code copied successfully",
"confirm_password_label": "Confirm password",
"password_match_error": "The Password and Confirm Password fields do not match",
"age_terms_agreement_text_1": "I am over 13 years old"
"age_terms_agreement_text_1": "I am over {{age}} years old"
}
2 changes: 1 addition & 1 deletion src/blocks/RegisterAnonymous/locales/kk.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
"copy_success": "Сәтті көшірілген код",
"confirm_password_label": "Құпия сөзді растаңыз",
"password_match_error": "Құпия сөз және Құпия сөзді растау өрістері сәйкес келмейді",
"age_terms_agreement_text_1": "Менің жасым 13-тен үлкен"
"age_terms_agreement_text_1": "Менің жасым 10-нан үлкен"
}
2 changes: 1 addition & 1 deletion src/blocks/RegisterAnonymous/locales/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
"copy_success": "Kod został pomyślnie skopiowany",
"confirm_password_label": "Potwierdź hasło",
"password_match_error": "Pola Hasło i Potwierdź hasło nie są zgodne",
"age_terms_agreement_text_1": "Mam ponad 13 lat"
"age_terms_agreement_text_1": "Mam ponad {{age}} lat"
}
2 changes: 1 addition & 1 deletion src/blocks/RegisterAnonymous/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
"copy_success": "Успешно скопированный код",
"confirm_password_label": "Подтвердите пароль",
"password_match_error": "Поля Пароль и Подтвердите пароль не совпадают",
"age_terms_agreement_text_1": "Мне больше 13 лет"
"age_terms_agreement_text_1": "Мне больше {{age}} лет"
}
2 changes: 1 addition & 1 deletion src/blocks/RegisterAnonymous/locales/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
"copy_success": "Код скопійовано",
"confirm_password_label": "Підтвердити пароль",
"password_match_error": "Поля «Пароль» і «Підтвердити пароль» не збігаються",
"age_terms_agreement_text_1": "Мені більше 13 років"
"age_terms_agreement_text_1": "Мені більше {{age}} років"
}
13 changes: 10 additions & 3 deletions src/blocks/RegisterEmail/RegisterEmail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useState } from "react";
import { useTranslation } from "react-i18next";
import { useNavigate, Link } from "react-router-dom";
import ReCAPTCHA from "react-google-recaptcha";
import { useQueryClient } from "@tanstack/react-query";

import Joi from "joi";

Expand Down Expand Up @@ -40,6 +41,8 @@ export const RegisterEmail = ({
}) => {
const { t } = useTranslation("register-email");
const navigate = useNavigate();
const queryClient = useQueryClient();
const countriesData = queryClient.getQueryData(["countries"]);

const schema = Joi.object({
password: Joi.string()
Expand All @@ -58,6 +61,10 @@ export const RegisterEmail = ({

const [errors, setErrors] = useState({});

const country = localStorage.getItem("country");
const selectedCountry = countriesData?.find((c) => c.value === country);
const minAge = selectedCountry?.minAge;

const handleChange = (field, value) => {
if (
field === "confirmPassword" &&
Expand Down Expand Up @@ -163,11 +170,11 @@ export const RegisterEmail = ({
textFour={t("terms_agreement_text_4")}
Link={Link}
/>
{/* <TermsAgreement
<TermsAgreement
isChecked={data.isAgeTermsSelected}
setIsChecked={(val) => handleChange("isAgeTermsSelected", val)}
textOne={t("age_terms_agreement_text_1")}
/> */}
textOne={t("age_terms_agreement_text_1", { age: minAge })}
/>
{showCaptcha && (
<ReCAPTCHA
sitekey={RECAPTCHA_SITE_KEY}
Expand Down
2 changes: 1 addition & 1 deletion src/blocks/RegisterEmail/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
"login_button_label": "I already have an account",
"confirm_password_label": "Confirm password",
"password_match_error": "The Password and Confirm Password fields do not match",
"age_terms_agreement_text_1": "I am over 13 years old"
"age_terms_agreement_text_1": "I am over {{age}} years old"
}
2 changes: 1 addition & 1 deletion src/blocks/RegisterEmail/locales/kk.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
"login_button_label": "Менің аккаунтым бар",
"confirm_password_label": "Құпия сөзді растаңыз",
"password_match_error": "Құпия сөз және Құпия сөзді растау өрістері сәйкес келмейді",
"age_terms_agreement_text_1": "Менің жасым 13-тен үлкен"
"age_terms_agreement_text_1": "Менің жасым 10-нан үлкен"
}
2 changes: 1 addition & 1 deletion src/blocks/RegisterEmail/locales/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
"login_button_label": "Już posiadam konto",
"confirm_password_label": "Potwierdź hasło",
"password_match_error": "Pola Hasło i Potwierdź hasło nie są zgodne",
"age_terms_agreement_text_1": "Mam ponad 13 lat"
"age_terms_agreement_text_1": "Mam ponad {{age}} lat"
}
2 changes: 1 addition & 1 deletion src/blocks/RegisterEmail/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
"login_button_label": "У меня уже есть аккаунт",
"confirm_password_label": "Подтвердите пароль",
"password_match_error": "Поля Пароль и Подтвердите пароль не совпадают",
"age_terms_agreement_text_1": "Мне больше 13 лет"
"age_terms_agreement_text_1": "Мне больше {{age}} лет"
}
2 changes: 1 addition & 1 deletion src/blocks/RegisterEmail/locales/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
"login_button_label": "Вже маю обліковий запис",
"confirm_password_label": "Підтвердити пароль",
"password_match_error": "Поля «Пароль» і «Підтвердити пароль» не збігаються",
"age_terms_agreement_text_1": "Мені більше 13 років"
"age_terms_agreement_text_1": "Мені більше {{age}} років"
}

0 comments on commit 4e61475

Please sign in to comment.