Skip to content

Commit

Permalink
Regulering: Splitta opp i uttrekk steg og orkesteringsteg.
Browse files Browse the repository at this point in the history
Co-authored-by: Håkon Røed <[email protected]>
Co-authored-by: Kristoffer Mjelva <[email protected]>
  • Loading branch information
3 people committed Dec 17, 2024
1 parent a05045a commit 192dcee
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 56 deletions.
24 changes: 8 additions & 16 deletions app/components/regulering/regulering-fortsett-avhengige.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ export default function FortsettAvhengigeReguleringBehandlinger() {

return (
<div>
<h1>Fortsett Avhengige behandlinger</h1>
<h2>Fortsett flere familiebehandlinger</h2>
<Form method="POST">
<input type="hidden" name="formType" value="fortsettAvhengige" />
<p>
BehandlingId for Uttreksbehandling
BehandlingId for Orkestrering behandling
<input
defaultValue=""
aria-label="BehandlingIdRegulering"
Expand All @@ -27,17 +27,13 @@ export default function FortsettAvhengigeReguleringBehandlinger() {
</p>
<p>
Antall avhengige behandlinger
<select
<input
defaultValue="10"
aria-label="AntallFamiliebehandlinger"
name="antallFamiliebehandlinger"
defaultValue="0"
>
<option value="1">1</option>
<option value="10">10</option>
<option value="100">100</option>
<option value="500">500</option>
<option value="500">500</option>
</select>
type="text"
placeholder="Maks antall familiebehandlinger (-1 for alle)"
/>
</p>
<p>
Fortsett til prosesserings-aktivitet Axxx
Expand All @@ -50,11 +46,7 @@ export default function FortsettAvhengigeReguleringBehandlinger() {
/>
</p>
<p>
<button
type="submit"
disabled={isClicked}
onClick={handleSubmit}
>
<button type="submit" disabled={isClicked} onClick={handleSubmit}>
Fortsett
</button>
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function FortsettFamilieReguleringBehandling() {

return (
<div>
<h1>Fortsett Familiebehandling</h1>
<h2>Fortsett én Familiebehandling</h2>
<Form method="POST">
<input type="hidden" name="formType" value="fortsettFamilie" />
<p>
Expand Down
60 changes: 60 additions & 0 deletions app/components/regulering/regulering-orkestrering.tsx
Original file line number Diff line number Diff line change
@@ -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 <div><h2>Start Orkestrering</h2><Form method="POST">
<input type="hidden" name="formType" value="startReguleringOrkestrering" />
<p>
Satsdato
<input
defaultValue="2025-05-01"
aria-label="Satsdato"
name="satsDato"
type="text"
placeholder="Satsdato"
/>
</p>
<p>
Reguleringsdato
<input
defaultValue="2025-05-01"
aria-label="Reguleringsdato"
name="reguleringsDato"
type="text"
placeholder="Reguleringsdato"
/>
</p>
<p>
Kjør til og med aktivitet
<input
defaultValue="A100"
aria-label="SisteAktivitet"
name="sisteAktivitet"
type="text"
placeholder="SisteAktivitet"
/>
</p>
<p>
Opprett maks antall familiebehandlinger
<input
defaultValue="10"
aria-label="MaxFamiliebehandlinger"
name="maxFamiliebehandlinger"
type="text"
placeholder="Maks antall familiebehandlinger (-1 for alle)"
/>
</p>
<p>
<button type="submit" disabled={isClicked} onClick={handleSubmit}>
Start
</button>
</p>
</Form>
</div>;
}
21 changes: 3 additions & 18 deletions app/components/regulering/regulering-uttrekk.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export default function ReguleringUttrekk() {
const submit = useSubmit();
const handleSubmit = (e:any)=> {submit(e.target.form); setIsClicked(true)}

return <div><h1>Start Regulering Uttrekk</h1><Form method="POST">
<input type="hidden" name="formType" value="startRegulering" />
return <div><h2>Start Uttrekk</h2><Form method="POST">
<input type="hidden" name="formType" value="startReguleringUttrekk" />
<p>
Satsdato
<input
Expand Down Expand Up @@ -40,24 +40,9 @@ export default function ReguleringUttrekk() {
placeholder="SisteAktivitet"
/>
</p>
<p>
Opprett max antall familiebehandlinger
<select
aria-label="MaxFamiliebehandlinger"
name="maxFamiliebehandlinger"
defaultValue="0"
>
<option value="0">0</option>
<option value="1">1</option>
<option value="10">10</option>
<option value="100">100</option>
<option value="500">500</option>
<option value="-1">Alle</option>
</select>
</p>
<p>
<button type="submit" disabled={isClicked} onClick={handleSubmit}>
Opprett
Start
</button>
</p>
</Form>
Expand Down
73 changes: 55 additions & 18 deletions app/routes/batch.regulering.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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'),
Expand All @@ -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<typeof loader>()
const { behandlingerUttrekk, behandlingerOrkestrering } =
useLoaderData<typeof loader>()

return (
<div>
<h1>Regulering</h1>
<div>
<ReguleringBatch />
<FortsettFamilieReguleringBehandling />
<FortsettAvhengigeReguleringBehandlinger />
<table width="100%">
<tr>
<td><ReguleringUttrekk /></td>
<td><ReguleringOrkestrering /></td>
</tr>
<tr>
<td><FortsettFamilieReguleringBehandling /></td>
<td><FortsettAvhengigeReguleringBehandlinger /></td>
</tr>
</table>
</div>

<div id="behandlinger">
<BehandlingerTable visStatusSoek={true} visBehandlingTypeSoek={false} behandlingerResponse={behandlinger as BehandlingerPage} />
<h2>Orkestrering</h2>
<BehandlingerTable
visStatusSoek={true}
visBehandlingTypeSoek={false}
behandlingerResponse={behandlingerOrkestrering as BehandlingerPage}
/>
<h2>Uttrekk</h2>
<BehandlingerTable
visStatusSoek={true}
visBehandlingTypeSoek={false}
behandlingerResponse={behandlingerUttrekk as BehandlingerPage}
/>
</div>
</div>
)
)
}
42 changes: 39 additions & 3 deletions app/services/batch.bpen068.server.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,55 @@
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<StartBatchResponse> {

const body: any = {
satsDato: satsDato,
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<StartBatchResponse> {

const body: any = {
satsDato: satsDato,
reguleringsDato: reguleringsDato,
}

if(sisteAktivitet !== ''){
body.sisteAktivitet = sisteAktivitet;
}
Expand All @@ -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: {
Expand Down

0 comments on commit 192dcee

Please sign in to comment.