From 4c74f55301c27f7c4b877c2fef9eecf5ebc31a4d Mon Sep 17 00:00:00 2001 From: "Georgi Ganchev @7DIGIT" Date: Fri, 28 Jun 2024 13:51:10 +0300 Subject: [PATCH] Refactor: Hide payment history for kz country in UserProfile --- src/blocks/UserProfile/UserProfile.jsx | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/blocks/UserProfile/UserProfile.jsx b/src/blocks/UserProfile/UserProfile.jsx index 3f935b2..4cb6516 100644 --- a/src/blocks/UserProfile/UserProfile.jsx +++ b/src/blocks/UserProfile/UserProfile.jsx @@ -1,12 +1,15 @@ import React, { useState, useEffect } from "react"; import { useNavigate } from "react-router-dom"; import { useTranslation } from "react-i18next"; +import { useQuery } from "@tanstack/react-query"; import { Block, Grid, GridItem, ButtonSelector, } from "@USupport-components-library/src"; + +import { countrySvc } from "@USupport-components-library/services"; import { useGetClientData } from "#hooks"; import "./user-profile.scss"; @@ -14,6 +17,13 @@ import "./user-profile.scss"; const AMAZON_S3_BUCKET = `${import.meta.env.VITE_AMAZON_S3_BUCKET}`; const GIT_BOOK_URL = `${import.meta.env.VITE_GIT_BOOK_URL}`; +const fetchCountry = async () => { + const { data } = await countrySvc.getActiveCountries(); + const currentCountryId = localStorage.getItem("country_id"); + const currentCountry = data.find((x) => x.country_id === currentCountryId); + return currentCountry?.alpha2 === "KZ" ? true : false; +}; + /** * UserProfile * @@ -30,6 +40,8 @@ export const UserProfile = ({ openModal, isTmpUser }) => { const clientQueryArray = useGetClientData(isTmpUser ? false : true); const clientData = isTmpUser ? {} : clientQueryArray[0].data; + const { data: isKzCountry } = useQuery(["is-kz-country"], fetchCountry); + useEffect(() => { if (clientData) { if (clientData.name && clientData.surname) { @@ -104,12 +116,14 @@ export const UserProfile = ({ openModal, isTmpUser }) => {

{t("other")}

- handleRedirect("payment-history")} - /> + {!isKzCountry && ( + handleRedirect("payment-history")} + /> + )}