✨ Klarer å skifte mellom redigerings- og visningsmodus
Co-authored-by: Markus A. R. Johansen <markus.aleksander.rakil.johansen@nav.no>
This commit is contained in:
parent
02178d187f
commit
3792ee6861
1 changed files with 55 additions and 17 deletions
|
@ -3,7 +3,7 @@ import { Button, Heading, Modal, Tag } from "@navikt/ds-react";
|
||||||
import { IFeilmelding } from "../interface";
|
import { IFeilmelding } from "../interface";
|
||||||
import FeilModal from "./FeilModal";
|
import FeilModal from "./FeilModal";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { PencilIcon, XMarkIcon } from "@navikt/aksel-icons";
|
import { FloppydiskIcon, PencilIcon, XMarkIcon } from "@navikt/aksel-icons";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* En konteiner som inneholder all informasjon og funksjonalitet for å vise og interagere med en feilmelding.
|
* En konteiner som inneholder all informasjon og funksjonalitet for å vise og interagere med en feilmelding.
|
||||||
|
@ -15,13 +15,21 @@ import { PencilIcon, XMarkIcon } from "@navikt/aksel-icons";
|
||||||
interface IFeilKort extends IFeilmelding {
|
interface IFeilKort extends IFeilmelding {
|
||||||
key: number
|
key: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export const FeilKort = (props: IFeilKort) => {
|
export const FeilKort = (props: IFeilKort) => {
|
||||||
const [visModal, setVisModal] = useState<boolean>(false)
|
const [visModal, setVisModal] = useState<boolean>(false)
|
||||||
|
const [redigeringsmodus, setRedigeringsmodus] = useState(false)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
Modal.setAppElement(document.getElementById('root'));
|
Modal.setAppElement(document.getElementById('root'));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const lagreEndringer = () => {
|
||||||
|
setRedigeringsmodus(false)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return(
|
return(
|
||||||
<>
|
<>
|
||||||
<div
|
<div
|
||||||
|
@ -35,23 +43,53 @@ export const FeilKort = (props: IFeilKort) => {
|
||||||
<FeilkortHeader tittel={props.tittel} beskrivelse={props.beskrivelse} dato={props.dato}/>
|
<FeilkortHeader tittel={props.tittel} beskrivelse={props.beskrivelse} dato={props.dato}/>
|
||||||
</div>
|
</div>
|
||||||
<FeilModal open={visModal} setOpen={setVisModal} >
|
<FeilModal open={visModal} setOpen={setVisModal} >
|
||||||
|
{redigeringsmodus ?
|
||||||
|
|
||||||
|
<div className="flex justify-between">
|
||||||
|
<FeilkortHeader tittel={props.tittel} beskrivelse={props.beskrivelse} dato={new Date()} />
|
||||||
|
<div className="flex gap-4 items-start">
|
||||||
|
<Button
|
||||||
|
variant="primary"
|
||||||
|
icon={<FloppydiskIcon/>}
|
||||||
|
onClick={() => lagreEndringer()}
|
||||||
|
>
|
||||||
|
Lagre
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="danger"
|
||||||
|
icon={<XMarkIcon/>}
|
||||||
|
onClick={() => {
|
||||||
|
setRedigeringsmodus(false)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Avbryt
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
:
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<FeilkortHeader tittel={props.tittel} beskrivelse={props.beskrivelse} dato={new Date()} />
|
<FeilkortHeader tittel={props.tittel} beskrivelse={props.beskrivelse} dato={new Date()} />
|
||||||
<div className="flex gap-4 items-start">
|
<div className="flex gap-4 items-start">
|
||||||
<Button
|
<Button
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
icon={<PencilIcon/>}
|
icon={<PencilIcon/>}
|
||||||
|
onClick={() => setRedigeringsmodus(true)}
|
||||||
>
|
>
|
||||||
Rediger
|
Rediger
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
icon={<XMarkIcon/>}
|
icon={<XMarkIcon/>}
|
||||||
onClick={() => setVisModal(false)}
|
onClick={() => {
|
||||||
|
setVisModal(false)
|
||||||
|
setRedigeringsmodus(false)
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Lukk
|
Lukk
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
<div className="h-2 bg-gray-200 my-4 rounded-lg"></div>
|
<div className="h-2 bg-gray-200 my-4 rounded-lg"></div>
|
||||||
|
|
Reference in a new issue