diff --git a/frontend/src/components/FeilKort.tsx b/frontend/src/components/FeilKort.tsx index 0b1cab8..08a5cfb 100644 --- a/frontend/src/components/FeilKort.tsx +++ b/frontend/src/components/FeilKort.tsx @@ -16,6 +16,7 @@ import FeilmeldingsInnhold from "./FeilmeldingsInnhold"; */ interface IFeilKort extends IFeilmelding { key: number + reset: () => void } const FeilKort = (props: IFeilKort) => { @@ -56,6 +57,7 @@ const FeilKort = (props: IFeilKort) => { arbeidsstatus={props.arbeidsstatus} setRedigeringsmodus={setRedigeringsmodus} setVisModal={setVisModal} + reset={props.reset} /> : void } /** @@ -22,6 +23,7 @@ const KortKonteiner = (props: IKortKonteiner) => { dato={new Date()} haster={feilMelding.haster} arbeidsstatus={feilMelding.arbeidsstatus} + reset={props.reset} /> )) } diff --git a/frontend/src/components/RedigeringsVerktoy.tsx b/frontend/src/components/RedigeringsVerktoy.tsx index 27d2f0f..cb22ea8 100644 --- a/frontend/src/components/RedigeringsVerktoy.tsx +++ b/frontend/src/components/RedigeringsVerktoy.tsx @@ -4,14 +4,17 @@ import { useState } from "react" import { FeilmeldingsInnholdInterface } from "../interface" import axios from "axios" +interface redigeringsInterface extends FeilmeldingsInnholdInterface { + reset: () => void +} -const RedigeringsVerktoy = (props: FeilmeldingsInnholdInterface) => { +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 = () => { + const lagreEndringer = async() => { props.setVisModal(false) props.setRedigeringsmodus(false) @@ -24,7 +27,7 @@ const RedigeringsVerktoy = (props: FeilmeldingsInnholdInterface) => { haster: haster } - axios.put(`/api/oppdaterfeil/${props.id}`, payload, { + await axios.put(`/api/oppdaterfeil/${props.id}`, payload, { headers: { 'Content-Type': 'application/json' } @@ -33,6 +36,8 @@ const RedigeringsVerktoy = (props: FeilmeldingsInnholdInterface) => { }).catch((error) => { console.log(error); }) + + props.reset() } return ( diff --git a/frontend/src/index.tsx b/frontend/src/index.tsx index c4f94bd..a966870 100644 --- a/frontend/src/index.tsx +++ b/frontend/src/index.tsx @@ -19,6 +19,8 @@ export default function Home() { * Bruker endepunktet /api/hentallefeil. */ const hentAlleFeil = async () => { + console.log("hentAlleFeil"); + await axios.get("/api/hentallefeil") .then(data => data.data) .then(feil => { @@ -69,7 +71,7 @@ export default function Home() { Meld inn feil - +