diff --git a/packages/ui/src/components/Routes/NotFoundPage.tsx b/packages/ui/src/components/Routes/NotFoundPage.tsx index a95dd4df4..afcf50f2d 100644 --- a/packages/ui/src/components/Routes/NotFoundPage.tsx +++ b/packages/ui/src/components/Routes/NotFoundPage.tsx @@ -1,12 +1,9 @@ -'use client'; -import { NotFoundPageQuery, useLocalized } from '@custom/schema'; +import { NotFoundPageQuery, useLocalized, withOperation } from '@custom/schema'; import React from 'react'; -import { useOperation } from '../../utils/operation'; import { PageDisplay } from '../Organisms/PageDisplay'; -export function NotFoundPage() { - const { data } = useOperation(NotFoundPageQuery); - const page = useLocalized(data?.websiteSettings?.notFoundPage?.translations); +export const NotFoundPage = withOperation(NotFoundPageQuery, ({operationResult}) => { + const page = useLocalized(operationResult.websiteSettings?.notFoundPage?.translations); return page ? :
; } diff --git a/packages/ui/src/components/Routes/Page.tsx b/packages/ui/src/components/Routes/Page.tsx index 318ce7d9b..dfd46e714 100644 --- a/packages/ui/src/components/Routes/Page.tsx +++ b/packages/ui/src/components/Routes/Page.tsx @@ -1,27 +1,36 @@ -'use client'; -import { useLocation, ViewPageQuery } from '@custom/schema'; +import { useLocation, ViewPageQuery, withOperation } from '@custom/schema'; import React from 'react'; import { isTruthy } from '../../utils/isTruthy'; -import { useOperation } from '../../utils/operation'; import { Translations } from '../../utils/translations'; import { PageDisplay } from '../Organisms/PageDisplay'; +export const PageWithData = withOperation( + ViewPageQuery, + ({ operationResult }) => { + // Initialize the language switcher with the options this page has. + const translations = Object.fromEntries( + operationResult?.page?.translations + ?.filter(isTruthy) + .map((translation) => [translation.locale, translation.path]) || [], + ); + return operationResult?.page ? ( + + + + ) : null; + }, +); + export function Page() { // Retrieve the current location and load the page // behind it. const [loc] = useLocation(); - const { data } = useOperation(ViewPageQuery, { pathname: loc.pathname }); - - // Initialize the language switcher with the options this page has. - const translations = Object.fromEntries( - data?.page?.translations - ?.filter(isTruthy) - .map((translation) => [translation.locale, translation.path]) || [], + return ( + ); - return data?.page ? ( - - - - ) : null; }