-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/nytt-filter-design
- Loading branch information
Showing
56 changed files
with
1,253 additions
and
1,103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 12 additions & 4 deletions
16
frontend/mr-admin-flate/src/api/avtaler/useAvbrytAvtale.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,25 @@ | ||
import { useMutation, useQueryClient } from "@tanstack/react-query"; | ||
import { mulighetsrommetClient } from "../clients"; | ||
import { ApiError } from "mulighetsrommet-api-client"; | ||
import { QueryKeys } from "../QueryKeys"; | ||
|
||
export function useAvbrytAvtale() { | ||
const client = useQueryClient(); | ||
|
||
return useMutation<unknown, ApiError, string>({ | ||
mutationFn: (id: string) => { | ||
return mulighetsrommetClient.avtaler.avbrytAvtale({ id }); | ||
}, | ||
onSuccess: () => { | ||
client.invalidateQueries({ | ||
queryKey: ["avtale"], | ||
}); | ||
onSuccess: (_, id) => { | ||
return Promise.all([ | ||
client.invalidateQueries({ | ||
queryKey: QueryKeys.avtale(id), | ||
}), | ||
|
||
client.invalidateQueries({ | ||
queryKey: QueryKeys.avtaler(), | ||
}), | ||
]); | ||
}, | ||
}); | ||
} |
14 changes: 14 additions & 0 deletions
14
frontend/mr-admin-flate/src/api/avtaler/useAvtaleEndringshistorikk.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { useSuspenseQuery } from "@tanstack/react-query"; | ||
import { QueryKeys } from "../QueryKeys"; | ||
import { mulighetsrommetClient } from "../clients"; | ||
|
||
export function useAvtaleEndringshistorikk(id: string) { | ||
return useSuspenseQuery({ | ||
queryKey: QueryKeys.avtaleHistorikk(id), | ||
queryFn() { | ||
return mulighetsrommetClient.avtaler.getAvtaleEndringshistorikk({ | ||
id, | ||
}); | ||
}, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,25 @@ | ||
import { useMutation } from "@tanstack/react-query"; | ||
import { useMutation, useQueryClient } from "@tanstack/react-query"; | ||
import { ApiError, Avtale, AvtaleRequest } from "mulighetsrommet-api-client"; | ||
import { mulighetsrommetClient } from "../clients"; | ||
import { QueryKeys } from "../QueryKeys"; | ||
|
||
export function useUpsertAvtale() { | ||
const queryClient = useQueryClient(); | ||
|
||
return useMutation<Avtale, ApiError, AvtaleRequest>({ | ||
mutationFn: (requestBody: AvtaleRequest) => | ||
mulighetsrommetClient.avtaler.upsertAvtale({ requestBody }), | ||
|
||
onSuccess(_, request) { | ||
return Promise.all([ | ||
queryClient.invalidateQueries({ | ||
queryKey: QueryKeys.avtale(request.id), | ||
}), | ||
|
||
queryClient.invalidateQueries({ | ||
queryKey: QueryKeys.avtaler(), | ||
}), | ||
]); | ||
}, | ||
}); | ||
} |
14 changes: 14 additions & 0 deletions
14
...d/mr-admin-flate/src/api/tiltaksgjennomforing/useTiltaksgjennomforingEndringshistorikk.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { useSuspenseQuery } from "@tanstack/react-query"; | ||
import { QueryKeys } from "../QueryKeys"; | ||
import { mulighetsrommetClient } from "../clients"; | ||
|
||
export function useTiltaksgjennomforingEndringshistorikk(id: string) { | ||
return useSuspenseQuery({ | ||
queryKey: QueryKeys.tiltaksgjennomforingHistorikk(id), | ||
queryFn() { | ||
return mulighetsrommetClient.tiltaksgjennomforinger.getTiltaksgjennomforingEndringshistorikk({ | ||
id, | ||
}); | ||
}, | ||
}); | ||
} |
43 changes: 43 additions & 0 deletions
43
frontend/mr-admin-flate/src/components/endringshistorikk/EndringshistorikkPopover.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React, { ReactElement, useRef, useState } from "react"; | ||
import { ClockDashedIcon } from "@navikt/aksel-icons"; | ||
import { Button, Loader, Popover } from "@navikt/ds-react"; | ||
import { ErrorBoundary } from "react-error-boundary"; | ||
import { ErrorFallback } from "../../main"; | ||
|
||
export interface EndringshistorikkPopoverProps { | ||
children: ReactElement; | ||
} | ||
|
||
export function EndringshistorikkPopover({ children }: EndringshistorikkPopoverProps) { | ||
const [open, setOpen] = useState(false); | ||
const buttonRef = useRef<HTMLButtonElement>(null); | ||
|
||
return ( | ||
<> | ||
<Button | ||
ref={buttonRef} | ||
onClick={() => setOpen(!open)} | ||
aria-expanded={open} | ||
variant="tertiary-neutral" | ||
type="button" | ||
size="small" | ||
title="Trykk for å se endringshistorikk" | ||
> | ||
<ClockDashedIcon height={25} width={25} title="Endringshistorikk" /> | ||
</Button> | ||
|
||
<Popover | ||
open={open} | ||
onClose={() => setOpen(false)} | ||
anchorEl={buttonRef.current} | ||
placement="bottom-end" | ||
> | ||
<Popover.Content> | ||
<React.Suspense fallback={<Loader title="Laster endringshistorikk" />}> | ||
<ErrorBoundary FallbackComponent={ErrorFallback}>{children}</ErrorBoundary> | ||
</React.Suspense> | ||
</Popover.Content> | ||
</Popover> | ||
</> | ||
); | ||
} |
5 changes: 5 additions & 0 deletions
5
frontend/mr-admin-flate/src/components/endringshistorikk/ViewEndringshistorikk.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.endringshistorikkList { | ||
list-style-type: none; | ||
padding: 0; | ||
margin: 0; | ||
} |
39 changes: 39 additions & 0 deletions
39
frontend/mr-admin-flate/src/components/endringshistorikk/ViewEndringshistorikk.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import type { | ||
Endringshistorikk, | ||
EndringshistorikkNavAnsatt, | ||
EndringshistorikkUser, | ||
} from "mulighetsrommet-api-client"; | ||
import { formaterDatoTid } from "../../utils/Utils"; | ||
import styles from "./ViewEndringshistorikk.module.scss"; | ||
|
||
export interface ViewEndringshistorikkProps { | ||
historikk: Endringshistorikk; | ||
} | ||
|
||
export function ViewEndringshistorikk(props: ViewEndringshistorikkProps) { | ||
const { historikk } = props; | ||
|
||
if (historikk.entries.length === 0) { | ||
return <div>Endringshistorikken er tom</div>; | ||
} | ||
|
||
return ( | ||
<ul className={styles.endringshistorikkList}> | ||
{historikk.entries.map(({ operation, editedAt, editedBy }) => { | ||
const user = isNavAnsatt(editedBy) | ||
? `${editedBy.navn} (${editedBy.navIdent})` | ||
: editedBy.navn; | ||
|
||
return ( | ||
<li key={editedAt}> | ||
{formaterDatoTid(editedAt)} - <b>{operation}</b> - {user} | ||
</li> | ||
); | ||
})} | ||
</ul> | ||
); | ||
} | ||
|
||
function isNavAnsatt(user: EndringshistorikkUser): user is EndringshistorikkNavAnsatt { | ||
return "navIdent" in user; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.