Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions apps/www/app/_hooks/use-show-consent-banner.ts

This file was deleted.

14 changes: 9 additions & 5 deletions apps/www/app/layouts/root/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,22 @@ import { Figma } from '~/_components/logos/figma';
import { Github } from '~/_components/logos/github';
import { Slack } from '~/_components/logos/slack';
import { SearchDialog } from '~/_components/search-dialog';
import { useShowConsentBanner } from '~/_hooks/use-show-consent-banner';
import { CONSENT_VERSION, userConsent } from '~/_utils/cookies';
import i18n from '~/i18n';
import type { Route as RootRoute } from './../../+types/root';
import type { Route } from './+types/layout';

export const loader = ({ params }: Route.LoaderArgs) => {
export const loader = async ({ params, request }: Route.LoaderArgs) => {
if (!i18n.supportedLngs.includes(params.lang || '')) {
throw new Response('Not Found', {
status: 404,
});
}

const consent = await userConsent.parse(request.headers.get('Cookie'));
Comment thread
Barsnes marked this conversation as resolved.
Outdated
const showConsentBanner = !consent || consent.version !== CONSENT_VERSION;

return { showConsentBanner };
};

const rightLinks: FooterLinkListItemProps[] = [
Expand Down Expand Up @@ -49,7 +54,7 @@ const rightLinks: FooterLinkListItemProps[] = [
},
];

export default function RootLayout() {
export default function RootLayout({ loaderData }: Route.ComponentProps) {
const { t } = useTranslation();
const { lang, centerLinks, menu } = useRouteLoaderData('root') as Omit<
RootRoute.ComponentProps['loaderData'],
Expand All @@ -61,7 +66,6 @@ export default function RootLayout() {
href: string;
}[];
};
const { showBanner } = useShowConsentBanner();

useChangeLanguage(lang);

Expand All @@ -72,7 +76,7 @@ export default function RootLayout() {
return (
<>
<div>
{showBanner && <ConsentBanner lang={lang} />}
{loaderData?.showConsentBanner && <ConsentBanner lang={lang} />}
<SkipLink href='#main'>{t('accessibility.skip-link')}</SkipLink>
</div>
<Header
Expand Down
Loading