diff --git a/src/features/footer/Footer.tsx b/src/features/footer/Footer.tsx
index 2757492c91..95d179f744 100644
--- a/src/features/footer/Footer.tsx
+++ b/src/features/footer/Footer.tsx
@@ -1,20 +1,33 @@
-import React, { useMemo } from 'react';
+import React from 'react';
+import { useQuery } from '@tanstack/react-query';
import cn from 'classnames';
import { AltinnLogo, LogoColor } from 'src/components/logo/AltinnLogo';
+import { useAppQueries } from 'src/core/contexts/AppQueriesProvider';
import { ContextNotProvided } from 'src/core/contexts/context';
+import { DisplayError } from 'src/core/errorHandling/DisplayError';
import { useLaxApplicationMetadata } from 'src/features/applicationMetadata/ApplicationMetadataProvider';
import { createFooterComponent } from 'src/features/footer';
import classes from 'src/features/footer/Footer.module.css';
-import { useFooterLayout } from 'src/features/footer/FooterLayoutProvider';
export const Footer = () => {
- const footerLayout = useFooterLayout();
+ const { fetchFooterLayout } = useAppQueries();
+ const { data, error: footerLayoutError } = useQuery({
+ queryKey: ['fetchFooterLayout'],
+ queryFn: fetchFooterLayout,
+ staleTime: 1000 * 60 * 60 * 24, // 24 hours
+ });
+
const application = useLaxApplicationMetadata();
+
+ if (footerLayoutError) {
+ return ;
+ }
+
const shouldUseOrgLogo = application !== ContextNotProvided && application.logo != null;
- const components = useMemo(() => footerLayout.map((props) => createFooterComponent(props)), [footerLayout]);
+ const components = data?.footer?.map((props) => createFooterComponent(props)) ?? [];
if (!components.length && !shouldUseOrgLogo) {
return null;
}
diff --git a/src/features/footer/FooterLayoutProvider.tsx b/src/features/footer/FooterLayoutProvider.tsx
deleted file mode 100644
index 333a139be9..0000000000
--- a/src/features/footer/FooterLayoutProvider.tsx
+++ /dev/null
@@ -1,47 +0,0 @@
-import { useEffect } from 'react';
-
-import { useQuery } from '@tanstack/react-query';
-
-import { useAppQueries } from 'src/core/contexts/AppQueriesProvider';
-import { ContextNotProvided } from 'src/core/contexts/context';
-import { delayedContext } from 'src/core/contexts/delayedContext';
-import { createQueryContext } from 'src/core/contexts/queryContext';
-import type { IFooterLayout } from 'src/features/footer/types';
-
-// Also used for prefetching @see appPrefetcher.ts
-export function useFooterLayoutQueryDef() {
- const { fetchFooterLayout } = useAppQueries();
- return {
- queryKey: ['fetchFooterLayout'],
- queryFn: fetchFooterLayout,
- };
-}
-
-const useFooterLayoutQuery = () => {
- const utils = useQuery(useFooterLayoutQueryDef());
-
- useEffect(() => {
- utils.error && window.logError('Fetching footer failed:\n', utils.error);
- }, [utils.error]);
-
- return utils;
-};
-
-const { Provider, useLaxCtx } = delayedContext(() =>
- createQueryContext({
- name: 'FooterLayout',
- required: true,
- query: useFooterLayoutQuery,
- }),
-);
-
-const noFooter: IFooterLayout['footer'] = [];
-export const FooterLayoutProvider = Provider;
-export const useFooterLayout = () => {
- const ctx = useLaxCtx();
- if (ctx == ContextNotProvided) {
- return noFooter;
- }
-
- return ctx?.footer || noFooter;
-};
diff --git a/src/index.tsx b/src/index.tsx
index 150783faef..66e77d3bec 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -22,7 +22,6 @@ import { AppQueriesProvider } from 'src/core/contexts/AppQueriesProvider';
import { WindowTitleProvider } from 'src/core/ui/WindowTitleProvider';
import { ApplicationMetadataProvider } from 'src/features/applicationMetadata/ApplicationMetadataProvider';
import { ApplicationSettingsProvider } from 'src/features/applicationSettings/ApplicationSettingsProvider';
-import { FooterLayoutProvider } from 'src/features/footer/FooterLayoutProvider';
import { UiConfigProvider } from 'src/features/form/layout/UiConfigContext';
import { LayoutSetsProvider } from 'src/features/form/layoutSets/LayoutSetsProvider';
import { GlobalFormDataReadersProvider } from 'src/features/formData/FormDataReaders';
@@ -87,22 +86,20 @@ function Root() {
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/src/queries/appPrefetcher.ts b/src/queries/appPrefetcher.ts
index a9e3bd20b8..ef97e3aed3 100644
--- a/src/queries/appPrefetcher.ts
+++ b/src/queries/appPrefetcher.ts
@@ -3,7 +3,6 @@ import { matchPath } from 'react-router-dom';
import { usePrefetchQuery } from 'src/core/queries/usePrefetchQuery';
import { useApplicationMetadataQueryDef } from 'src/features/applicationMetadata/ApplicationMetadataProvider';
import { useApplicationSettingsQueryDef } from 'src/features/applicationSettings/ApplicationSettingsProvider';
-import { useFooterLayoutQueryDef } from 'src/features/footer/FooterLayoutProvider';
import { useLayoutSetsQueryDef } from 'src/features/form/layoutSets/LayoutSetsProvider';
import { useInstanceDataQueryDef } from 'src/features/instance/InstanceContext';
import { useProcessQueryDef } from 'src/features/instance/ProcessContext';
@@ -26,7 +25,6 @@ export function AppPrefetcher() {
usePrefetchQuery(useProfileQueryDef(true), Boolean(partyId));
usePrefetchQuery(useOrgsQueryDef());
usePrefetchQuery(useApplicationSettingsQueryDef());
- usePrefetchQuery(useFooterLayoutQueryDef());
usePrefetchQuery(usePartiesQueryDef(true), Boolean(partyId));
usePrefetchQuery(useCurrentPartyQueryDef(true), Boolean(partyId));
diff --git a/src/test/renderWithProviders.tsx b/src/test/renderWithProviders.tsx
index 6b8c1feb7c..c254f640bb 100644
--- a/src/test/renderWithProviders.tsx
+++ b/src/test/renderWithProviders.tsx
@@ -25,7 +25,6 @@ import { AppQueriesProvider } from 'src/core/contexts/AppQueriesProvider';
import { RenderStart } from 'src/core/ui/RenderStart';
import { ApplicationMetadataProvider } from 'src/features/applicationMetadata/ApplicationMetadataProvider';
import { ApplicationSettingsProvider } from 'src/features/applicationSettings/ApplicationSettingsProvider';
-import { FooterLayoutProvider } from 'src/features/footer/FooterLayoutProvider';
import { FormProvider } from 'src/features/form/FormContext';
import { PageNavigationProvider } from 'src/features/form/layout/PageNavigationContext';
import { UiConfigProvider } from 'src/features/form/layout/UiConfigContext';
@@ -284,9 +283,7 @@ function DefaultProviders({ children, queries, queryClient, Router = DefaultRout
-
- {children}
-
+ {children}