Skip to content

Commit

Permalink
Endret til brevmal kode.
Browse files Browse the repository at this point in the history
Fikset input feltets bredde vha react.

Co-authored-by: [email protected]
  • Loading branch information
Anders Refsahl committed Nov 8, 2024
1 parent abad550 commit a9434b3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
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

0 comments on commit a9434b3

Please sign in to comment.