From 1e2ba82c1b5fa3f182abfcefeb8f30b49fa64303 Mon Sep 17 00:00:00 2001 From: cesarLima1 Date: Mon, 30 Dec 2024 15:53:17 -0400 Subject: [PATCH] [TM-1568] change text for logged users --- .../extensive/BlurContainer/BlurContainer.tsx | 44 +++++++++++++++++-- .../extensive/PageElements/Card/PageCard.tsx | 7 ++- src/constants/dashboardConsts.ts | 8 +++- .../dashboard/components/SecDashboard.tsx | 17 +++---- src/pages/dashboard/index.page.tsx | 6 +-- 5 files changed, 61 insertions(+), 21 deletions(-) diff --git a/src/components/extensive/BlurContainer/BlurContainer.tsx b/src/components/extensive/BlurContainer/BlurContainer.tsx index 98b2e88dc..19b4105e9 100644 --- a/src/components/extensive/BlurContainer/BlurContainer.tsx +++ b/src/components/extensive/BlurContainer/BlurContainer.tsx @@ -1,17 +1,23 @@ +import { useT } from "@transifex/react"; import React from "react"; import { When } from "react-if"; import { twMerge as tw } from "tailwind-merge"; import Text from "@/components/elements/Text/Text"; +import { TEXT_TYPES } from "@/constants/dashboardConsts"; +import { useLogout } from "@/hooks/logout"; export interface BlurContainerProps { isBlur: boolean; - textInformation?: string | React.ReactNode; + textType?: string; children: React.ReactNode; className?: string; } -const BlurContainer = ({ isBlur, textInformation, children, className, ...props }: BlurContainerProps) => { +const BlurContainer = ({ isBlur, textType, children, className }: BlurContainerProps) => { + const t = useT(); + const logout = useLogout(); + if (!isBlur) { return <>{children}; } @@ -31,6 +37,36 @@ const BlurContainer = ({ isBlur, textInformation, children, className, ...props ); + const ProjectAccessText = () => ( + <> + {" "} + with an account associated with this project + + ); + + const NoDataText = () => ( + + {t( + "Data is still being collected and checked. This visual will remain empty until data is properly quality assured." + )} + + ); + + const renderText = () => { + switch (textType) { + case TEXT_TYPES.LOGGED_USER: + return ; + case TEXT_TYPES.NOT_LOGGED_USER: + return ; + case TEXT_TYPES.NO_DATA: + return ; + default: + return null; + } + }; + return (
- + - {typeof textInformation === "string" ? textInformation : } + {renderText()}
diff --git a/src/components/extensive/PageElements/Card/PageCard.tsx b/src/components/extensive/PageElements/Card/PageCard.tsx index 4336ad5ac..2c0612a15 100644 --- a/src/components/extensive/PageElements/Card/PageCard.tsx +++ b/src/components/extensive/PageElements/Card/PageCard.tsx @@ -9,7 +9,7 @@ import Paper from "@/components/elements/Paper/Paper"; import Text from "@/components/elements/Text/Text"; import ToolTip from "@/components/elements/Tooltip/Tooltip"; import { useMyUser } from "@/connections/User"; -import { NO_DATA_INFORMATION } from "@/constants/dashboardConsts"; +import { TEXT_TYPES } from "@/constants/dashboardConsts"; import { withFrameworkShow } from "@/context/framework.provider"; import { TextVariants } from "@/types/common"; @@ -70,7 +70,10 @@ const PageCard = ({ return ( - }> +
diff --git a/src/constants/dashboardConsts.ts b/src/constants/dashboardConsts.ts index 71f1f109e..3de691340 100644 --- a/src/constants/dashboardConsts.ts +++ b/src/constants/dashboardConsts.ts @@ -38,10 +38,14 @@ export const ORGANIZATIONS_TYPES = { "for-profit-organization": "Enterprise" }; -export const NO_DATA_INFORMATION = "No data available. You may not have permission to view the project profile."; - export const TERRAFUND_MONITORING_LINK = "https://www.wri.org/update/land-degradation-project-recipe-for-restoration"; +export const TEXT_TYPES = { + LOGGED_USER: "textForLoggedUser", + NOT_LOGGED_USER: "textForNotLoggedUser", + NO_DATA: "noData" +}; + export const TERRAFUND_MRV_LINK = `TerraFund's MRV framework`; export const DEFAULT_POLYGONS_DATA = { diff --git a/src/pages/dashboard/components/SecDashboard.tsx b/src/pages/dashboard/components/SecDashboard.tsx index fcdc432e8..77060009e 100644 --- a/src/pages/dashboard/components/SecDashboard.tsx +++ b/src/pages/dashboard/components/SecDashboard.tsx @@ -18,7 +18,8 @@ import { DUMMY_DATA_FOR_CHART_GROUPED_BAR_CHART_GENDER, DUMMY_DATA_FOR_CHART_MULTI_LINE_CHART, DUMMY_DATA_FOR_CHART_SIMPLE_BAR_CHART, - DUMMY_DATA_TARGET_LAND_USE_TYPES_REPRESENTED + DUMMY_DATA_TARGET_LAND_USE_TYPES_REPRESENTED, + TEXT_TYPES } from "@/constants/dashboardConsts"; import { TextVariants } from "@/types/common"; import { getRestorationGoalDataForChart, getRestorationGoalResumeData, isEmptyChartData } from "@/utils/dashboardUtils"; @@ -84,10 +85,6 @@ const SecDashboard = ({ const [treesPlantedByYear, setTreesPlantedByYear] = useState<{ name: string; values: any }[]>([]); const t = useT(); - const noDataInformation = t( - "Data is still being collected and checked. This visual will remain empty until data is properly quality assured." - ); - const tableColumns = [ { header: isTableProject ? "Organization" : "Specie", @@ -179,7 +176,7 @@ const SecDashboard = ({ { } + textType={user !== undefined ? TEXT_TYPES.LOGGED_USER : TEXT_TYPES.NOT_LOGGED_USER} >
{dashboardHeader.map((item, index) => (