🚑 Frontend bruker oppdaterkommentar endepunktet
This commit is contained in:
parent
a8e991420e
commit
011eda1941
2 changed files with 27 additions and 8 deletions
|
@ -4,12 +4,34 @@ import { FeilmeldingsInnholdInterface } from "../interface"
|
||||||
import FeilkortHeader from "./FeilkortHeader"
|
import FeilkortHeader from "./FeilkortHeader"
|
||||||
import { useState } from "react"
|
import { useState } from "react"
|
||||||
import Skillelinje from "./Skillelinje"
|
import Skillelinje from "./Skillelinje"
|
||||||
|
import axios from "axios"
|
||||||
|
|
||||||
|
|
||||||
const FeilmeldingsInnhold = (props: FeilmeldingsInnholdInterface) => {
|
const FeilmeldingsInnhold = (props: FeilmeldingsInnholdInterface) => {
|
||||||
const [kommentar, setKommentar] = useState("")
|
const [kommentar, setKommentar] = useState("")
|
||||||
const [kommentarfelt, setKommentarfelt] = useState("")
|
const [kommentarfelt, setKommentarfelt] = useState("")
|
||||||
|
|
||||||
|
const oppdaterkommentar = async() => {
|
||||||
|
setKommentar(kommentarfelt)
|
||||||
|
|
||||||
|
const payload = {
|
||||||
|
id: props.id,
|
||||||
|
tittel: kommentar,
|
||||||
|
}
|
||||||
|
|
||||||
|
await axios.put("/api/oppdaterkommentar", payload, {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
}).then((response) => {
|
||||||
|
console.log(response);
|
||||||
|
}).catch((error) => {
|
||||||
|
console.log(error);
|
||||||
|
})
|
||||||
|
|
||||||
|
props.reset()
|
||||||
|
}
|
||||||
|
|
||||||
return(
|
return(
|
||||||
<div>
|
<div>
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
|
@ -45,13 +67,11 @@ const FeilmeldingsInnhold = (props: FeilmeldingsInnholdInterface) => {
|
||||||
<KommentarTekstfelt
|
<KommentarTekstfelt
|
||||||
kommentarfelt={kommentarfelt}
|
kommentarfelt={kommentarfelt}
|
||||||
setKommentarfelt={setKommentarfelt}
|
setKommentarfelt={setKommentarfelt}
|
||||||
setKommentar={setKommentar}
|
oppdaterKommentar={() => oppdaterkommentar()}
|
||||||
/>
|
/>
|
||||||
:
|
:
|
||||||
<Kommentar
|
<Kommentar
|
||||||
tekst={kommentar}
|
tekst={kommentar}
|
||||||
setKommentarfelt={setKommentarfelt}
|
|
||||||
setKommentar={setKommentar}
|
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
@ -62,13 +82,13 @@ export default FeilmeldingsInnhold;
|
||||||
|
|
||||||
interface Ikommentar {
|
interface Ikommentar {
|
||||||
setKommentarfelt: (val: string) => void
|
setKommentarfelt: (val: string) => void
|
||||||
setKommentar: (val: string) => void
|
oppdaterKommentar: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
interface kommentarTekstfeltInterface extends Ikommentar{
|
interface kommentarTekstfeltInterface extends Ikommentar{
|
||||||
kommentarfelt: string,
|
kommentarfelt: string,
|
||||||
}
|
}
|
||||||
interface kommentarInterface extends Ikommentar {
|
interface kommentarInterface {
|
||||||
tekst: string
|
tekst: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,9 +106,7 @@ const KommentarTekstfelt = (props: kommentarTekstfeltInterface) => {
|
||||||
<Button
|
<Button
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
icon={<ChatElipsisIcon/>}
|
icon={<ChatElipsisIcon/>}
|
||||||
onClick={() => {
|
onClick={() => props.oppdaterKommentar()}
|
||||||
props.setKommentar(props.kommentarfelt)
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
Legg til kommentar
|
Legg til kommentar
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
@ -16,6 +16,7 @@ export interface FeilmeldingsInnholdInterface extends IFeilmelding {
|
||||||
children?: React.ReactNode
|
children?: React.ReactNode
|
||||||
setRedigeringsmodus: (redigeringsmodus: boolean) => void
|
setRedigeringsmodus: (redigeringsmodus: boolean) => void
|
||||||
setVisModal: (visModal: boolean) => void
|
setVisModal: (visModal: boolean) => void
|
||||||
|
reset: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Feilmelding implements IFeilmelding {
|
export class Feilmelding implements IFeilmelding {
|
||||||
|
|
Reference in a new issue