Skip to content

Commit

Permalink
Merge pull request #21 from navikt/feature/bpen068-start
Browse files Browse the repository at this point in the history
Forsøk på å sette opp en start knapp for regulering i verdande.
  • Loading branch information
arefsahl authored Oct 17, 2024
2 parents 7193bdf + 97c99a9 commit 030a935
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 9 deletions.
43 changes: 34 additions & 9 deletions app/routes/batch-opprett._index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function BatchOpprett_index() {
<div>
<h1>Opprett BPEN005 batchkjøring</h1>
<Form action="bpen005" method="POST">
<div style={{display: "inline-block"}}>
<div style={{ display: "inline-block" }}>
<label>Behandlingsmåned</label>
<br />
<input
Expand All @@ -34,7 +34,7 @@ export default function BatchOpprett_index() {
/>
</div>
<br />
<div style={{display: "inline-block"}}>
<div style={{ display: "inline-block" }}>
<Select label="Begrenset utplukk" size={"small"} name={"begrensetUtplukk"} defaultValue={"false"}>
<option value="true">Ja</option>
<option value="false">Nei</option>
Expand Down Expand Up @@ -78,7 +78,32 @@ export default function BatchOpprett_index() {
<button type="submit">Opprett</button>
</p>
</Form>

<h1>Opprett BPEN068 batchkjøring</h1>
<Form action="bpen068" method="POST">
<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>
<button type="submit" disabled={isClicked} onClick={handleSubmit}>Opprett</button>
</p>
</Form>
<h1>Opprett BPEN091 batchkjøring</h1>
<Form action="bpen091" method="POST">
<p>
Expand All @@ -105,11 +130,11 @@ export default function BatchOpprett_index() {

<h1>Opprett RTV Brev Sammenligninger</h1>

<NavLink to={"./rtv-brev-sammenligning"}>Opprett RTV Brev Sammenligninger</NavLink>
<h1>Opprett Omsorgsopptjening uttrekk</h1>
<NavLink to={"./omsorgsopptjening-uttrekk"}>Opprett Omsorgsopptjening-uttrekk</NavLink>
<h1>Overfør Klager til Kabal</h1>
<NavLink to={"./overfortilkabal"}>Start batch behandling</NavLink>
</div>
<NavLink to={"./rtv-brev-sammenligning"}>Opprett RTV Brev Sammenligninger</NavLink>
<h1>Opprett Omsorgsopptjening uttrekk</h1>
<NavLink to={"./omsorgsopptjening-uttrekk"}>Opprett Omsorgsopptjening-uttrekk</NavLink>
<h1>Overfør Klager til Kabal</h1>
<NavLink to={"./overfortilkabal"}>Start batch behandling</NavLink>
</div>
)
}
15 changes: 15 additions & 0 deletions app/routes/batch-opprett.bpen068.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { ActionFunctionArgs} from '@remix-run/node';
import { redirect } from '@remix-run/node'
import { requireAccessToken } from '~/services/auth.server'
import { opprettBpen068 } from '~/services/batch.bpen068.server'


export const action = async ({ request }: ActionFunctionArgs) => {
const formData = await request.formData()
const updates = Object.fromEntries(formData)
const accessToken = await requireAccessToken(request)

let response = await opprettBpen068(accessToken, updates.satsDato as string, updates.reguleringsDato as string)

return redirect(`/behandling/${response.behandlingId}`)
}
31 changes: 31 additions & 0 deletions app/services/batch.bpen068.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { env } from '~/services/env.server'
import type { StartBatchResponse } from '~/types'

export async function opprettBpen068(
accessToken: string,
satsDato: string,
reguleringsDato: string,
): Promise<StartBatchResponse> {
const response = await fetch(
`${env.penUrl}/springapi/vedtak/regulering/start`,
{
method: 'POST',
headers: {
Authorization: `Bearer ${accessToken}`,
'Content-Type': 'application/json',
'X-Request-ID': crypto.randomUUID(),
},
body: JSON.stringify({
satsDato: satsDato,
reguleringsDato: reguleringsDato,
}),
},
)

if (response.ok) {
return (await response.json()) as StartBatchResponse
} else {
throw new Error()
}
}

0 comments on commit 030a935

Please sign in to comment.