Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Endret til brevmal kode. #24

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions app/routes/batch-opprett._index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Form, NavLink, useSubmit } from '@remix-run/react'
import { json } from '@remix-run/node'
import { env } from '~/services/env.server'
import React, { useState } from 'react'
import React, { useState, useRef, useEffect } from 'react'
import { Select } from '@navikt/ds-react'

export const loader = async () => {
Expand All @@ -18,6 +18,18 @@ export default function BatchOpprett_index() {
const submit = useSubmit()
const handleSubmit = (e:any)=> {submit(e.target.form); setIsClicked(true)}

const inputRef = useRef<HTMLInputElement>(null)

const handleInput = () => {
if (inputRef.current) {
inputRef.current.style.width = `${inputRef.current.value.length + 1}ch`
}
}

useEffect(() => {
handleInput()
})

return (
<div>
<h1>Opprett BPEN005 batchkjøring</h1>
Expand Down Expand Up @@ -87,16 +99,19 @@ export default function BatchOpprett_index() {
<button type="submit">Opprett</button>
</p>
</Form>
<h1>Opprett ADHOC Brevbestilling batchkjøring</h1>
<h1>Opprett ADHOC Brevbestilling batchkjøring på brevmal for sak</h1>
<Form action="adhocBrev" method="POST">
<p>
InternBatchBrevkode
Brevmal kode for Sak
<input
defaultValue="ADHOC_2024_AP3"
aria-label="InternBatchBrevkode"
name="internBatchBrevkode"
ref={inputRef}
defaultValue="PE_AP_ADHOC_2024_GJR_AP_MNTINDV_2"
aria-label="Brevmal"
name="brevmal"
type="text"
placeholder="InternBatchBrevkode"
placeholder="Brevmal"
onInput={handleInput}
style={{ width: 'auto' }}
/>
</p>
<p>
Expand Down
2 changes: 1 addition & 1 deletion app/routes/batch-opprett.adhocbrev.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const action = async ({ request }: ActionFunctionArgs) => {
const updates = Object.fromEntries(formData)
const accessToken = await requireAccessToken(request)

let response = await opprettAdhocBrevBehandling(accessToken, updates.internBatchBrevkode as string)
let response = await opprettAdhocBrevBehandling(accessToken, updates.brevmal as string)

return redirect(`/behandling/${response.behandlingId}`)
}
4 changes: 2 additions & 2 deletions app/services/batch.adhocBrev.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import type { StartBatchResponse } from '~/types'

export async function opprettAdhocBrevBehandling(
accessToken: string,
internBatchBrevkode: string,
brevmal: string,
): Promise<StartBatchResponse> {

const body: any = {
batchBrevkode: internBatchBrevkode,
brevmal: brevmal,
}

const response = await fetch(
Expand Down
Loading