Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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.

20 changes: 9 additions & 11 deletions apps/www/app/layouts/root/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,15 @@ 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 i18n from '~/i18n';
import { hasConsent } from '~/_utils/consent.client';
import type { Route as RootRoute } from './../../+types/root';
import type { Route } from './+types/layout';

export const loader = ({ params }: Route.LoaderArgs) => {
if (!i18n.supportedLngs.includes(params.lang || '')) {
throw new Response('Not Found', {
status: 404,
});
}
export const clientLoader = async () => {
const showConsentBanner = !(await hasConsent());
return { showConsentBanner };
};
clientLoader.hydrate = true as const;

const rightLinks: FooterLinkListItemProps[] = [
{
Expand All @@ -49,7 +46,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 +58,6 @@ export default function RootLayout() {
href: string;
}[];
};
const { showBanner } = useShowConsentBanner();

useChangeLanguage(lang);

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