From 39457d769d0fea78949eae965be3c3045e5e8090 Mon Sep 17 00:00:00 2001 From: Markus Johansen Date: Wed, 2 Aug 2023 15:31:49 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Feilmeldingene=20p=C3=A5=20siden=20?= =?UTF-8?q?lastes=20inn=20p=C3=A5=20nytt=20til=20frontenden=20etter=20oppd?= =?UTF-8?q?atering?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/FeilKort.tsx | 2 ++ frontend/src/components/KortKonteiner.tsx | 2 ++ frontend/src/components/RedigeringsVerktoy.tsx | 11 ++++++++--- frontend/src/index.tsx | 4 +++- 4 files changed, 15 insertions(+), 4 deletions(-) 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 - +