Skip to content

Commit

Permalink
Opphør forsørgertilegg knapp
Browse files Browse the repository at this point in the history
  • Loading branch information
KimandrenaessNAV committed Oct 25, 2024
1 parent c3fd999 commit 5473735
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions app/routes/batch-opprett._index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ export default function BatchOpprett_index() {
<button type='submit'>Opprett</button>
</p>
</Form>
<h1>Opprett Opphør av Forsørgertilegg</h1>
<Form action='opphoerforsorgertilegg' method='POST'>
<p>
<button type='submit'>Opprett</button>
</p>
</Form>

<h1>Opprett RTV Brev Sammenligninger</h1>

Expand Down
12 changes: 12 additions & 0 deletions app/routes/batch-opprett.opphoerforsorgertilegg.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { ActionFunctionArgs, redirect } from '@remix-run/node'
import { requireAccessToken } from '~/services/auth.server'
import { opphoerforsorgertilegg } from '~/services/batch.opphoerforsorgertilegg.server'

export const action = async ({ request }: ActionFunctionArgs) => {
const accessToken = await requireAccessToken(request)

let response = await opphoerforsorgertilegg(accessToken)

return redirect(`/behandling/${response.behandlingId}`)
}

24 changes: 24 additions & 0 deletions app/services/batch.opphoerforsorgertilegg.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { env } from '~/services/env.server'
import { StartBatchResponse } from '~/types'

export async function opphoerforsorgertilegg(
accessToken: string,
): Promise<StartBatchResponse> {
const response = await fetch(
`${env.penUrl}/springapi/opphoerforsorgertilegg`,
{
method: 'POST',
headers: {
Authorization: `Bearer ${accessToken}`,
'Content-Type': 'application/json',
'X-Request-ID': crypto.randomUUID(),
},
},
)
if (response.ok) {
return (await response.json()) as StartBatchResponse
} else {
throw new Error()
}
}

0 comments on commit 5473735

Please sign in to comment.