diff --git a/app/routes/_oppgaver.tsx b/app/routes/_oppgaver.tsx
deleted file mode 100644
index 49d8ae4b..00000000
--- a/app/routes/_oppgaver.tsx
+++ /dev/null
@@ -1,19 +0,0 @@
-import type { LoaderFunctionArgs } from "@remix-run/node";
-import { json } from "@remix-run/node";
-import { Outlet } from "@remix-run/react";
-
-import { hentOppgaver } from "~/models/oppgave.server";
-
-export async function loader({ request }: LoaderFunctionArgs) {
- const url = new URL(request.url);
- const oppgaverResponse = await hentOppgaver(request, url.search);
-
- return json({
- oppgaver: oppgaverResponse.oppgaver,
- totaltAntallOppgaver: oppgaverResponse.totaltAntallOppgaver,
- });
-}
-
-export function Oppgaver() {
- return
;
-}
diff --git a/app/routes/_oppgaver.alle-oppgaver.tsx b/app/routes/alle-oppgaver.tsx
similarity index 77%
rename from app/routes/_oppgaver.alle-oppgaver.tsx
rename to app/routes/alle-oppgaver.tsx
index b2f85910..b561fcae 100644
--- a/app/routes/_oppgaver.alle-oppgaver.tsx
+++ b/app/routes/alle-oppgaver.tsx
@@ -1,7 +1,7 @@
import { BarChartIcon, FunnelIcon } from "@navikt/aksel-icons";
import { Tabs } from "@navikt/ds-react";
import { json, LoaderFunctionArgs, redirect } from "@remix-run/node";
-import { useNavigation } from "@remix-run/react";
+import { useLoaderData, useNavigation } from "@remix-run/react";
import { OppgaveFilterDato } from "~/components/oppgave-filter-dato/OppgaveFilterDato";
import { OppgaveFilterEmneknagger } from "~/components/oppgave-filter-emneknagger/OppgaveFilterEmneknagger";
@@ -10,22 +10,23 @@ import { OppgaveFilterStatus } from "~/components/oppgave-filter-status/OppgaveF
import { OppgaveListe } from "~/components/oppgave-liste/OppgaveListe";
import tabStyles from "~/components/oppgave-liste-meny/OppgaveListeMeny.module.css";
import { OppgaveListePaginering } from "~/components/oppgave-liste-paginering/OppgaveListePaginering";
-import { useTypedRouteLoaderData } from "~/hooks/useTypedRouteLoaderData";
+import { useHandleAlertMessages } from "~/hooks/useHandleAlertMessages";
+import { hentOppgaver } from "~/models/oppgave.server";
import styles from "~/route-styles/index.module.css";
import { commitSession, getSession } from "~/sessions";
import { appendSearchParamIfNotExists } from "~/utils/url.utils";
+export const alleOppgaverDefaultParams = [
+ { key: "side", value: "1" },
+ { key: "antallOppgaver", value: "100" },
+];
+
export async function loader({ request }: LoaderFunctionArgs) {
const url = new URL(request.url);
if (!url.search) {
- const paramsToAppend = [
- { key: "side", value: "1" },
- { key: "antallOppgaver", value: "100" },
- ];
-
let appended = false;
- for (const { key, value } of paramsToAppend) {
+ for (const { key, value } of alleOppgaverDefaultParams) {
appended = appendSearchParamIfNotExists(url.searchParams, key, value) || appended;
}
@@ -34,26 +35,29 @@ export async function loader({ request }: LoaderFunctionArgs) {
}
}
+ const oppgaverResponse = await hentOppgaver(request, url.search);
const session = await getSession(request.headers.get("Cookie"));
const alert = session.get("alert");
- if (alert) {
- return json(
- { alert },
- {
- headers: {
- "Set-Cookie": await commitSession(session),
- },
+ return json(
+ {
+ alert,
+ oppgaver: oppgaverResponse.oppgaver,
+ totaltAntallOppgaver: oppgaverResponse.totaltAntallOppgaver,
+ },
+ {
+ headers: {
+ "Set-Cookie": await commitSession(session),
},
- );
- }
-
- return null;
+ },
+ );
}
export default function Saksbehandling() {
const { state } = useNavigation();
- const { oppgaver, totaltAntallOppgaver } = useTypedRouteLoaderData("routes/_oppgaver");
+ const { alert, oppgaver, totaltAntallOppgaver } = useLoaderData
();
+ useHandleAlertMessages(alert);
+
return (