Skip to content

Commit

Permalink
fix(organizations): Add notice if organization is closed
Browse files Browse the repository at this point in the history
  • Loading branch information
annelhote committed Oct 15, 2024
1 parent 51aadc1 commit 1bf5584
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 14 deletions.
36 changes: 24 additions & 12 deletions client/src/pages/organizations/[id]/index.tsx
Original file line number Diff line number Diff line change
@@ -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],
Expand All @@ -29,11 +37,17 @@ export default function Organization() {
});
return (
<RawIntlProvider value={intl}>
{(data?.isFrench === false) && (
{!data?.isFrench && (
<Notice closeMode="disallow" type="warning">
{intl.formatMessage({ id: "organizations.notice.not-french" })}
</Notice>
)}
{data?.endDate && (
<Notice closeMode="disallow" type="warning">
{intl.formatMessage({ id: "organizations.notice.closed" })}{" "}
{data.endDate.slice(0, 4)}.
</Notice>
)}
<Container>
<Breadcrumb>
<Link href="/">
Expand All @@ -42,13 +56,11 @@ export default function Organization() {
<Link href="/search/organizations">
{intl.formatMessage({ id: "organizations.breadcrumb.search" })}
</Link>
<Link>
{getLangFieldValue(locale)(data?.label)}
</Link>
<Link>{getLangFieldValue(locale)(data?.label)}</Link>
</Breadcrumb>
{(isLoading || !data?.id) && <PageSkeleton />}
{(data?.id) && <OrganizationPresentation data={data} />}
{data?.id && <OrganizationPresentation data={data} />}
</Container>
</RawIntlProvider>
)
}
);
}
1 change: 1 addition & 0 deletions client/src/pages/organizations/[id]/locales/de.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
3 changes: 2 additions & 1 deletion client/src/pages/organizations/[id]/locales/en.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
3 changes: 2 additions & 1 deletion client/src/pages/organizations/[id]/locales/es.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
1 change: 1 addition & 0 deletions client/src/pages/organizations/[id]/locales/fr.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 1bf5584

Please sign in to comment.