From a25736402c937574269967ac9bdf174edaa28730 Mon Sep 17 00:00:00 2001 From: Georgi 7DIGIT Date: Thu, 28 Nov 2024 22:02:52 +0200 Subject: [PATCH] Refactor: the age agreement to display the minAge from the DB --- .../RegisterAnonymous/RegisterAnonymous.jsx | 15 +++++++++++---- src/blocks/RegisterAnonymous/locales/en.json | 2 +- src/blocks/RegisterAnonymous/locales/kk.json | 2 +- src/blocks/RegisterAnonymous/locales/pl.json | 2 +- src/blocks/RegisterAnonymous/locales/ru.json | 2 +- src/blocks/RegisterAnonymous/locales/uk.json | 2 +- src/blocks/RegisterEmail/RegisterEmail.jsx | 13 ++++++++++--- src/blocks/RegisterEmail/locales/en.json | 2 +- src/blocks/RegisterEmail/locales/kk.json | 2 +- src/blocks/RegisterEmail/locales/pl.json | 2 +- src/blocks/RegisterEmail/locales/ru.json | 2 +- src/blocks/RegisterEmail/locales/uk.json | 2 +- 12 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/blocks/RegisterAnonymous/RegisterAnonymous.jsx b/src/blocks/RegisterAnonymous/RegisterAnonymous.jsx index beb6e989..8e862835 100644 --- a/src/blocks/RegisterAnonymous/RegisterAnonymous.jsx +++ b/src/blocks/RegisterAnonymous/RegisterAnonymous.jsx @@ -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"; @@ -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() @@ -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 () => { @@ -256,11 +263,11 @@ export const RegisterAnonymous = () => { textFour={t("terms_agreement_text_4")} Link={Link} /> - {/* handleChange("isAgeTermsSelected", val)} - textOne={t("age_terms_agreement_text_1")} - /> */} + textOne={t("age_terms_agreement_text_1", { age: minAge })} + />