92 lines
3.2 KiB
TypeScript
92 lines
3.2 KiB
TypeScript
![]() |
import { FloppydiskIcon, XMarkIcon } from "@navikt/aksel-icons"
|
||
|
import { TextField, Textarea, RadioGroup, Radio, Button } from "@navikt/ds-react"
|
||
|
import { useState } from "react"
|
||
|
import { IFeilmelding } from "../interface"
|
||
|
import axios from "axios"
|
||
|
|
||
|
interface RedigeringsInterface extends IFeilmelding {
|
||
|
setRedigeringsmodus: (redigeringsmodus: boolean) => void
|
||
|
}
|
||
|
|
||
|
const RedigeringsVerktoy = (props: RedigeringsInterface) => {
|
||
|
const [tittel, setTittel] = useState(props.tittel)
|
||
|
const [beskrivelse, setBeskrivelse] = useState(props.beskrivelse)
|
||
|
const [arbeidsstatus, setArbeidsstatus] = useState(props.arbeidsstatus)
|
||
|
const [haster, setHaster] = useState(props.haster)
|
||
|
|
||
|
const lagreEndringer = () => {
|
||
|
props.setRedigeringsmodus(false)
|
||
|
|
||
|
const payload = {
|
||
|
id: props.id,
|
||
|
tittel: tittel,
|
||
|
beskrivelse: beskrivelse,
|
||
|
dato: props.dato.toISOString().replace('Z', ''),
|
||
|
arbeidsstatus: arbeidsstatus,
|
||
|
haster: haster
|
||
|
}
|
||
|
|
||
|
axios.put(`/api/oppdaterfeil/${props.id}`, payload, {
|
||
|
headers: {
|
||
|
'Content-Type': 'application/json'
|
||
|
}
|
||
|
}).then((response) => {
|
||
|
console.log(response);
|
||
|
}).catch((error) => {
|
||
|
console.log(error);
|
||
|
})
|
||
|
}
|
||
|
|
||
|
return (
|
||
|
<div className="flex justify-between">
|
||
|
<div className="flex flex-col gap-4 w-1/2">
|
||
|
<TextField
|
||
|
label="Tittel"
|
||
|
value={tittel}
|
||
|
onChange={e => setTittel(e.target.value)}
|
||
|
/>
|
||
|
<Textarea
|
||
|
label="Beskrivelse"
|
||
|
value={beskrivelse}
|
||
|
onChange={e => setBeskrivelse(e.target.value)}
|
||
|
/>
|
||
|
<RadioGroup
|
||
|
legend="Velg arbeidsstatus for feil"
|
||
|
onChange={(arbeidsstatus: number) => {setArbeidsstatus(arbeidsstatus)}}
|
||
|
value={arbeidsstatus}
|
||
|
>
|
||
|
<Radio value={0}>Ikke påbegynt</Radio>
|
||
|
<Radio value={1}>Feilen jobbes med</Radio>
|
||
|
<Radio value={2}>Feilen er fikset</Radio>
|
||
|
</RadioGroup>
|
||
|
<RadioGroup
|
||
|
legend="Hvor vil du sitte?"
|
||
|
onChange={(haster: boolean) => {setHaster(haster)}}
|
||
|
value={haster}
|
||
|
>
|
||
|
<Radio value={true}>Ja</Radio>
|
||
|
<Radio value={false}>Nei</Radio>
|
||
|
</RadioGroup>
|
||
|
</div>
|
||
|
<div className="flex gap-4 items-start">
|
||
|
<Button
|
||
|
variant="primary"
|
||
|
icon={<FloppydiskIcon/>}
|
||
|
onClick={() => lagreEndringer()}
|
||
|
>
|
||
|
Lagre
|
||
|
</Button>
|
||
|
<Button
|
||
|
variant="danger"
|
||
|
icon={<XMarkIcon/>}
|
||
|
onClick={() => {
|
||
|
props.setRedigeringsmodus(false)
|
||
|
}}
|
||
|
>
|
||
|
Avbryt
|
||
|
</Button>
|
||
|
</div>
|
||
|
</div>
|
||
|
)
|
||
|
}
|
||
|
export default RedigeringsVerktoy;
|