Skip to content

Commit

Permalink
flytter driftsmeldinger til client-side
Browse files Browse the repository at this point in the history
  • Loading branch information
toresbe committed Nov 21, 2024
1 parent 2325e63 commit 37b0987
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {getPathPrefixIncludingLocale} from "./getPathPrefixIncludingLocale.ts";
import {QueryClient, QueryClientProvider} from "@tanstack/react-query";
import {ReactQueryDevtools} from "@tanstack/react-query-devtools";
import {onLanguageSelect, setParams} from "@navikt/nav-dekoratoren-moduler";
import {Driftsmeldinger} from "./lib/driftsmeldinger/Driftsmeldinger.tsx";

const queryClient = new QueryClient();

Expand Down Expand Up @@ -52,6 +53,7 @@ export default function App() {
return (
<Suspense fallback={<ApplicationSpinner />}>
<QueryClientProvider client={queryClient}>
<Driftsmeldinger />
<BrowserRouter
basename={prefix}
future={{
Expand Down
8 changes: 7 additions & 1 deletion src/app/[locale]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {DigisosContext} from "../../lib/providers/DigisosContext.ts";
import {BASE_PATH} from "../../lib/constants.ts";
import {configureLogger} from "@navikt/next-logger";
import {initAmplitude} from "../../lib/amplitude/Amplitude.tsx";
import {Driftsmeldinger} from "../../lib/driftsmeldinger/Driftsmeldinger.tsx";

const Page = () => {
configureLogger({basePath: BASE_PATH});
Expand All @@ -20,7 +21,12 @@ const Page = () => {
onLanguageSelect(({locale: language, url}) =>
setParams({language}).then(() => window.location.assign(`${url}${path}`))
);
return <Informasjon />;
return (
<>
<Driftsmeldinger />
<Informasjon />
</>
);
};

export default Page;
6 changes: 4 additions & 2 deletions src/lib/driftsmeldinger/getDriftsmeldinger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ export const getDriftsmeldinger = async () => {
driftsmeldingUrl.searchParams.set(DriftsmeldingAudienceParam, DriftsmeldingAudience.soknad);

try {
const res = await fetch(driftsmeldingUrl.toString(), {signal: AbortSignal.timeout(500)});
const res = await fetch(driftsmeldingUrl.toString(), {
signal: AbortSignal.timeout(500),
});
if (!res.ok) {
logger.warn(`fetching driftsmeldinger: HTTP error response: ${res.status} ${res.statusText}`);
return [];
}
return (await res.json()) as Driftsmelding[];
} catch (e: any) {
logger.warn("fetching driftsmeldinger: error", e);
logger.warn({error: e?.message}, "fetching driftsmeldinger: error");
return [];
}
};

0 comments on commit 37b0987

Please sign in to comment.