diff --git a/src/sider/oppfolgingsplan/container/OppfoelgingsPlanerOversiktContainer.tsx b/src/sider/oppfolgingsplan/container/OppfoelgingsPlanerOversiktContainer.tsx
index 72ce29e09..f55a10a8f 100644
--- a/src/sider/oppfolgingsplan/container/OppfoelgingsPlanerOversiktContainer.tsx
+++ b/src/sider/oppfolgingsplan/container/OppfoelgingsPlanerOversiktContainer.tsx
@@ -1,7 +1,6 @@
import React from "react";
import Side from "../../Side";
import OppfolgingsplanerOversikt from "../oppfolgingsplaner/OppfolgingsplanerOversikt";
-import IngenPlaner from "../oppfolgingsplaner/IngenPlaner";
import { activeOppfolgingsplaner } from "@/utils/oppfolgingsplanerUtils";
import SideLaster from "../../../components/SideLaster";
import { useValgtPersonident } from "@/hooks/useValgtBruker";
@@ -33,10 +32,6 @@ export const OppfoelgingsPlanerOversiktContainer = () => {
const inaktivePlaner = oppfolgingsplaner.filter(
(plan) => !aktivePlaner.includes(plan)
);
- const hasNoPlans =
- aktivePlaner.length === 0 &&
- inaktivePlaner.length === 0 &&
- oppfolgingsplanerLPS.length === 0;
return (
{
aktivtMenypunkt={Menypunkter.OPPFOELGINGSPLANER}
>
- {(() => {
- if (hasNoPlans) {
- return ;
- } else {
- return (
-
- );
- }
- })()}
+
);
diff --git a/src/sider/oppfolgingsplan/oppfolgingsplaner/AktiveOppfolgingsplaner.tsx b/src/sider/oppfolgingsplan/oppfolgingsplaner/AktiveOppfolgingsplaner.tsx
new file mode 100644
index 000000000..6f8f99716
--- /dev/null
+++ b/src/sider/oppfolgingsplan/oppfolgingsplaner/AktiveOppfolgingsplaner.tsx
@@ -0,0 +1,153 @@
+import { Alert, Heading } from "@navikt/ds-react";
+import BeOmOppfolgingsplan from "@/sider/oppfolgingsplan/oppfolgingsplaner/BeOmOppfolgingsplan";
+import OppfolgingsplanerOversiktLPS from "@/sider/oppfolgingsplan/lps/OppfolgingsplanerOversiktLPS";
+import OppfolgingsplanLink from "@/sider/oppfolgingsplan/oppfolgingsplaner/OppfolgingsplanLink";
+import React from "react";
+import { erIdag, tilLesbarDatoMedArUtenManedNavn } from "@/utils/datoUtils";
+import dayjs from "dayjs";
+import { useLedereQuery } from "@/data/leder/ledereQueryHooks";
+import {
+ useGetOppfolgingsplanForesporselQuery,
+ usePostOppfolgingsplanForesporsel,
+} from "@/data/oppfolgingsplan/oppfolgingsplanForesporselHooks";
+import { useOppfolgingstilfellePersonQuery } from "@/data/oppfolgingstilfelle/person/oppfolgingstilfellePersonQueryHooks";
+import { useFeatureToggles } from "@/data/unleash/unleashQueryHooks";
+import { NarmesteLederRelasjonDTO } from "@/data/leder/ledereTypes";
+import { OppfolgingstilfelleDTO } from "@/data/oppfolgingstilfelle/person/types/OppfolgingstilfellePersonDTO";
+import { OppfolgingsplanLPSMedPersonoppgave } from "@/data/oppfolgingsplan/types/OppfolgingsplanLPS";
+import { OppfolgingsplanDTO } from "@/data/oppfolgingsplan/types/OppfolgingsplanDTO";
+
+const texts = {
+ aktiveOppfolgingsplaner: "Aktive oppfølgingsplaner",
+ ingenAktiveOppfolgingsplaner: "Det er ingen aktive oppfølgingsplaner",
+ foresporselSendt: "Forespørsel om oppfølgingsplan ble sendt",
+ aktivForesporsel:
+ "Obs! Det ble bedt om oppfølgingsplan fra denne arbeidsgiveren",
+};
+
+function activeNarmesteLederForCurrentOppfolgingstilfelle(
+ ledere: NarmesteLederRelasjonDTO[],
+ oppfolgingsTilfelle: OppfolgingstilfelleDTO
+): NarmesteLederRelasjonDTO[] {
+ return ledere.filter(
+ (leder) =>
+ leder.status === "INNMELDT_AKTIV" &&
+ oppfolgingsTilfelle.virksomhetsnummerList.includes(
+ leder.virksomhetsnummer
+ )
+ );
+}
+
+interface Props {
+ aktivePlaner: OppfolgingsplanDTO[];
+ oppfolgingsplanerLPSMedPersonoppgave: OppfolgingsplanLPSMedPersonoppgave[];
+}
+
+export default function AktiveOppfolgingsplaner({
+ aktivePlaner,
+ oppfolgingsplanerLPSMedPersonoppgave,
+}: Props) {
+ const { toggles } = useFeatureToggles();
+ const { currentLedere } = useLedereQuery();
+ const getOppfolgingsplanForesporsel = useGetOppfolgingsplanForesporselQuery();
+ const postOppfolgingsplanForesporsel = usePostOppfolgingsplanForesporsel();
+ const { latestOppfolgingstilfelle, hasActiveOppfolgingstilfelle } =
+ useOppfolgingstilfellePersonQuery();
+ const currentOppfolgingstilfelle = hasActiveOppfolgingstilfelle
+ ? latestOppfolgingstilfelle
+ : undefined;
+
+ const oppfolgingsplanerLPSUnprocessed = oppfolgingsplanerLPSMedPersonoppgave
+ .filter((oppfolgingsplanLPS) => {
+ if (oppfolgingsplanLPS.personoppgave) {
+ if (oppfolgingsplanLPS.personoppgave.behandletTidspunkt) {
+ return (
+ Date.now() <
+ dayjs(oppfolgingsplanLPS.personoppgave.behandletTidspunkt)
+ .add(1, "days")
+ .toDate()
+ .getTime()
+ );
+ }
+ return !oppfolgingsplanLPS.personoppgave.behandletTidspunkt;
+ }
+ return erIdag(oppfolgingsplanLPS.opprettet);
+ })
+ .sort((a, b) => {
+ return new Date(b.opprettet).getTime() - new Date(a.opprettet).getTime();
+ });
+
+ const hasActivePlan =
+ aktivePlaner.length !== 0 || oppfolgingsplanerLPSUnprocessed.length !== 0;
+
+ const activeNarmesteLedere = !!currentOppfolgingstilfelle
+ ? activeNarmesteLederForCurrentOppfolgingstilfelle(
+ currentLedere,
+ currentOppfolgingstilfelle
+ )
+ : [];
+ const activeNarmesteLederIfSingle =
+ activeNarmesteLedere.length === 1 ? activeNarmesteLedere[0] : undefined;
+ const isBeOmOppfolgingsplanVisible =
+ toggles.isBeOmOppfolgingsplanEnabled &&
+ !hasActivePlan &&
+ !!currentOppfolgingstilfelle &&
+ !!activeNarmesteLederIfSingle &&
+ !postOppfolgingsplanForesporsel.isSuccess;
+
+ const lastForesporselCreatedAt =
+ getOppfolgingsplanForesporsel.data?.[0]?.createdAt;
+
+ const isAktivForesporsel =
+ !!lastForesporselCreatedAt &&
+ !!currentOppfolgingstilfelle &&
+ !postOppfolgingsplanForesporsel.isSuccess
+ ? currentOppfolgingstilfelle.start <= lastForesporselCreatedAt &&
+ lastForesporselCreatedAt <= currentOppfolgingstilfelle.end
+ : false;
+ const aktivForesporselTekst = `${
+ texts.aktivForesporsel
+ } ${tilLesbarDatoMedArUtenManedNavn(lastForesporselCreatedAt)}`;
+
+ return (
+
+
+ {texts.aktiveOppfolgingsplaner}
+
+ {!hasActivePlan &&
+ !postOppfolgingsplanForesporsel.isSuccess &&
+ !isAktivForesporsel && (
+
+ {texts.ingenAktiveOppfolgingsplaner}
+
+ )}
+ {isAktivForesporsel && (
+
+ {aktivForesporselTekst}
+
+ )}
+ {postOppfolgingsplanForesporsel.isSuccess && (
+
+ {texts.foresporselSendt}
+
+ )}
+ {isBeOmOppfolgingsplanVisible && (
+
+ )}
+ {oppfolgingsplanerLPSUnprocessed.map((planLPS, index) => {
+ return (
+
+ );
+ })}
+ {aktivePlaner.map((dialog, index) => {
+ return
;
+ })}
+
+ );
+}
diff --git a/src/sider/oppfolgingsplan/oppfolgingsplaner/BeOmOppfolgingsplan.tsx b/src/sider/oppfolgingsplan/oppfolgingsplaner/BeOmOppfolgingsplan.tsx
index ead524853..a84d42ed6 100644
--- a/src/sider/oppfolgingsplan/oppfolgingsplaner/BeOmOppfolgingsplan.tsx
+++ b/src/sider/oppfolgingsplan/oppfolgingsplaner/BeOmOppfolgingsplan.tsx
@@ -1,23 +1,11 @@
-import {
- Alert,
- BodyLong,
- BodyShort,
- Box,
- Button,
- Heading,
-} from "@navikt/ds-react";
+import { BodyLong, BodyShort, Box, Button, Heading } from "@navikt/ds-react";
import React from "react";
import { useValgtPersonident } from "@/hooks/useValgtBruker";
import { NarmesteLederRelasjonDTO } from "@/data/leder/ledereTypes";
-import { OppfolgingstilfelleDTO } from "@/data/oppfolgingstilfelle/person/types/OppfolgingstilfellePersonDTO";
-import { tilLesbarDatoMedArUtenManedNavn } from "@/utils/datoUtils";
import * as Amplitude from "@/utils/amplitude";
import { EventType } from "@/utils/amplitude";
-import {
- NewOppfolgingsplanForesporselDTO,
- useGetOppfolgingsplanForesporselQuery,
- usePostOppfolgingsplanForesporsel,
-} from "@/data/oppfolgingsplan/oppfolgingsplanForesporselHooks";
+import { NewOppfolgingsplanForesporselDTO } from "@/data/oppfolgingsplan/oppfolgingsplanForesporselHooks";
+import { UseMutationResult } from "@tanstack/react-query";
const texts = {
header: "Be om oppfølgingsplan fra arbeidsgiver",
@@ -25,8 +13,6 @@ const texts = {
"Her kan du be om oppfølgingsplan fra arbeidsgiver eller purre om det mangler.",
virksomhet: "Virksomhet:",
narmesteLeder: "Nærmeste leder:",
- aktivForesporsel:
- "Obs! Det ble bedt om oppfølgingsplan fra denne arbeidsgiveren",
button: "Be om oppfølgingsplan",
};
@@ -42,17 +28,19 @@ function logOppfolgingsplanForesporselEvent() {
interface Props {
aktivNarmesteLeder: NarmesteLederRelasjonDTO;
- currentOppfolgingstilfelle: OppfolgingstilfelleDTO;
+ postOppfolgingsplanForesporsel: UseMutationResult<
+ NewOppfolgingsplanForesporselDTO,
+ Error,
+ NewOppfolgingsplanForesporselDTO,
+ unknown
+ >;
}
export default function BeOmOppfolgingsplan({
aktivNarmesteLeder,
- currentOppfolgingstilfelle,
+ postOppfolgingsplanForesporsel,
}: Props) {
const personident = useValgtPersonident();
- const getOppfolgingsplanForesporsel = useGetOppfolgingsplanForesporselQuery();
-
- const postOppfolgingsplanForesporsel = usePostOppfolgingsplanForesporsel();
function onClick() {
const foresporsel: NewOppfolgingsplanForesporselDTO = {
@@ -67,47 +55,26 @@ export default function BeOmOppfolgingsplan({
});
}
- const lastForesporselCreatedAt =
- getOppfolgingsplanForesporsel.data?.[0]?.createdAt;
-
- const isAktivForesporsel = !!lastForesporselCreatedAt
- ? currentOppfolgingstilfelle.start <= lastForesporselCreatedAt &&
- lastForesporselCreatedAt <= currentOppfolgingstilfelle.end
- : false;
- const aktivForesporselTekst = `${
- texts.aktivForesporsel
- } ${tilLesbarDatoMedArUtenManedNavn(lastForesporselCreatedAt)}`;
-
return (
- <>
- {postOppfolgingsplanForesporsel.isSuccess && (
-
- Forespørsel om oppfølgingsplan ble sendt
-
- )}
-
- {texts.header}
- {texts.description}
-
- {texts.virksomhet} {aktivNarmesteLeder.virksomhetsnavn}
-
-
- {texts.narmesteLeder} {aktivNarmesteLeder.narmesteLederNavn}
-
- {isAktivForesporsel && !!lastForesporselCreatedAt && (
-
- {aktivForesporselTekst}
-
- )}
-
-
- >
+
+
+ {texts.header}
+
+ {texts.description}
+
+ {texts.virksomhet} {aktivNarmesteLeder.virksomhetsnavn}
+
+
+ {texts.narmesteLeder} {aktivNarmesteLeder.narmesteLederNavn}
+
+
+
);
}
diff --git a/src/sider/oppfolgingsplan/oppfolgingsplaner/OppfolgingsplanerOversikt.tsx b/src/sider/oppfolgingsplan/oppfolgingsplaner/OppfolgingsplanerOversikt.tsx
index 55f17ea70..b35b7f6b2 100644
--- a/src/sider/oppfolgingsplan/oppfolgingsplaner/OppfolgingsplanerOversikt.tsx
+++ b/src/sider/oppfolgingsplan/oppfolgingsplaner/OppfolgingsplanerOversikt.tsx
@@ -1,48 +1,26 @@
import React from "react";
-import dayjs from "dayjs";
-import Alertstripe from "nav-frontend-alertstriper";
import Sidetopp from "../../../components/Sidetopp";
-import { erIdag, erIkkeIdag } from "@/utils/datoUtils";
+import { erIkkeIdag } from "@/utils/datoUtils";
import OppfolgingsplanerOversiktLPS from "../lps/OppfolgingsplanerOversiktLPS";
import { OppfolgingsplanLPS } from "@/data/oppfolgingsplan/types/OppfolgingsplanLPS";
import { usePersonoppgaverQuery } from "@/data/personoppgave/personoppgaveQueryHooks";
import { OppfolgingsplanDTO } from "@/data/oppfolgingsplan/types/OppfolgingsplanDTO";
import { toOppfolgingsplanLPSMedPersonoppgave } from "@/utils/oppfolgingsplanerUtils";
-import { Heading } from "@navikt/ds-react";
+import { BodyShort, Box, Heading } from "@navikt/ds-react";
import OppfolgingsplanLink from "@/sider/oppfolgingsplan/oppfolgingsplaner/OppfolgingsplanLink";
-import { useLedereQuery } from "@/data/leder/ledereQueryHooks";
-import { NarmesteLederRelasjonDTO } from "@/data/leder/ledereTypes";
-import { useOppfolgingstilfellePersonQuery } from "@/data/oppfolgingstilfelle/person/oppfolgingstilfellePersonQueryHooks";
-import { OppfolgingstilfelleDTO } from "@/data/oppfolgingstilfelle/person/types/OppfolgingstilfellePersonDTO";
-import { useFeatureToggles } from "@/data/unleash/unleashQueryHooks";
-import BeOmOppfolgingsplan from "@/sider/oppfolgingsplan/oppfolgingsplaner/BeOmOppfolgingsplan";
+import AktiveOppfolgingsplaner from "@/sider/oppfolgingsplan/oppfolgingsplaner/AktiveOppfolgingsplaner";
const texts = {
titles: {
- relevantOppfolgingsplaner: "Aktive oppfølgingsplaner",
- inactiveOppfolgingsplaner: "Tidligere oppfølgingsplaner",
+ tidligereOppfolgingsplaner: "Tidligere oppfølgingsplaner",
lpsOppfolgingsplaner: "Oppfølgingsplaner med bistandsbehov",
},
alertMessages: {
- noRelevantOppfolgingsplaner: "Det er ingen aktive oppfølgingsplaner.",
- noInactiveOppfolgingsplaner: "Det er ingen tidligere oppfølgingsplaner.",
+ ingenTidligereOppfolgingsplaner: "Det er ingen tidligere oppfølgingsplaner",
noLPSOppfolgingsplaner: "Det er ingen oppfølgingsplaner med bistandsbehov",
},
};
-function activeNarmesteLederForCurrentOppfolgingstilfelle(
- ledere: NarmesteLederRelasjonDTO[],
- oppfolgingsTilfelle: OppfolgingstilfelleDTO
-): NarmesteLederRelasjonDTO[] {
- return ledere.filter(
- (leder) =>
- leder.status === "INNMELDT_AKTIV" &&
- oppfolgingsTilfelle.virksomhetsnummerList.includes(
- leder.virksomhetsnummer
- )
- );
-}
-
interface Props {
aktivePlaner: OppfolgingsplanDTO[];
inaktivePlaner: OppfolgingsplanDTO[];
@@ -50,48 +28,24 @@ interface Props {
oppfolgingsplanerLPS: OppfolgingsplanLPS[];
}
-export default function OppfolgingsplanerOversikt(props: Props) {
- const { toggles } = useFeatureToggles();
+export default function OppfolgingsplanerOversikt({
+ aktivePlaner,
+ inaktivePlaner,
+ oppfolgingsplanerLPS,
+}: Props) {
const { data: personoppgaver } = usePersonoppgaverQuery();
- const { currentLedere } = useLedereQuery();
- const { latestOppfolgingstilfelle, hasActiveOppfolgingstilfelle } =
- useOppfolgingstilfellePersonQuery();
- const currentOppfolgingstillfelle = hasActiveOppfolgingstilfelle
- ? latestOppfolgingstilfelle
- : undefined;
-
- const { aktivePlaner, inaktivePlaner, oppfolgingsplanerLPS } = props;
const oppfolgingsplanerLPSMedPersonOppgave = oppfolgingsplanerLPS.map(
(oppfolgingsplanLPS) =>
toOppfolgingsplanLPSMedPersonoppgave(oppfolgingsplanLPS, personoppgaver)
);
- const oppfolgingsplanerLPSUnprocessed = oppfolgingsplanerLPSMedPersonOppgave
- .filter((oppfolgingsplanLPS) => {
- if (oppfolgingsplanLPS.personoppgave) {
- if (oppfolgingsplanLPS.personoppgave.behandletTidspunkt) {
- return (
- Date.now() <
- dayjs(oppfolgingsplanLPS.personoppgave.behandletTidspunkt)
- .add(1, "days")
- .toDate()
- .getTime()
- );
- }
- return !oppfolgingsplanLPS.personoppgave.behandletTidspunkt;
- }
- return erIdag(oppfolgingsplanLPS.opprettet);
- })
- .sort((a, b) => {
- return new Date(b.opprettet).getTime() - new Date(a.opprettet).getTime();
- });
-
const oppfolgingsplanerLPSProcessed = oppfolgingsplanerLPSMedPersonOppgave
.filter((oppfolgingsplanLPS) => {
if (oppfolgingsplanLPS.personoppgave) {
return oppfolgingsplanLPS.personoppgave.behandletTidspunkt;
+ } else {
+ return erIkkeIdag(oppfolgingsplanLPS.opprettet);
}
- return erIkkeIdag(oppfolgingsplanLPS.opprettet);
})
.sort((a, b) => {
return new Date(b.opprettet).getTime() - new Date(a.opprettet).getTime();
@@ -111,75 +65,43 @@ export default function OppfolgingsplanerOversikt(props: Props) {
);
});
- const hasNoActivePlans =
- aktivePlaner.length === 0 && oppfolgingsplanerLPSUnprocessed.length === 0;
- const hasNoInactivePlans =
- inaktivePlaner.length === 0 && oppfolgingsplanerLPSProcessed.length === 0;
-
- const activeNarmesteLedere = !!currentOppfolgingstillfelle
- ? activeNarmesteLederForCurrentOppfolgingstilfelle(
- currentLedere,
- currentOppfolgingstillfelle
- )
- : [];
- const activeNarmesteLederIfSingle =
- activeNarmesteLedere.length === 1 ? activeNarmesteLedere[0] : undefined;
- const isBeOmOppfolgingsplanEnabled =
- toggles.isBeOmOppfolgingsplanEnabled &&
- !!currentOppfolgingstillfelle &&
- !!activeNarmesteLederIfSingle;
+ const hasTidligereOppfolgingsplaner =
+ inaktivePlaner.length !== 0 || oppfolgingsplanerLPSProcessed.length !== 0;
return (
- {isBeOmOppfolgingsplanEnabled && (
-
- )}
-
-
-
- {texts.titles.relevantOppfolgingsplaner}
-
- {hasNoActivePlans && (
-
- {texts.alertMessages.noRelevantOppfolgingsplaner}
-
- )}
- {oppfolgingsplanerLPSUnprocessed.map((planLPS, index) => {
- return (
-
- );
- })}
- {aktivePlaner.map((dialog, index) => {
- return
;
- })}
-
+
- {texts.titles.inactiveOppfolgingsplaner}
+ {texts.titles.tidligereOppfolgingsplaner}
- {hasNoInactivePlans && (
-
- {texts.alertMessages.noInactiveOppfolgingsplaner}
-
+ {hasTidligereOppfolgingsplaner ? (
+ <>
+ {inaktivePlaner.map((dialog, index) => {
+ return
;
+ })}
+ {oppfolgingsplanerLPSProcessed.map((planLPS, index) => {
+ return (
+
+ );
+ })}
+ >
+ ) : (
+
+
+ {texts.alertMessages.ingenTidligereOppfolgingsplaner}
+
+
)}
- {inaktivePlaner.map((dialog, index) => {
- return
;
- })}
- {oppfolgingsplanerLPSProcessed.map((planLPS, index) => {
- return (
-
- );
- })}
);
}