From 1bf5584946881ab5d1ab67fac1dd1203ac276a99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anne=20L=27H=C3=B4te?= Date: Tue, 15 Oct 2024 10:51:36 +0200 Subject: [PATCH] fix(organizations): Add notice if organization is closed --- client/src/pages/organizations/[id]/index.tsx | 36 ++++++++++++------- .../pages/organizations/[id]/locales/de.json | 1 + .../pages/organizations/[id]/locales/en.json | 3 +- .../pages/organizations/[id]/locales/es.json | 3 +- .../pages/organizations/[id]/locales/fr.json | 1 + 5 files changed, 30 insertions(+), 14 deletions(-) diff --git a/client/src/pages/organizations/[id]/index.tsx b/client/src/pages/organizations/[id]/index.tsx index b7e81f7c..cffc0c21 100644 --- a/client/src/pages/organizations/[id]/index.tsx +++ b/client/src/pages/organizations/[id]/index.tsx @@ -1,26 +1,34 @@ import { useParams } from "react-router-dom"; import { useQuery } from "@tanstack/react-query"; -import { Breadcrumb, Container, Link, Notice, useDSFRConfig } from "@dataesr/dsfr-plus"; +import { + Breadcrumb, + Container, + Link, + Notice, + useDSFRConfig, +} from "@dataesr/dsfr-plus"; import PageSkeleton from "../../../components/skeleton/page-skeleton"; import OrganizationPresentation from "./components/organization"; import { getOrganizationById } from "../../../api/organizations/[id]"; import getLangFieldValue from "../../../utils/lang"; import { RawIntlProvider, createIntl } from "react-intl"; -const modules = import.meta.glob('./locales/*.json', { eager: true, import: 'default' }) +const modules = import.meta.glob("./locales/*.json", { + eager: true, + import: "default", +}); const messages = Object.keys(modules).reduce((acc, key) => { const locale = key.match(/\.\/locales\/(.+)\.json$/)?.[1]; if (locale) { - return { ...acc, [locale]: modules[key] } + return { ...acc, [locale]: modules[key] }; } return acc; }, {}); - export default function Organization() { const { locale } = useDSFRConfig(); - const intl = createIntl({ locale, messages: messages[locale] }) + const intl = createIntl({ locale, messages: messages[locale] }); const { id } = useParams(); const { data, isLoading } = useQuery({ queryKey: ["organizations", id], @@ -29,11 +37,17 @@ export default function Organization() { }); return ( - {(data?.isFrench === false) && ( + {!data?.isFrench && ( {intl.formatMessage({ id: "organizations.notice.not-french" })} )} + {data?.endDate && ( + + {intl.formatMessage({ id: "organizations.notice.closed" })}{" "} + {data.endDate.slice(0, 4)}. + + )} @@ -42,13 +56,11 @@ export default function Organization() { {intl.formatMessage({ id: "organizations.breadcrumb.search" })} - - {getLangFieldValue(locale)(data?.label)} - + {getLangFieldValue(locale)(data?.label)} {(isLoading || !data?.id) && } - {(data?.id) && } + {data?.id && } - ) -} \ No newline at end of file + ); +} diff --git a/client/src/pages/organizations/[id]/locales/de.json b/client/src/pages/organizations/[id]/locales/de.json index b170b1fa..59648d82 100644 --- a/client/src/pages/organizations/[id]/locales/de.json +++ b/client/src/pages/organizations/[id]/locales/de.json @@ -1,5 +1,6 @@ { "organizations.notice.not-french": "Achtung, da es sich um eine ausländische Entität handelt, werden nur ihre Verbindungen zu französischen Organisationen, Finanzierungen und Produktionen angezeigt.", + "organizations.notice.closed": "Achtung, diese Entität ist geschlossen seit", "organizations.breadcrumb.home": "Startseite", "organizations.breadcrumb.search": "Strukturen", "organizations.section.leaders.title": "Führungsteam", diff --git a/client/src/pages/organizations/[id]/locales/en.json b/client/src/pages/organizations/[id]/locales/en.json index 4db77c5e..bb168197 100644 --- a/client/src/pages/organizations/[id]/locales/en.json +++ b/client/src/pages/organizations/[id]/locales/en.json @@ -1,5 +1,6 @@ { - "organizations.notice.not-french": "Attention, this entity being a foreign entity, only its connections with French organizations, funding, and productions will be displayed.", + "organizations.notice.not-french": "Please note that this entity being a foreign entity, only its connections with French organizations, funding, and productions will be displayed.", + "organizations.notice.closed": "Please note that this entity has been closed since", "organizations.breadcrumb.home": "Home", "organizations.breadcrumb.search": "Organizations", "organizations.section.leaders.title": "Leadership team", diff --git a/client/src/pages/organizations/[id]/locales/es.json b/client/src/pages/organizations/[id]/locales/es.json index e4fc304c..83e3aa40 100644 --- a/client/src/pages/organizations/[id]/locales/es.json +++ b/client/src/pages/organizations/[id]/locales/es.json @@ -1,5 +1,6 @@ { - "organizations.notice.not-french": "Atención, al tratarse de una entidad extranjera, solo se mostrarán sus conexiones con organizaciones, financiamientos y producciones francesas.", + "organizations.notice.not-french": "Tenga al tratarse de una entidad extranjera, solo se mostrarán sus conexiones con organizaciones, financiamientos y producciones francesas.", + "organizations.notice.closed": "Tenga en cuenta que esta entidad lleva cerrada desde", "organizations.breadcrumb.home": "Inicio", "organizations.breadcrumb.search": "Estructuras", "organizations.section.leaders.title": "Equipo Directivo", diff --git a/client/src/pages/organizations/[id]/locales/fr.json b/client/src/pages/organizations/[id]/locales/fr.json index 1c342013..1ca4e485 100644 --- a/client/src/pages/organizations/[id]/locales/fr.json +++ b/client/src/pages/organizations/[id]/locales/fr.json @@ -1,5 +1,6 @@ { "organizations.notice.not-french": "Attention, cette entité étant une entité étrangère, seuls ses liens avec des organisations, financements et productions françaises seront affichées.", + "organizations.notice.closed": "Attention, cette entité est fermée depuis", "organizations.breadcrumb.home": "Accueil", "organizations.breadcrumb.search": "Structures", "organizations.section.leaders.title": "Équipe de direction",