Skip to content

Commit

Permalink
feat(newsletter): n'affiche pas Follow sur les pages newsletter_
Browse files Browse the repository at this point in the history
  • Loading branch information
slafayIGN committed Sep 30, 2024
1 parent 4a6b476 commit c8f6c2f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
13 changes: 12 additions & 1 deletion assets/components/Layout/AppFollow.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import { memo } from "react";
import Follow from "@codegouvfr/react-dsfr/Follow";
import { routes } from "../../router/router";
import { routes, useRoute } from "../../router/router";

const AppFollow = () => {
const newsletterSubscribeAction = (document.getElementById("app_env") as HTMLDivElement)?.dataset?.["newsletterSubscribeAction"] ?? null;
const route = useRoute();

if (newsletterSubscribeAction === null) {
return null;
}

if (typeof route.name === "string" && /^newsletter_/.test(route.name)) {
return null;
}

return (
<Follow
newsletter={{
Expand Down
4 changes: 1 addition & 3 deletions assets/components/Layout/AppLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ const AppLayout: FC<PropsWithChildren<AppLayoutProps>> = ({ children, navItems,
return getBreadcrumb(route, datastoreQuery.data);
}, [route, datastoreQuery.data, customBreadcrumbProps]);

const newsletterSubscribeAction = (document.getElementById("app_env") as HTMLDivElement)?.dataset?.["newsletterSubscribeAction"] ?? null;

navItems = useMemo(() => navItems ?? defaultNavItems(t), [navItems, t]);

return (
Expand All @@ -93,7 +91,7 @@ const AppLayout: FC<PropsWithChildren<AppLayoutProps>> = ({ children, navItems,
{children}
</div>
</main>
{newsletterSubscribeAction !== null && <AppFollow />}
<AppFollow />
<AppFooter />
<SnackbarMessage />
</>
Expand Down

0 comments on commit c8f6c2f

Please sign in to comment.