From 192dcee4f82373e11cbcf42fb71e480684e990e0 Mon Sep 17 00:00:00 2001 From: Anders Refsahl Date: Tue, 17 Dec 2024 15:55:12 +0100 Subject: [PATCH] Regulering: Splitta opp i uttrekk steg og orkesteringsteg. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Håkon Røed Co-authored-by: Kristoffer Mjelva --- .../regulering-fortsett-avhengige.tsx | 24 ++---- .../regulering-fortsettbehandling.tsx | 2 +- .../regulering/regulering-orkestrering.tsx | 60 +++++++++++++++ .../regulering/regulering-uttrekk.tsx | 21 +----- app/routes/batch.regulering.tsx | 73 ++++++++++++++----- app/services/batch.bpen068.server.ts | 42 ++++++++++- 6 files changed, 166 insertions(+), 56 deletions(-) diff --git a/app/components/regulering/regulering-fortsett-avhengige.tsx b/app/components/regulering/regulering-fortsett-avhengige.tsx index 9499118..106015f 100644 --- a/app/components/regulering/regulering-fortsett-avhengige.tsx +++ b/app/components/regulering/regulering-fortsett-avhengige.tsx @@ -12,11 +12,11 @@ export default function FortsettAvhengigeReguleringBehandlinger() { return (
-

Fortsett Avhengige behandlinger

+

Fortsett flere familiebehandlinger

- BehandlingId for Uttreksbehandling + BehandlingId for Orkestrering behandling

Antall avhengige behandlinger - + type="text" + placeholder="Maks antall familiebehandlinger (-1 for alle)" + />

Fortsett til prosesserings-aktivitet Axxx @@ -50,11 +46,7 @@ export default function FortsettAvhengigeReguleringBehandlinger() { />

-

diff --git a/app/components/regulering/regulering-fortsettbehandling.tsx b/app/components/regulering/regulering-fortsettbehandling.tsx index 8cf842c..36622a9 100644 --- a/app/components/regulering/regulering-fortsettbehandling.tsx +++ b/app/components/regulering/regulering-fortsettbehandling.tsx @@ -12,7 +12,7 @@ export default function FortsettFamilieReguleringBehandling() { return (
-

Fortsett Familiebehandling

+

Fortsett én Familiebehandling

diff --git a/app/components/regulering/regulering-orkestrering.tsx b/app/components/regulering/regulering-orkestrering.tsx index e69de29..06e91b9 100644 --- a/app/components/regulering/regulering-orkestrering.tsx +++ b/app/components/regulering/regulering-orkestrering.tsx @@ -0,0 +1,60 @@ + +import React, { useState } from 'react' +import { Form, useSubmit } from '@remix-run/react' + +export default function ReguleringOrkestrering() { + + const [isClicked, setIsClicked] = useState(false); + const submit = useSubmit(); + const handleSubmit = (e:any)=> {submit(e.target.form); setIsClicked(true)} + + return

Start Orkestrering

+ +

+ Satsdato + +

+

+ Reguleringsdato + +

+

+ Kjør til og med aktivitet + +

+

+ Opprett maks antall familiebehandlinger + +

+

+ +

+ +
; +} \ No newline at end of file diff --git a/app/components/regulering/regulering-uttrekk.tsx b/app/components/regulering/regulering-uttrekk.tsx index 19d63be..27db847 100644 --- a/app/components/regulering/regulering-uttrekk.tsx +++ b/app/components/regulering/regulering-uttrekk.tsx @@ -8,8 +8,8 @@ export default function ReguleringUttrekk() { const submit = useSubmit(); const handleSubmit = (e:any)=> {submit(e.target.form); setIsClicked(true)} - return

Start Regulering Uttrekk

- + return

Start Uttrekk

+

Satsdato

-

- Opprett max antall familiebehandlinger - -

diff --git a/app/routes/batch.regulering.tsx b/app/routes/batch.regulering.tsx index deb06f5..f4cac2e 100644 --- a/app/routes/batch.regulering.tsx +++ b/app/routes/batch.regulering.tsx @@ -1,25 +1,31 @@ import { ActionFunctionArgs, json, redirect } from '@remix-run/node' import { requireAccessToken } from '~/services/auth.server' -import { - fortsettAvhengigeBehandling, - fortsettBehandling, - startRegulering, -} from '~/services/batch.bpen068.server' -import ReguleringBatch from '~/components/regulering/regulering-batch' +import { fortsettAvhengigeBehandling, fortsettBehandling, startReguleringOrkestrering, startReguleringUttrekk, } from '~/services/batch.bpen068.server' +import ReguleringUttrekk from '~/components/regulering/regulering-uttrekk' import FortsettFamilieReguleringBehandling from '~/components/regulering/regulering-fortsettbehandling' import FortsettAvhengigeReguleringBehandlinger from '~/components/regulering/regulering-fortsett-avhengige' import { useLoaderData } from '@remix-run/react' import { getBehandlinger } from '~/services/behandling.server' import BehandlingerTable from '~/components/behandlinger-table/BehandlingerTable' import { BehandlingerPage } from '~/types' +import ReguleringOrkestrering from '~/components/regulering/regulering-orkestrering' export const action = async ({ request }: ActionFunctionArgs) => { const formData = await request.formData() const updates = Object.fromEntries(formData) const accessToken = await requireAccessToken(request) - if (updates.formType === 'startRegulering') { - await startRegulering( + if (updates.formType === 'startReguleringUttrekk') { + await startReguleringUttrekk( + accessToken, + updates.satsDato as string, + updates.reguleringsDato as string, + updates.sisteAktivitet as string, + ) + return redirect(`/batch/regulering`) + + } else if (updates.formType === 'startReguleringOrkestrering') { + await startReguleringOrkestrering( accessToken, updates.satsDato as string, updates.reguleringsDato as string, @@ -28,7 +34,7 @@ export const action = async ({ request }: ActionFunctionArgs) => { ) return redirect(`/batch/regulering`) - } else if (updates.formType === 'fortsettFamilie') { + }else if (updates.formType === 'fortsettFamilie') { await fortsettBehandling( accessToken, updates.behandlingIdFamilie as string, @@ -56,7 +62,7 @@ export const loader = async ({ request }: ActionFunctionArgs) => { const page = searchParams.get('page') const accessToken = await requireAccessToken(request) - const behandlinger = await getBehandlinger( + const behandlingerUttrekk = await getBehandlinger( accessToken, "ReguleringUttrekk", searchParams.get('status'), @@ -66,26 +72,57 @@ export const loader = async ({ request }: ActionFunctionArgs) => { size ? +size : 3, null ) - if (!behandlinger) { + const behandlingerOrkestrering = await getBehandlinger( + accessToken, + "ReguleringOrkestrering", + searchParams.get('status'), + null, + true, + page ? +page : 0, + size ? +size : 3, + null + ) + if (!behandlingerUttrekk) { throw new Response('Not Found', { status: 404 }) } - return json({ behandlinger }) + return json({ behandlingerUttrekk, behandlingerOrkestrering }) } export default function OpprettReguleringBatchRoute() { - const { behandlinger } = useLoaderData() + const { behandlingerUttrekk, behandlingerOrkestrering } = + useLoaderData() return (
+

Regulering

- - - + + + + + + + + + +
+
- +

Orkestrering

+ +

Uttrekk

+
-) + ) } diff --git a/app/services/batch.bpen068.server.ts b/app/services/batch.bpen068.server.ts index 6408a95..06d659b 100644 --- a/app/services/batch.bpen068.server.ts +++ b/app/services/batch.bpen068.server.ts @@ -1,12 +1,11 @@ import { env } from '~/services/env.server' import { FortsettBatchResponse, StartBatchResponse } from '~/types' -export async function startRegulering( +export async function startReguleringUttrekk( accessToken: string, satsDato: string, reguleringsDato: string, sisteAktivitet: string, - maxFamiliebehandlinger: string, ): Promise { const body: any = { @@ -14,6 +13,43 @@ export async function startRegulering( reguleringsDato: reguleringsDato, } + if(sisteAktivitet !== ''){ + body.sisteAktivitet = sisteAktivitet; + } + + const response = await fetch( + `${env.penUrl}/api/vedtak/regulering/uttrekk/start`, + { + method: 'POST', + headers: { + Authorization: `Bearer ${accessToken}`, + 'Content-Type': 'application/json', + 'X-Request-ID': crypto.randomUUID(), + }, + body: JSON.stringify(body), + }, + ) + + if (response.ok) { + return (await response.json()) as StartBatchResponse + } else { + throw new Error() + } +} + +export async function startReguleringOrkestrering( + accessToken: string, + satsDato: string, + reguleringsDato: string, + sisteAktivitet: string, + maxFamiliebehandlinger: string, +): Promise { + + const body: any = { + satsDato: satsDato, + reguleringsDato: reguleringsDato, + } + if(sisteAktivitet !== ''){ body.sisteAktivitet = sisteAktivitet; } @@ -22,7 +58,7 @@ export async function startRegulering( } const response = await fetch( - `${env.penUrl}/api/vedtak/regulering/start`, + `${env.penUrl}/api/vedtak/regulering/orkestrering/start`, { method: 'POST', headers: {