From 8816fd0cda2eb18a669b4a39fe3fed063fcf7645 Mon Sep 17 00:00:00 2001 From: AudunSorheim <80095835+AudunSorheim@users.noreply.github.com> Date: Tue, 5 Dec 2023 09:33:41 +0100 Subject: [PATCH] Historisk visning av brukerhendelser (#2) * Add historic view and slight redesign --- package-lock.json | 2 +- package.json | 2 +- src/breadcrumbs/breadcrumbs.ts | 24 ++- src/components/Aktivitetskrav.cy.tsx | 36 ++-- src/components/Aktivitetskrav.tsx | 33 ++-- src/components/box/AktivitetskravBox.tsx | 22 +++ src/components/header/ComponentHeader.tsx | 50 ++++++ .../header/componentheader.module.css | 27 +++ .../history/HistoricEventsSummary.tsx | 52 ++++++ src/components/icons/IconRow.tsx | 2 +- src/components/page/Page.tsx | 32 +--- src/components/page/PageHeadingWithImage.tsx | 2 +- .../AktivitetskravSkeletonComponent.tsx | 24 ++- .../TestScenarioSelector.tsx | 16 +- .../view/ForhandsvarselComponent.tsx | 54 ++++-- .../view/MottattVurderingComponent.tsx | 46 +++++ ...onent.tsx => UnderBehandlingComponent.tsx} | 21 ++- src/components/view/Vurdering.tsx | 28 +++ .../aktivitetskravInfo/AktivitetskravInfo.tsx | 2 +- .../MedUtenArbeidsgiverToggleGroup.tsx | 46 ++--- .../view/ikkeOppfylt/IkkeOppfyltComponent.tsx | 31 ++++ .../MottattVurderingDetaljer.tsx | 20 +++ .../mottattVurdering/VurderingIkkeAktuell.tsx | 11 ++ .../mottattVurdering/VurderingOppfylt.tsx | 23 +++ .../view/mottattVurdering/VurderingUnntak.tsx | 20 +++ src/components/view/viewUtils.ts | 89 ++++++++++ src/data/api.ts | 6 +- src/data/dataHooks.tsx | 13 ++ src/mocks/fixtures.ts | 167 ++++++++++++++---- src/pages/[uuid]/index.tsx | 50 ++++++ src/pages/_app.tsx | 12 +- src/pages/_document.tsx | 4 +- .../aktivitetsplikt/{ => historikk}/index.ts | 2 +- src/pages/index.tsx | 12 +- src/schema/aktivitetskravVurderingSchema.ts | 111 ++++++++---- src/utils/dateUtils.ts | 4 + src/utils/testScenarioUtils.ts | 28 ++- tailwind.config.ts | 4 + 38 files changed, 924 insertions(+), 204 deletions(-) create mode 100644 src/components/box/AktivitetskravBox.tsx create mode 100644 src/components/header/ComponentHeader.tsx create mode 100644 src/components/header/componentheader.module.css create mode 100644 src/components/history/HistoricEventsSummary.tsx create mode 100644 src/components/view/MottattVurderingComponent.tsx rename src/components/view/{AktivitetskravInfoComponent.tsx => UnderBehandlingComponent.tsx} (54%) create mode 100644 src/components/view/Vurdering.tsx create mode 100644 src/components/view/ikkeOppfylt/IkkeOppfyltComponent.tsx create mode 100644 src/components/view/mottattVurdering/MottattVurderingDetaljer.tsx create mode 100644 src/components/view/mottattVurdering/VurderingIkkeAktuell.tsx create mode 100644 src/components/view/mottattVurdering/VurderingOppfylt.tsx create mode 100644 src/components/view/mottattVurdering/VurderingUnntak.tsx create mode 100644 src/components/view/viewUtils.ts create mode 100644 src/data/dataHooks.tsx create mode 100644 src/pages/[uuid]/index.tsx rename src/pages/api/aktivitetsplikt/{ => historikk}/index.ts (92%) diff --git a/package-lock.json b/package-lock.json index 8943e705..a7757d4f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,7 +36,7 @@ "next-router-mock": "^0.9.10", "postcss": "^8", "prettier": "3.0.3", - "tailwindcss": "^3.3.0", + "tailwindcss": "^3.3.5", "typescript": "^5" } }, diff --git a/package.json b/package.json index e7ee0c0f..cd428cc9 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "next-router-mock": "^0.9.10", "postcss": "^8", "prettier": "3.0.3", - "tailwindcss": "^3.3.0", + "tailwindcss": "^3.3.5", "typescript": "^5" } } diff --git a/src/breadcrumbs/breadcrumbs.ts b/src/breadcrumbs/breadcrumbs.ts index 936d96c6..a030d1b8 100644 --- a/src/breadcrumbs/breadcrumbs.ts +++ b/src/breadcrumbs/breadcrumbs.ts @@ -3,7 +3,7 @@ interface Breadcrumb { title: string; } -export const AktivitetspliktCrumbs: Breadcrumb[] = [ +export const AktivitetspliktBaseCrumbs: Breadcrumb[] = [ { url: process.env.NEXT_PUBLIC_MIN_SIDE_URL!, title: "Min side", @@ -13,8 +13,26 @@ export const AktivitetspliktCrumbs: Breadcrumb[] = [ title: "Ditt sykefravær", }, { - url: "/aktivitetsplikt", - title: "Informasjon om aktivitetsplikt", + url: "/syk/aktivitetskrav", + title: "Din aktivitetsplikt", }, ]; +export const AktivitetspliktHistorikkCrumbs: Breadcrumb[] = [ + ...AktivitetspliktBaseCrumbs, + { + url: "/syk/aktivitetskrav", + title: "Historikk", + }, +]; + +export function createBreadcrumbs(pathname: string) { + switch (pathname) { + case "/": + return AktivitetspliktBaseCrumbs; + case "/[uuid]": + return AktivitetspliktHistorikkCrumbs; + default: + return []; + } +} diff --git a/src/components/Aktivitetskrav.cy.tsx b/src/components/Aktivitetskrav.cy.tsx index 8216a69c..52cb495e 100644 --- a/src/components/Aktivitetskrav.cy.tsx +++ b/src/components/Aktivitetskrav.cy.tsx @@ -1,37 +1,45 @@ import React from "react"; import { Aktivitetskrav } from "./Aktivitetskrav"; import fixtures from "@/mocks/fixtures"; -import { infoSideHeaderText } from "@/components/view/AktivitetskravInfoComponent"; -import { forhandsVarselHeaderText } from "@/components/view/ForhandsvarselComponent"; describe("", () => { - it("Displays infoside for Ny kandidat", () => { - cy.mount(); + it("Displays infoside for vurdering ny kandidat", () => { + cy.mount(); - cy.contains(infoSideHeaderText); + cy.contains("Det er på tide å informere deg om aktivitetsplikten"); }); - it("Displays infoside for forhandsvarsel with missing document", () => { + it("Displays infoside for vurdering forhandsvarsel with missing document", () => { cy.mount( , ); - cy.contains(infoSideHeaderText); + cy.contains("Det er på tide å informere deg om aktivitetsplikten"); }); - it("Displays forhaandsvarsel for forhandsvarsel with document", () => { + it("Displays forhaandsvarsel for vurdering forhandsvarsel with document", () => { cy.mount( - , + , ); - cy.contains(forhandsVarselHeaderText); + cy.contains("Varsel om stans av sykepenger"); }); - it("Defaults to infoside for other states", () => { - cy.mount(); + it("Displays unntaksinfo with årsak for vurdering unntak", () => { + cy.mount(); - cy.contains(infoSideHeaderText); + cy.contains("NAV har vurdert aktivitetsplikten din"); + cy.contains( + "NAV har vurdert aktivitetsplikten din og besluttet at du er unntatt fra aktivitetsplikten på grunn av medisinske opplysninger.", + ); + }); + + it("Displays oppfyltinfo with årsak for vurdering oppfylt", () => { + cy.mount(); + + cy.contains("NAV har vurdert aktivitetsplikten din"); + cy.contains("NAV vurderer at du oppfyller aktivitetsplikten siden du er"); }); }); diff --git a/src/components/Aktivitetskrav.tsx b/src/components/Aktivitetskrav.tsx index 3d42e9ac..bc79a263 100644 --- a/src/components/Aktivitetskrav.tsx +++ b/src/components/Aktivitetskrav.tsx @@ -1,20 +1,25 @@ import { AktivitetskravVurdering } from "@/schema/aktivitetskravVurderingSchema"; -import { AktivitetskravInfoComponent } from "@/components/view/AktivitetskravInfoComponent"; -import { ForhandsvarselComponent } from "@/components/view/ForhandsvarselComponent"; +import { Page } from "@/components/page/Page"; +import { AktivitetskravBox } from "@/components/box/AktivitetskravBox"; +import React from "react"; +import { HistoricEventsSummary } from "@/components/history/HistoricEventsSummary"; +import { getViewItems } from "@/components/view/viewUtils"; +import { Vurdering } from "@/components/view/Vurdering"; interface Props { - aktivitetskrav: AktivitetskravVurdering; + aktivitetskrav: AktivitetskravVurdering[]; } + export const Aktivitetskrav = ({ aktivitetskrav }: Props) => { - switch (aktivitetskrav.status) { - case "FORHANDSVARSEL": { - if (!aktivitetskrav.document) { - return ; - } - return ; - } - default: { - return ; - } - } + const { activeVurdering, historicVurderinger } = getViewItems(aktivitetskrav); + + return ( + + + + + + + + ); }; diff --git a/src/components/box/AktivitetskravBox.tsx b/src/components/box/AktivitetskravBox.tsx new file mode 100644 index 00000000..30d64787 --- /dev/null +++ b/src/components/box/AktivitetskravBox.tsx @@ -0,0 +1,22 @@ +import React, { ReactNode } from "react"; +import { Box } from "@navikt/ds-react"; + +interface Props { + children: ReactNode; +} + +export const AktivitetskravBox = ({ children }: Props) => { + return ( +
+ + {children} + +
+ ); +}; diff --git a/src/components/header/ComponentHeader.tsx b/src/components/header/ComponentHeader.tsx new file mode 100644 index 00000000..0113e1fc --- /dev/null +++ b/src/components/header/ComponentHeader.tsx @@ -0,0 +1,50 @@ +import { BodyLong, Heading } from "@navikt/ds-react"; +import React from "react"; +import { getShortDateFormat } from "@/utils/dateUtils"; +import { + CheckmarkCircleFillIcon, + ExclamationmarkTriangleFillIcon, + InformationSquareFillIcon, + XMarkOctagonFillIcon, +} from "@navikt/aksel-icons"; +import styles from "./componentheader.module.css"; + +interface Props { + headerText: string; + alertStyle: "info" | "success" | "warning" | "error"; + createdAt: string; +} + +export const ComponentHeader = ({ + headerText, + alertStyle, + createdAt, +}: Props) => { + return ( +
+
+ + {headerText} + + <> + {alertStyle === "info" && ( + + )} + {alertStyle === "warning" && ( + + )} + {alertStyle === "success" && ( + + )} + {alertStyle === "error" && ( + + )} + +
+ + + Utsendt {getShortDateFormat(createdAt)} + +
+ ); +}; diff --git a/src/components/header/componentheader.module.css b/src/components/header/componentheader.module.css new file mode 100644 index 00000000..b7c9ef8f --- /dev/null +++ b/src/components/header/componentheader.module.css @@ -0,0 +1,27 @@ +.roundedIcon { + flex-shrink: 0; + font-size: 2rem; + height: 30px; + margin-top: 0.2rem; + margin-left: auto; +} + +.infoIcon { + composes: roundedIcon; + color: var(--a-icon-info); +} + +.warningIcon { + composes: roundedIcon; + color: var(--a-icon-warning); +} + +.successIcon { + composes: roundedIcon; + color: var(--a-icon-success); +} + +.errorIcon { + composes: roundedIcon; + color: var(--a-icon-danger); +} diff --git a/src/components/history/HistoricEventsSummary.tsx b/src/components/history/HistoricEventsSummary.tsx new file mode 100644 index 00000000..447add2b --- /dev/null +++ b/src/components/history/HistoricEventsSummary.tsx @@ -0,0 +1,52 @@ +import { AktivitetskravBox } from "@/components/box/AktivitetskravBox"; +import { Heading, LinkPanel } from "@navikt/ds-react"; +import NextLink from "next/link"; +import React from "react"; +import { getShortDateFormat } from "@/utils/dateUtils"; +import { AktivitetskravViewItem } from "@/components/view/viewUtils"; + +const getHeaderText = (viewItem: AktivitetskravViewItem) => { + switch (viewItem.type) { + case "UNDER_BEHANDLING": + return "NAV vurderer aktivitetsplikten din"; + case "IKKE_OPPFYLT": + return "Svarfristen har gått ut"; + case "FORHANDSVARSEL": + return "Forhåndsvarsel om stans av sykepenger"; + case "MOTTATT_VURDERING": + return "Du har mottatt en vurdering av din aktivitetsplikt"; + } +}; + +interface Props { + historicVurderinger: AktivitetskravViewItem[] | null; +} + +export const HistoricEventsSummary = ({ historicVurderinger }: Props) => { + if (historicVurderinger && historicVurderinger.length > 0) { + return ( + + + Tidligere hendelser vedrørende din aktivitetsplikt + + + {historicVurderinger.map((item, index) => { + return ( + + + {getShortDateFormat(item.vurdering.createdAt)}:{" "} + {getHeaderText(item)} + + + ); + })} + + ); + } + return null; +}; diff --git a/src/components/icons/IconRow.tsx b/src/components/icons/IconRow.tsx index d355d474..990d014c 100644 --- a/src/components/icons/IconRow.tsx +++ b/src/components/icons/IconRow.tsx @@ -11,7 +11,7 @@ export const IconRow = ({ icon, displaySkeleton = false, children }: Props) => { return (
{displaySkeleton ? ( -
+
) : ( diff --git a/src/components/page/Page.tsx b/src/components/page/Page.tsx index f5478490..21fdf6b9 100644 --- a/src/components/page/Page.tsx +++ b/src/components/page/Page.tsx @@ -1,36 +1,22 @@ import React, { ReactNode } from "react"; -import { PageHeadingWithImage } from "./PageHeadingWithImage"; -import { PageHeading } from "./PageHeading"; import { Link } from "@navikt/ds-react"; -import { MedUtenAGVisning } from "@/components/view/AktivitetskravInfoComponent"; interface Props { - headerText: ReactNode; - image?: MedUtenAGVisning; children: ReactNode; } -export const Page = ({ headerText, image, children }: Props) => { +export const Page = ({ children }: Props) => { return ( <> -
- {image ? ( - - ) : ( - - )} -
+
+ {children} -
-
- {children} - - Naviger til Min side - -
+ + Naviger til Min side +
); diff --git a/src/components/page/PageHeadingWithImage.tsx b/src/components/page/PageHeadingWithImage.tsx index 9c03d224..9d0fe1ab 100644 --- a/src/components/page/PageHeadingWithImage.tsx +++ b/src/components/page/PageHeadingWithImage.tsx @@ -3,7 +3,7 @@ import { Heading } from "@navikt/ds-react"; import React, { ReactNode } from "react"; import medarbeidsgiver from "../../../public/med_arbeidsgiver.svg"; import utenarbeidsgiver from "../../../public/uten_arbeidsgiver.svg"; -import { MedUtenAGVisning } from "@/components/view/AktivitetskravInfoComponent"; +import { MedUtenAGVisning } from "@/components/view/UnderBehandlingComponent"; interface Props { headerText: ReactNode; diff --git a/src/components/skeleton/AktivitetskravSkeletonComponent.tsx b/src/components/skeleton/AktivitetskravSkeletonComponent.tsx index 9e9e0696..0bf6ac42 100644 --- a/src/components/skeleton/AktivitetskravSkeletonComponent.tsx +++ b/src/components/skeleton/AktivitetskravSkeletonComponent.tsx @@ -1,12 +1,30 @@ "use client"; import { Page } from "@/components/page/Page"; -import { Skeleton } from "@navikt/ds-react"; import { AktivitetskravInfo } from "@/components/view/aktivitetskravInfo/AktivitetskravInfo"; +import { AktivitetskravBox } from "@/components/box/AktivitetskravBox"; +import { infoSideHeaderText } from "@/components/view/UnderBehandlingComponent"; +import { ComponentHeader } from "@/components/header/ComponentHeader"; +import { MedUtenArbeidsgiverToggleGroup } from "@/components/view/aktivitetskravInfo/MedUtenArbeidsgiverToggleGroup"; +import { Skeletor } from "@/components/skeleton/Skeletor"; export const AktivitetskravSkeletonComponent = () => { return ( - Informasjon om aktivitetsplikt}> - + + + + + + + + void 0} /> + + + + ); }; diff --git a/src/components/testscenarioselector/TestScenarioSelector.tsx b/src/components/testscenarioselector/TestScenarioSelector.tsx index f4880811..8aa470d9 100644 --- a/src/components/testscenarioselector/TestScenarioSelector.tsx +++ b/src/components/testscenarioselector/TestScenarioSelector.tsx @@ -6,18 +6,20 @@ import styles from "./testscenarioselector.module.css"; import { ForhandsvarselTestScenario, getTestScenario, + IkkeAktuellTestScenario, + IkkeOppfyltTestScenario, InfoSideTestScenario, + OppfyltTestScenario, setTestScenario, TestScenario, + UnntakTestScenario, } from "@/utils/testScenarioUtils"; -import { useQueryClient } from "@tanstack/react-query"; export const TestScenarioSelector = () => { const [open, setOpen] = useState(false); const [selectedScenario, setSelectedScenario] = useState< TestScenario | undefined >(); - const queryClient = useQueryClient(); useEffect(() => { setSelectedScenario(getTestScenario()); @@ -45,9 +47,12 @@ export const TestScenarioSelector = () => { setSelectedScenario(val); }} > - Infosiden - + Ny kandidat Forhåndsvarsel + Ikke aktuell + Ikke oppfylt + Unntak + Oppfylt
@@ -58,8 +63,7 @@ export const TestScenarioSelector = () => { // disabled={!setActiveTestScenario} onClick={() => { setTestScenario(selectedScenario); - queryClient.invalidateQueries(); - setOpen(false); + window.location.reload(); }} > Velg scenario diff --git a/src/components/view/ForhandsvarselComponent.tsx b/src/components/view/ForhandsvarselComponent.tsx index e82e76df..ced25472 100644 --- a/src/components/view/ForhandsvarselComponent.tsx +++ b/src/components/view/ForhandsvarselComponent.tsx @@ -1,17 +1,16 @@ -import { DocumentComponent } from "@/schema/documentComponentSchema"; -import { BodyLong, Heading, Link } from "@navikt/ds-react"; -import { Page } from "@/components/page/Page"; -import { useEffect } from "react"; +import { BodyLong, Heading, Link, Tag } from "@navikt/ds-react"; +import React, { useEffect } from "react"; import { post } from "@/data/api"; +import { AktivitetskravVurdering } from "@/schema/aktivitetskravVurderingSchema"; +import { getShortDateFormat } from "@/utils/dateUtils"; +import { ComponentHeader } from "@/components/header/ComponentHeader"; interface Props { - document?: DocumentComponent[] | null; + vurdering: AktivitetskravVurdering; } const ferdigstiltSessionStorageKey = "ferdigstilt-forhandsvarsel"; -export const forhandsVarselHeaderText = "Varsel om stans av sykepenger"; - -export const ForhandsvarselComponent = ({ document }: Props) => { +export const ForhandsvarselComponent = ({ vurdering }: Props) => { useEffect(() => { const hasAlreadyFerdigstilt = sessionStorage.getItem( ferdigstiltSessionStorageKey, @@ -22,16 +21,29 @@ export const ForhandsvarselComponent = ({ document }: Props) => { } }, []); + if (vurdering.status !== "FORHANDSVARSEL") return null; + return ( - -
- {document?.map((d) => { +
+
+ {vurdering.document?.map((d, index) => { switch (d.type) { case "HEADER_H1": - return null; + return ( +
+ {d.texts.map((text, index) => ( + + ))} +
+ ); case "HEADER_H2": return ( -
+
{d.texts.map((text, index) => ( {text} @@ -41,7 +53,7 @@ export const ForhandsvarselComponent = ({ document }: Props) => { ); case "HEADER_H3": return ( -
+
{d.texts.map((text, index) => ( {text} @@ -51,7 +63,7 @@ export const ForhandsvarselComponent = ({ document }: Props) => { ); case "LINK": return ( -
+
{d.title && ( {d.title} @@ -66,7 +78,7 @@ export const ForhandsvarselComponent = ({ document }: Props) => { ); case "BULLET_POINTS": return ( -
    +
      {d.texts.map((text, index) => ( {text} @@ -76,17 +88,21 @@ export const ForhandsvarselComponent = ({ document }: Props) => { ); case "PARAGRAPH": return ( - <> +
      {d.texts.map((text, index) => ( {text} ))} - +
      ); } })}
- + + + Svarfrist: {getShortDateFormat(vurdering.fristDato)} + +
); }; diff --git a/src/components/view/MottattVurderingComponent.tsx b/src/components/view/MottattVurderingComponent.tsx new file mode 100644 index 00000000..45d6c7b7 --- /dev/null +++ b/src/components/view/MottattVurderingComponent.tsx @@ -0,0 +1,46 @@ +"use client"; +import React from "react"; +import { ComponentHeader } from "@/components/header/ComponentHeader"; +import { BodyLong, Tag } from "@navikt/ds-react"; +import { AktivitetskravVurdering } from "@/schema/aktivitetskravVurderingSchema"; +import { getShortDateFormat } from "@/utils/dateUtils"; +import { MottattVurderingDetaljer } from "@/components/view/mottattVurdering/MottattVurderingDetaljer"; + +interface Props { + vurdering: AktivitetskravVurdering; +} + +export const MottattVurderingComponent = ({ vurdering }: Props) => { + return ( + <> + + +
+ Hei! + + + + + Aktivitetsplikten gjelder gjennom hele sykefraværet og det kan være at + NAV vurderer aktivitetsplikten din igjen på et senere tidspunkt. Du + vil da motta ny informasjon om det. + + + + Denne vurderingen er tilgjengelig for deg på Min side i 30 dager fra + vurderingen til NAV ble gjort. + + + {vurdering.sistVurdert && ( + + Dato for vurdering: {getShortDateFormat(vurdering.sistVurdert)} + + )} +
+ + ); +}; diff --git a/src/components/view/AktivitetskravInfoComponent.tsx b/src/components/view/UnderBehandlingComponent.tsx similarity index 54% rename from src/components/view/AktivitetskravInfoComponent.tsx rename to src/components/view/UnderBehandlingComponent.tsx index a223c8cd..aae4cca4 100644 --- a/src/components/view/AktivitetskravInfoComponent.tsx +++ b/src/components/view/UnderBehandlingComponent.tsx @@ -1,20 +1,31 @@ "use client"; -import { Page } from "@/components/page/Page"; import { useState } from "react"; import { MedUtenArbeidsgiverToggleGroup } from "@/components/view/aktivitetskravInfo/MedUtenArbeidsgiverToggleGroup"; import { AktivitetskravInfo } from "@/components/view/aktivitetskravInfo/AktivitetskravInfo"; +import { ComponentHeader } from "@/components/header/ComponentHeader"; +import { AktivitetskravVurdering } from "@/schema/aktivitetskravVurderingSchema"; export type MedUtenAGVisning = "MED_ARBEIDSGIVER" | "UTEN_ARBEIDSGIVER"; -export const infoSideHeaderText = "Informasjon om aktivitetsplikt"; +export const infoSideHeaderText = "Din aktivitetsplikt"; -export const AktivitetskravInfoComponent = () => { +interface Props { + vurdering: AktivitetskravVurdering; +} + +export const UnderBehandlingComponent = ({ vurdering }: Props) => { const [visning, setVisning] = useState("MED_ARBEIDSGIVER"); return ( - + <> + + - + ); }; diff --git a/src/components/view/Vurdering.tsx b/src/components/view/Vurdering.tsx new file mode 100644 index 00000000..2894ed86 --- /dev/null +++ b/src/components/view/Vurdering.tsx @@ -0,0 +1,28 @@ +import React, { ReactElement } from "react"; +import { ForhandsvarselComponent } from "@/components/view/ForhandsvarselComponent"; +import { UnderBehandlingComponent } from "@/components/view/UnderBehandlingComponent"; +import { MottattVurderingComponent } from "@/components/view/MottattVurderingComponent"; +import { AktivitetskravViewItem } from "@/components/view/viewUtils"; +import { IkkeOppfyltComponent } from "@/components/view/ikkeOppfylt/IkkeOppfyltComponent"; + +interface Props { + viewItem?: AktivitetskravViewItem | null; +} + +export const Vurdering = ({ viewItem }: Props): ReactElement | null => { + if (!viewItem) return null; + + switch (viewItem.type) { + case "FORHANDSVARSEL": { + return ; + } + case "MOTTATT_VURDERING": + return ; + case "UNDER_BEHANDLING": + return ; + case "IKKE_OPPFYLT": + return ; + default: + return null; + } +}; diff --git a/src/components/view/aktivitetskravInfo/AktivitetskravInfo.tsx b/src/components/view/aktivitetskravInfo/AktivitetskravInfo.tsx index 894575dc..286efb5e 100644 --- a/src/components/view/aktivitetskravInfo/AktivitetskravInfo.tsx +++ b/src/components/view/aktivitetskravInfo/AktivitetskravInfo.tsx @@ -20,7 +20,7 @@ export const AktivitetskravInfo = ({ }: Props) => { return (
-
+
Hei! diff --git a/src/components/view/aktivitetskravInfo/MedUtenArbeidsgiverToggleGroup.tsx b/src/components/view/aktivitetskravInfo/MedUtenArbeidsgiverToggleGroup.tsx index 4b814a2f..31f846fc 100644 --- a/src/components/view/aktivitetskravInfo/MedUtenArbeidsgiverToggleGroup.tsx +++ b/src/components/view/aktivitetskravInfo/MedUtenArbeidsgiverToggleGroup.tsx @@ -1,28 +1,28 @@ -import { ToggleGroup } from "@navikt/ds-react" -import React from "react" -import { Buldings3Icon, PersonIcon } from "@navikt/aksel-icons" -import { MedUtenAGVisning } from "@/components/view/AktivitetskravInfoComponent"; +import { ToggleGroup } from "@navikt/ds-react"; +import React from "react"; +import { Buldings3Icon, PersonIcon } from "@navikt/aksel-icons"; +import { MedUtenAGVisning } from "@/components/view/UnderBehandlingComponent"; interface Props { - setVisning(val: MedUtenAGVisning): void + setVisning(val: MedUtenAGVisning): void; } export const MedUtenArbeidsgiverToggleGroup = ({ setVisning }: Props) => { - return ( -
- setVisning(visning as MedUtenAGVisning)} - > - - - Jeg har arbeidsgiver - - - - Jeg har ikke arbeidsgiver - - -
- ) -} + return ( +
+ setVisning(visning as MedUtenAGVisning)} + > + + + Jeg har arbeidsgiver + + + + Jeg har ikke arbeidsgiver + + +
+ ); +}; diff --git a/src/components/view/ikkeOppfylt/IkkeOppfyltComponent.tsx b/src/components/view/ikkeOppfylt/IkkeOppfyltComponent.tsx new file mode 100644 index 00000000..ad869b63 --- /dev/null +++ b/src/components/view/ikkeOppfylt/IkkeOppfyltComponent.tsx @@ -0,0 +1,31 @@ +"use client"; +import React from "react"; +import {ComponentHeader} from "@/components/header/ComponentHeader"; +import {BodyLong} from "@navikt/ds-react"; +import {AktivitetskravVurdering} from "@/schema/aktivitetskravVurderingSchema"; + +interface Props { + vurdering: AktivitetskravVurdering; +} + +export const IkkeOppfyltComponent = ({ vurdering }: Props) => { + return ( + <> + + +
+ Hei! + + + Svarfristen til forhåndsvarslet har gått ut. NAV vurderer fremdeles + aktivitetsplikten din. Du vil motta ny informasjon så snart NAV har + fullført vurderingen. + +
+ + ); +}; diff --git a/src/components/view/mottattVurdering/MottattVurderingDetaljer.tsx b/src/components/view/mottattVurdering/MottattVurderingDetaljer.tsx new file mode 100644 index 00000000..a6c36018 --- /dev/null +++ b/src/components/view/mottattVurdering/MottattVurderingDetaljer.tsx @@ -0,0 +1,20 @@ +import React from "react"; +import { VurderingOppfylt } from "@/components/view/mottattVurdering/VurderingOppfylt"; +import { VurderingUnntak } from "@/components/view/mottattVurdering/VurderingUnntak"; +import { VurderingIkkeAktuell } from "@/components/view/mottattVurdering/VurderingIkkeAktuell"; +import { AktivitetskravVurdering } from "@/schema/aktivitetskravVurderingSchema"; + +interface Props { + vurdering: AktivitetskravVurdering; +} + +export const MottattVurderingDetaljer = ({ vurdering }: Props) => { + switch (vurdering.status) { + case "OPPFYLT": + return ; + case "UNNTAK": + return ; + case "IKKE_AKTUELL": + return ; + } +}; diff --git a/src/components/view/mottattVurdering/VurderingIkkeAktuell.tsx b/src/components/view/mottattVurdering/VurderingIkkeAktuell.tsx new file mode 100644 index 00000000..e336f69b --- /dev/null +++ b/src/components/view/mottattVurdering/VurderingIkkeAktuell.tsx @@ -0,0 +1,11 @@ +import { BodyLong } from "@navikt/ds-react"; +import React from "react"; + +export const VurderingIkkeAktuell = () => { + return ( + + NAV vurderer at aktivitetsplikten ikke er aktuell for deg. Dette kan blant + annet gjelde hvis du mottar en annen ytelse enn sykepenger. + + ); +}; diff --git a/src/components/view/mottattVurdering/VurderingOppfylt.tsx b/src/components/view/mottattVurdering/VurderingOppfylt.tsx new file mode 100644 index 00000000..07133d10 --- /dev/null +++ b/src/components/view/mottattVurdering/VurderingOppfylt.tsx @@ -0,0 +1,23 @@ +import { + Oppfylt, + OppfyltArsaker, +} from "@/schema/aktivitetskravVurderingSchema"; +import { BodyLong } from "@navikt/ds-react"; + +const getAarsakAvsnitt = (arsak: OppfyltArsaker) => { + switch (arsak) { + case "FRISKMELDT": + return "NAV vurderer at du oppfyller aktivitetsplikten siden du er friskmeldt."; + case "GRADERT": + return "NAV vurderer at du oppfyller aktivitetsplikten siden du er i gradert arbeid."; + case "TILTAK": + return "NAV vurderer at du oppfyller aktivitetsplikten siden du er i tiltak."; + } +}; + +interface Props { + vurdering: Oppfylt; +} +export const VurderingOppfylt = ({ vurdering }: Props) => { + return {getAarsakAvsnitt(vurdering.arsaker[0])}; +}; diff --git a/src/components/view/mottattVurdering/VurderingUnntak.tsx b/src/components/view/mottattVurdering/VurderingUnntak.tsx new file mode 100644 index 00000000..8fbcc138 --- /dev/null +++ b/src/components/view/mottattVurdering/VurderingUnntak.tsx @@ -0,0 +1,20 @@ +import { Unntak, UnntakArsaker } from "@/schema/aktivitetskravVurderingSchema"; +import { BodyLong } from "@navikt/ds-react"; + +const getAarsakAvsnitt = (arsak: UnntakArsaker) => { + switch (arsak) { + case "MEDISINSKE_GRUNNER": + return "NAV har vurdert aktivitetsplikten din og besluttet at du er unntatt fra aktivitetsplikten på grunn av medisinske opplysninger."; + case "TILRETTELEGGING_IKKE_MULIG": + return "NAV har vurdert aktivitetsplikten din og besluttet at du er unntatt fra aktivitetsplikten siden tilrettelegging på arbeidsplassen ikke er mulig."; + case "SJOMENN_UTENRIKS": + return "NAV vurderer at du er unntatt fra aktivitetsplikten."; + } +}; + +interface Props { + vurdering: Unntak; +} +export const VurderingUnntak = ({ vurdering }: Props) => { + return {getAarsakAvsnitt(vurdering.arsaker[0])}; +}; diff --git a/src/components/view/viewUtils.ts b/src/components/view/viewUtils.ts new file mode 100644 index 00000000..618f48c8 --- /dev/null +++ b/src/components/view/viewUtils.ts @@ -0,0 +1,89 @@ +import { AktivitetskravVurdering } from "@/schema/aktivitetskravVurderingSchema"; + +export interface AktivitetskravViewItem { + type: + | "UNDER_BEHANDLING" + | "FORHANDSVARSEL" + | "MOTTATT_VURDERING" + | "IKKE_OPPFYLT"; + vurdering: AktivitetskravVurdering; +} + +export const mapVurderingerToViewItem = ( + vurderinger: AktivitetskravVurdering[], +): AktivitetskravViewItem[] => { + return vurderinger.map((vurdering) => mapVurderingToViewItem(vurdering)); +}; + +export const mapVurderingToViewItem = ( + vurdering: AktivitetskravVurdering, +): AktivitetskravViewItem => { + switch (vurdering.status) { + case "FORHANDSVARSEL": { + return { + type: !!vurdering.document ? "FORHANDSVARSEL" : "UNDER_BEHANDLING", + vurdering: vurdering, + }; + } + case "AVVENT": + case "NY": + case "NY_VURDERING": { + return { + type: "UNDER_BEHANDLING", + vurdering: vurdering, + }; + } + case "UNNTAK": + case "OPPFYLT": + case "IKKE_AKTUELL": + return { + type: "MOTTATT_VURDERING", + vurdering: vurdering, + }; + case "IKKE_OPPFYLT": { + return { + type: "IKKE_OPPFYLT", + vurdering: vurdering, + }; + } + } +}; + +interface SplittedAktivitetskrav { + activeVurdering: AktivitetskravViewItem | null; + historicVurderinger: AktivitetskravViewItem[] | null; +} + +export const getViewItems = ( + aktivitetskrav: AktivitetskravVurdering[], +): SplittedAktivitetskrav => { + if (!aktivitetskrav) { + return { + activeVurdering: null, + historicVurderinger: null, + }; + } + + const copiedAktivitetskrav = [...aktivitetskrav]; + + const aktivitetsKravToViewItems = + mapVurderingerToViewItem(copiedAktivitetskrav); + + const viewItemsWithoutDuplicates = aktivitetsKravToViewItems.filter( + (vurdering, index) => { + const previousVurdering = aktivitetsKravToViewItems[index - 1]; + + if (!previousVurdering) return true; + + return previousVurdering.type !== vurdering.type; + }, + ); + + const activeVurdering: AktivitetskravViewItem | null = + viewItemsWithoutDuplicates.shift() || null; + + return { + activeVurdering: activeVurdering, + historicVurderinger: viewItemsWithoutDuplicates, + }; +}; diff --git a/src/data/api.ts b/src/data/api.ts index aa5b29af..a500612c 100644 --- a/src/data/api.ts +++ b/src/data/api.ts @@ -1,7 +1,7 @@ import { loginUser } from "@/utils/urlUtils"; import { + ForhandsvarselTestScenario, getTestScenario, - InfoSideTestScenario, } from "@/utils/testScenarioUtils"; const testScenarioHeaders = (): Record | undefined => { @@ -10,10 +10,10 @@ const testScenarioHeaders = (): Record | undefined => { process.env.NEXT_PUBLIC_RUNTIME_ENVIRONMENT === "demo" ) { const headers: Record = { - "testscenario": getTestScenario() || InfoSideTestScenario, + testscenario: getTestScenario() || ForhandsvarselTestScenario, }; - return headers + return headers; } }; diff --git a/src/data/dataHooks.tsx b/src/data/dataHooks.tsx new file mode 100644 index 00000000..7fb2644d --- /dev/null +++ b/src/data/dataHooks.tsx @@ -0,0 +1,13 @@ +import { useQuery } from "@tanstack/react-query"; +import { get } from "@/data/api"; +import { AktivitetskravVurdering } from "@/schema/aktivitetskravVurderingSchema"; + +export const useAktivitetskravData = () => { + return useQuery({ + queryKey: ["aktivitetskrav"], + queryFn: () => + get( + `${process.env.NEXT_PUBLIC_ESYFO_PROXY_API_URL}/historikk`!, + ), + }); +}; diff --git a/src/mocks/fixtures.ts b/src/mocks/fixtures.ts index fde296b9..e32c45a6 100644 --- a/src/mocks/fixtures.ts +++ b/src/mocks/fixtures.ts @@ -1,57 +1,152 @@ import { AktivitetskravVurdering } from "@/schema/aktivitetskravVurderingSchema"; -import { addDaysToDate, subtractDaysFromDate } from "@/utils/dateUtils"; +import { addDaysToDate, pastDateAsString } from "@/utils/dateUtils"; import { forhaandsvarselDocumentMock } from "@/mocks/ForhaandsvarselDocumentMock"; -const nyKandidatVurdering: AktivitetskravVurdering = { - status: "NY", +const nyKandidatVurdering = ( + dagerSidenHendelse: number, +): AktivitetskravVurdering => { + return { + status: "NY", + internUuid: "12345", + createdAt: pastDateAsString(dagerSidenHendelse), + }; }; -const unntakVurdering: AktivitetskravVurdering = { - status: "UNNTAK", - sistVurdert: subtractDaysFromDate(new Date(), 5).toISOString(), - arsaker: ["MEDISINSKE_GRUNNER"], +const unntakVurdering = ( + dagerSidenHendelse: number, +): AktivitetskravVurdering => { + return { + status: "UNNTAK", + internUuid: "12346585686585", + createdAt: pastDateAsString(dagerSidenHendelse), + sistVurdert: pastDateAsString(dagerSidenHendelse), + arsaker: ["MEDISINSKE_GRUNNER"], + }; }; -const oppfyltVurdering: AktivitetskravVurdering = { - status: "OPPFYLT", - sistVurdert: subtractDaysFromDate(new Date(), 5).toISOString(), - arsaker: ["TILTAK"], +const oppfyltVurdering = ( + dagerSidenHendelse: number, +): AktivitetskravVurdering => { + return { + status: "OPPFYLT", + internUuid: "244365474", + createdAt: pastDateAsString(dagerSidenHendelse), + sistVurdert: pastDateAsString(dagerSidenHendelse), + arsaker: ["TILTAK"], + }; }; -const ikkeAktuellVurdering: AktivitetskravVurdering = { - status: "IKKE_AKTUELL", - sistVurdert: subtractDaysFromDate(new Date(), 5).toISOString(), +const ikkeAktuellVurdering = ( + dagerSidenHendelse: number, +): AktivitetskravVurdering => { + return { + status: "IKKE_AKTUELL", + internUuid: "686868", + createdAt: pastDateAsString(dagerSidenHendelse), + sistVurdert: pastDateAsString(dagerSidenHendelse), + }; }; -const avventVurdering: AktivitetskravVurdering = { - status: "AVVENT", - sistVurdert: subtractDaysFromDate(new Date(), 5).toISOString(), +const ikkeOppfyltVurdering = ( + dagerSidenHendelse: number, +): AktivitetskravVurdering => { + return { + status: "IKKE_OPPFYLT", + internUuid: "55554444", + createdAt: pastDateAsString(dagerSidenHendelse), + sistVurdert: pastDateAsString(dagerSidenHendelse), + }; }; -const forhaandsvarselVurdering: AktivitetskravVurdering = { - status: "FORHANDSVARSEL", - sistVurdert: subtractDaysFromDate(new Date(), 5).toISOString(), - journalpostId: "123", - fristDato: addDaysToDate(new Date(), 14).toISOString(), - document: forhaandsvarselDocumentMock, +const avventVurdering = ( + dagerSidenHendelse: number, +): AktivitetskravVurdering => { + return { + status: "AVVENT", + internUuid: "77322357", + createdAt: pastDateAsString(dagerSidenHendelse), + sistVurdert: pastDateAsString(dagerSidenHendelse), + }; }; -const forhaandsvarselVurderingWithoutDocument: AktivitetskravVurdering = { - status: "FORHANDSVARSEL", - sistVurdert: subtractDaysFromDate(new Date(), 5).toISOString(), - journalpostId: null, - fristDato: addDaysToDate(new Date(), 14).toISOString(), - document: null, +const forhaandsvarselVurdering = ( + dagerSidenHendelse: number, +): AktivitetskravVurdering => { + return { + status: "FORHANDSVARSEL", + internUuid: "457474547547", + createdAt: pastDateAsString(dagerSidenHendelse), + sistVurdert: pastDateAsString(dagerSidenHendelse), + journalpostId: "123", + fristDato: addDaysToDate(new Date(), 14).toISOString(), + document: forhaandsvarselDocumentMock, + }; }; +const forhaandsvarselVurderingWithoutDocument = ( + dagerSidenHendelse: number, +): AktivitetskravVurdering => { + return { + status: "FORHANDSVARSEL", + internUuid: "1231231313", + createdAt: pastDateAsString(dagerSidenHendelse), + sistVurdert: pastDateAsString(dagerSidenHendelse), + journalpostId: null, + fristDato: addDaysToDate(new Date(), 14).toISOString(), + document: null, + }; +}; + +const forhaandsvarselFixtureWithoutDocument: AktivitetskravVurdering[] = [ + forhaandsvarselVurderingWithoutDocument(10), + avventVurdering(25), + nyKandidatVurdering(30), +]; + +const nyKandidatFixture: AktivitetskravVurdering[] = [nyKandidatVurdering(12)]; + +const unntakFixture: AktivitetskravVurdering[] = [ + unntakVurdering(4), + forhaandsvarselVurdering(15), + avventVurdering(24), + nyKandidatVurdering(33), +]; + +const oppfyltFixture: AktivitetskravVurdering[] = [ + oppfyltVurdering(1), + forhaandsvarselVurdering(15), + avventVurdering(21), + nyKandidatVurdering(28), +]; + +const ikkeOppfyltFixture: AktivitetskravVurdering[] = [ + ikkeOppfyltVurdering(1), + forhaandsvarselVurdering(4), + avventVurdering(7), + nyKandidatVurdering(14), +]; + +const ikkeAktuellFixture: AktivitetskravVurdering[] = [ + ikkeAktuellVurdering(13), + forhaandsvarselVurdering(20), + avventVurdering(28), + nyKandidatVurdering(29), +]; + +const forhaandsvarselFixture: AktivitetskravVurdering[] = [ + forhaandsvarselVurdering(11), + avventVurdering(21), + nyKandidatVurdering(28), +]; + const fixtures = { - nyKandidatVurdering, - unntakVurdering, - oppfyltVurdering, - ikkeAktuellVurdering, - forhaandsvarselVurdering, - forhaandsvarselVurderingWithoutDocument, - avventVurdering, + forhaandsvarselFixture, + forhaandsvarselFixtureWithoutDocument, + nyKandidatFixture, + unntakFixture, + ikkeAktuellFixture, + ikkeOppfyltFixture, + oppfyltFixture, }; export default fixtures; diff --git a/src/pages/[uuid]/index.tsx b/src/pages/[uuid]/index.tsx new file mode 100644 index 00000000..bb32e422 --- /dev/null +++ b/src/pages/[uuid]/index.tsx @@ -0,0 +1,50 @@ +import React from "react"; +import { NextPage } from "next"; +import { AktivitetskravVurdering } from "@/schema/aktivitetskravVurderingSchema"; +import { AktivitetskravSkeletonComponent } from "@/components/skeleton/AktivitetskravSkeletonComponent"; +import { useAktivitetskravData } from "@/data/dataHooks"; +import { mapVurderingToViewItem } from "@/components/view/viewUtils"; +import { AktivitetskravBox } from "@/components/box/AktivitetskravBox"; +import { Vurdering } from "@/components/view/Vurdering"; +import { useRouter } from "next/router"; +import { Page } from "@/components/page/Page"; + +interface Props { + uuidToDisplay: string | string[] | undefined; + vurderinger: AktivitetskravVurdering[]; +} +const DetailedView = ({ uuidToDisplay, vurderinger }: Props) => { + const viewItem = vurderinger.find( + (vurdering) => vurdering.internUuid === uuidToDisplay, + ); + + if (viewItem) { + return ( + + + + + + ); + } + + throw new Error("Could not find viewItem"); +}; + +const DetailsPage: NextPage = () => { + const { isPending, error, data } = useAktivitetskravData(); + const router = useRouter(); + const uuid = router.query.uuid; + + if (error) { + throw error; + } + + return isPending ? ( + + ) : ( + + ); +}; + +export default DetailsPage; diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index a6011503..34b5e395 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -13,6 +13,9 @@ import { ErrorBoundary } from "@/components/error/ErrorBoundary"; import { initFaro } from "@/faro/initFaro"; import { TestScenarioSelector } from "@/components/testscenarioselector/TestScenarioSelector"; import { getTestScenario, setTestScenario } from "@/utils/testScenarioUtils"; +import { setBreadcrumbs } from "@navikt/nav-dekoratoren-moduler"; +import { useRouter } from "next/router"; +import { createBreadcrumbs } from "@/breadcrumbs/breadcrumbs"; configureLogger({ basePath: "/syk/aktivitetskrav", @@ -22,6 +25,7 @@ function MyApp({ Component, pageProps, }: AppProps<{ dehydratedState: DehydratedState }>) { + const { pathname } = useRouter(); const [queryClient] = useState( () => new QueryClient({ @@ -38,14 +42,18 @@ function MyApp({ initFaro(); }, []); + useEffect(() => { + setBreadcrumbs(createBreadcrumbs(pathname)); + }, [pathname]); + const TestScenarioDevTools = () => { if ( process.env.NEXT_PUBLIC_RUNTIME_ENVIRONMENT === "local" || process.env.NEXT_PUBLIC_RUNTIME_ENVIRONMENT === "demo" ) { - const hasActiveScenario = !!getTestScenario() + const hasActiveScenario = !!getTestScenario(); if (!hasActiveScenario) { - setTestScenario("INFOSIDE"); + setTestScenario("FORHANDSVARSEL"); } return ; diff --git a/src/pages/_document.tsx b/src/pages/_document.tsx index 09d0d890..838aa08a 100644 --- a/src/pages/_document.tsx +++ b/src/pages/_document.tsx @@ -10,7 +10,7 @@ import Document, { Main, NextScript, } from "next/document"; -import { AktivitetspliktCrumbs } from "@/breadcrumbs/breadcrumbs"; +import { AktivitetspliktBaseCrumbs } from "@/breadcrumbs/breadcrumbs"; // The 'head'-field of the document initialProps contains data from (meta-tags etc) const getDocumentParameter = ( @@ -41,7 +41,7 @@ export default class MyDocument extends Document { level: "Level4", urlLookupTable: false, logoutWarning: true, - breadcrumbs: AktivitetspliktCrumbs, + breadcrumbs: AktivitetspliktBaseCrumbs, }, }); diff --git a/src/pages/api/aktivitetsplikt/index.ts b/src/pages/api/aktivitetsplikt/historikk/index.ts similarity index 92% rename from src/pages/api/aktivitetsplikt/index.ts rename to src/pages/api/aktivitetsplikt/historikk/index.ts index 133b3b95..5b4ec12d 100644 --- a/src/pages/api/aktivitetsplikt/index.ts +++ b/src/pages/api/aktivitetsplikt/historikk/index.ts @@ -7,7 +7,7 @@ import { export default function handler( _req: NextApiRequest, - res: NextApiResponse, + res: NextApiResponse, ) { if ( process.env.NEXT_PUBLIC_RUNTIME_ENVIRONMENT === "local" || diff --git a/src/pages/index.tsx b/src/pages/index.tsx index f393e21f..bb3a4eb0 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -1,19 +1,11 @@ import React from "react"; import { Aktivitetskrav } from "@/components/Aktivitetskrav"; -import { useQuery } from "@tanstack/react-query"; import { NextPage } from "next"; -import { get } from "@/data/api"; -import { AktivitetskravVurdering } from "@/schema/aktivitetskravVurderingSchema"; import { AktivitetskravSkeletonComponent } from "@/components/skeleton/AktivitetskravSkeletonComponent"; +import { useAktivitetskravData } from "@/data/dataHooks"; const Home: NextPage = () => { - const { isPending, error, data } = useQuery({ - queryKey: ["aktivitetskrav"], - queryFn: () => - get( - process.env.NEXT_PUBLIC_ESYFO_PROXY_API_URL!, - ), - }); + const { isPending, error, data } = useAktivitetskravData(); if (error) { throw error; diff --git a/src/schema/aktivitetskravVurderingSchema.ts b/src/schema/aktivitetskravVurderingSchema.ts index 4c00e299..56e7ede9 100644 --- a/src/schema/aktivitetskravVurderingSchema.ts +++ b/src/schema/aktivitetskravVurderingSchema.ts @@ -1,6 +1,17 @@ import { literal, object, string, union, z } from "zod"; import { documentComponentSchema } from "@/schema/documentComponentSchema"; +const VurderingStatusSchema = z.union([ + literal("UNNTAK"), + literal("OPPFYLT"), + literal("NY"), + literal("NY_VURDERING"), + literal("AVVENT"), + literal("FORHANDSVARSEL"), + literal("IKKE_OPPFYLT"), + literal("IKKE_AKTUELL"), +]); + const unntakArsaker = z.union([ literal("MEDISINSKE_GRUNNER"), literal("TILRETTELEGGING_IKKE_MULIG"), @@ -13,43 +24,79 @@ const oppfyltArsaker = z.union([ literal("TILTAK"), ]); +export const BaseVurdering = object({ + status: VurderingStatusSchema, + createdAt: string().datetime(), + internUuid: string(), +}); + +export const UnntakSchema = BaseVurdering.extend({ + status: z.literal("UNNTAK"), + arsaker: z.array(unntakArsaker), + sistVurdert: string().datetime(), +}); + +export const OppfyltSchema = BaseVurdering.extend({ + status: z.literal("OPPFYLT"), + arsaker: z.array(oppfyltArsaker), + sistVurdert: string().datetime(), +}); + +export const NySchema = BaseVurdering.extend({ + status: z.literal("NY"), + sistVurdert: string().datetime().nullish(), +}); + +export const NyVurderingSchema = BaseVurdering.extend({ + status: z.literal("NY_VURDERING"), + sistVurdert: string().datetime().nullish(), +}); + +export const AvventSchema = BaseVurdering.extend({ + status: z.literal("AVVENT"), + sistVurdert: string().datetime(), +}); + +export const ForhandsvarselSchema = BaseVurdering.extend({ + status: z.literal("FORHANDSVARSEL"), + journalpostId: string().nullish(), + sistVurdert: string().datetime(), + fristDato: string().datetime(), + document: z.array(documentComponentSchema).nullable(), +}); + +export const IkkeOppfyltSchema = BaseVurdering.extend({ + status: z.literal("IKKE_OPPFYLT"), + sistVurdert: string().datetime(), +}); + +export const IkkeAktuellSchema = BaseVurdering.extend({ + status: z.literal("IKKE_AKTUELL"), + sistVurdert: string().datetime(), +}); + export const aktivitetskravVurderingSchema = union([ - object({ - status: z.literal("UNNTAK"), - arsaker: z.array(unntakArsaker), - sistVurdert: string().datetime(), - }), - object({ - status: z.literal("OPPFYLT"), - arsaker: z.array(oppfyltArsaker), - sistVurdert: string().datetime(), - }), - object({ - status: z.literal("NY"), - }), - object({ - status: z.literal("AVVENT"), - sistVurdert: string().datetime(), - }), - object({ - status: z.literal("FORHANDSVARSEL"), - journalpostId: string().nullish(), - sistVurdert: string().datetime(), - fristDato: string().datetime(), - document: z.array(documentComponentSchema).nullable(), - }), - object({ - status: z.literal("IKKE_OPPFYLT"), - sistVurdert: string().datetime(), - }), - object({ - status: z.literal("IKKE_AKTUELL"), - sistVurdert: string().datetime(), - }), + UnntakSchema, + OppfyltSchema, + NySchema, + NyVurderingSchema, + AvventSchema, + ForhandsvarselSchema, + IkkeOppfyltSchema, + IkkeAktuellSchema, ]); export type AktivitetskravVurdering = z.infer< typeof aktivitetskravVurderingSchema >; + +export type Unntak = z.infer; +export type Oppfylt = z.infer; +export type Ny = z.infer; +export type NyVurdering = z.infer; +export type Avvent = z.infer; +export type Forhandsvarsel = z.infer; +export type IkkeOppfylt = z.infer; +export type IkkeAktuell = z.infer; export type UnntakArsaker = z.infer; export type OppfyltArsaker = z.infer; diff --git a/src/utils/dateUtils.ts b/src/utils/dateUtils.ts index 37a23517..4d75d98b 100644 --- a/src/utils/dateUtils.ts +++ b/src/utils/dateUtils.ts @@ -76,3 +76,7 @@ export function subtractDaysFromDate(date: Date, daysToSubtract: number) { nyDato.setTime(newTime); return nyDato; } + +export const pastDateAsString = (daysSince: number): string => { + return subtractDaysFromDate(new Date(), daysSince).toISOString() +} diff --git a/src/utils/testScenarioUtils.ts b/src/utils/testScenarioUtils.ts index 475dd590..7bf76b47 100644 --- a/src/utils/testScenarioUtils.ts +++ b/src/utils/testScenarioUtils.ts @@ -3,10 +3,18 @@ import { AktivitetskravVurdering } from "@/schema/aktivitetskravVurderingSchema" export type TestScenario = | typeof InfoSideTestScenario + | typeof IkkeAktuellTestScenario + | typeof IkkeOppfyltTestScenario + | typeof UnntakTestScenario + | typeof OppfyltTestScenario | typeof ForhandsvarselTestScenario; export const InfoSideTestScenario = "INFOSIDE"; export const ForhandsvarselTestScenario = "FORHANDSVARSEL"; +export const IkkeAktuellTestScenario = "IKKEAKTUELL"; +export const IkkeOppfyltTestScenario = "IKKEOPPFYLT"; +export const UnntakTestScenario = "UNNTAK"; +export const OppfyltTestScenario = "OPPFYLT"; export const setTestScenario = (testScenario: TestScenario) => { if (typeof window !== "undefined") { @@ -22,13 +30,27 @@ export const getTestScenario = (): TestScenario | undefined => { } }; -export const getAktivitetskravVurderingForScenario = (testScenario: TestScenario): AktivitetskravVurdering => { +export const getAktivitetskravVurderingForScenario = ( + testScenario: TestScenario, +): AktivitetskravVurdering[] => { switch (testScenario) { case "INFOSIDE": { - return fixtures.nyKandidatVurdering; + return fixtures.nyKandidatFixture; } case "FORHANDSVARSEL": { - return fixtures.forhaandsvarselVurdering; + return fixtures.forhaandsvarselFixture; + } + case "OPPFYLT": { + return fixtures.oppfyltFixture; + } + case "IKKEAKTUELL": { + return fixtures.ikkeAktuellFixture; + } + case "IKKEOPPFYLT": { + return fixtures.ikkeOppfyltFixture; + } + case "UNNTAK": { + return fixtures.unntakFixture; } } }; diff --git a/tailwind.config.ts b/tailwind.config.ts index 2eee182a..b73fc128 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -16,6 +16,10 @@ const config: Config = { colors: { 'ds-gray-50': '#f7f7f7', 'header-color': '#d1eff9', + 'aksel-info-color': 'var(--ac-alert-icon-info-color, var(--a-icon-info))', + 'aksel-warning-color': 'var(--ac-alert-icon-warning-color, var(--a-icon-warning))', + 'aksel-success-color': 'var(--ac-alert-icon-success-color, var(--a-icon-success))', + 'aksel-error-color': 'var(--ac-alert-icon-error-color, var(--a-icon-danger))', }, }, },