From ca9a9dce404f464f6ac949ec11c0365a0fa54b3e Mon Sep 17 00:00:00 2001 From: Erik Eiesland Date: Mon, 3 Jun 2024 17:45:35 +0200 Subject: [PATCH] =?UTF-8?q?endrer=20litt=20p=C3=A5=20hast=20og=20paginerin?= =?UTF-8?q?g?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit skjuler kolonnen hast hvis ikke pilot --- .../felleskomponenter/table/Tabellkolonne.ts | 1 + client/src/mocks/handlers/oppgaver.ts | 7 +++-- client/src/oppgavebenk/useOppgavelisteV2.ts | 18 +++++++------ client/src/oppgaveliste/Oppgaveliste.tsx | 13 +++++++--- .../src/oppgaveliste/paging/PageCounter.tsx | 8 +++--- client/src/oppgaveliste/paging/Paging.tsx | 10 +++---- client/src/oppgaveliste/useOppgaveliste.ts | 23 ++++++++-------- .../src/saksbilde/hjelpemidler/Hastesak.tsx | 26 +++++++++---------- client/src/state/authentication.ts | 5 ++++ 9 files changed, 62 insertions(+), 49 deletions(-) diff --git a/client/src/felleskomponenter/table/Tabellkolonne.ts b/client/src/felleskomponenter/table/Tabellkolonne.ts index d53f2718..a241589e 100644 --- a/client/src/felleskomponenter/table/Tabellkolonne.ts +++ b/client/src/felleskomponenter/table/Tabellkolonne.ts @@ -5,6 +5,7 @@ export interface Tabellkolonne { name?: string width?: number sortable?: boolean + hide?: boolean header?(): ReactNode render(verdi: T): ReactNode diff --git a/client/src/mocks/handlers/oppgaver.ts b/client/src/mocks/handlers/oppgaver.ts index fa6ddb4e..4c0911d8 100644 --- a/client/src/mocks/handlers/oppgaver.ts +++ b/client/src/mocks/handlers/oppgaver.ts @@ -108,11 +108,10 @@ export const oppgaveHandlers: StoreHandlersFactory = ({ const response: OppgavelisteResponse = { oppgaver: !filterApplied ? oppgaver.slice(startIndex, endIndex) : filtrerteOppgaver.slice(startIndex, endIndex), + pageNumber, + pageSize, + totalPages: 1, totalElements: !filterApplied ? oppgaver.length : filtrerteOppgaver.length, - pageRequest: { - pageNumber, - pageSize, - }, antallHaster: !filterApplied ? oppgaver.filter(haster).length : filtrerteOppgaver.filter(haster).length, } diff --git a/client/src/oppgavebenk/useOppgavelisteV2.ts b/client/src/oppgavebenk/useOppgavelisteV2.ts index dc1d67a8..8cd1e6c8 100644 --- a/client/src/oppgavebenk/useOppgavelisteV2.ts +++ b/client/src/oppgavebenk/useOppgavelisteV2.ts @@ -1,15 +1,15 @@ import useSwr from 'swr' import { httpGet } from '../io/http' - -import { OppgaveV2 } from '../types/types.internal' import { PAGE_SIZE } from '../oppgaveliste/paging/Paging' +import { OppgaveV2 } from '../types/types.internal' interface DataResponse { oppgaver: OppgaveV2[] - totalCount: number - currentPage: number + pageNumber: number pageSize: number + totalPages: number + totalElements: number isLoading: boolean error: unknown mutate: (...args: any[]) => any @@ -35,9 +35,10 @@ interface Filters { interface OppgavelisteResponse { oppgaver: OppgaveV2[] - totalCount: number + pageNumber: number pageSize: number - currentPage: number + totalPages: number + totalElements: number } /* @@ -94,9 +95,10 @@ export function useOppgavelisteV2(currentPage: number /*, sort: SortState, filte return { oppgaver: data?.data.oppgaver || [], - totalCount: data?.data.totalCount || 0, + pageNumber: data?.data.pageNumber || currentPage, pageSize: data?.data.pageSize || PAGE_SIZE, - currentPage: data?.data.currentPage || currentPage, + totalPages: data?.data.totalPages || 0, + totalElements: data?.data.totalElements || 0, isLoading: !error && !data, error, mutate, diff --git a/client/src/oppgaveliste/Oppgaveliste.tsx b/client/src/oppgaveliste/Oppgaveliste.tsx index 1e9e6095..2aaee5d0 100644 --- a/client/src/oppgaveliste/Oppgaveliste.tsx +++ b/client/src/oppgaveliste/Oppgaveliste.tsx @@ -3,6 +3,7 @@ import styled from 'styled-components' import { DataCell, KolonneHeader } from '../felleskomponenter/table/KolonneHeader' import { LinkRow } from '../felleskomponenter/table/LinkRow' +import { useSaksbehandlerTilhørerEnhet } from '../state/authentication.ts' import { formaterFødselsnummer, formaterNavn, storForbokstavIAlleOrd } from '../utils/formater' import { isError } from '../utils/type' @@ -48,6 +49,9 @@ export function Oppgaveliste() { områdeFilter, }) + // NAV IT, Vestland-Bergen, Trøndelag + const pilotHast = useSaksbehandlerTilhørerEnhet('2970', '4712', '4716') + const handleFilter = (handler: (...args: any[]) => any, value: SakerFilter | OppgaveStatusType | OmrådeFilter) => { handler(value) setCurrentPage(1) @@ -102,6 +106,7 @@ export function Oppgaveliste() { { key: 'HAST', width: 105, + hide: !pilotHast, header() { return ( <> @@ -209,6 +214,8 @@ export function Oppgaveliste() { const hasData = oppgaver && oppgaver.length > 0 + const filterHide = ({ hide }: Tabellkolonne): boolean => hide !== true + return ( <> Oppgaveliste @@ -272,7 +279,7 @@ export function Oppgaveliste() { Oppgaveliste - {kolonner.map(({ key, name, width, sortable = true, header }) => ( + {kolonner.filter(filterHide).map(({ key, name, width, sortable = true, header }) => ( {header ? header() : name} @@ -289,7 +296,7 @@ export function Oppgaveliste() { : `/sak/${oppgave.sakId}` } > - {kolonner.map(({ key, width, render }) => ( + {kolonner.filter(filterHide).map(({ key, width, render }) => ( setCurrentPage(page)} /> diff --git a/client/src/oppgaveliste/paging/PageCounter.tsx b/client/src/oppgaveliste/paging/PageCounter.tsx index 61aadbba..3a8643b0 100644 --- a/client/src/oppgaveliste/paging/PageCounter.tsx +++ b/client/src/oppgaveliste/paging/PageCounter.tsx @@ -3,12 +3,12 @@ import styled from 'styled-components' import { Tekst } from '../../felleskomponenter/typografi' interface PageCounterProps { - totalCount: number + totalElements: number pageSize: number currentPage: number } -export function PageCounter({ pageSize, totalCount, currentPage }: PageCounterProps) { +export function PageCounter({ pageSize, totalElements, currentPage }: PageCounterProps) { const førsteSynligeOppgave = pageSize * (currentPage - 1) + 1 const sisteOppgave = førsteSynligeOppgave + pageSize - 1 @@ -17,8 +17,8 @@ export function PageCounter({ pageSize, totalCount, currentPage }: PageCounterPr {`Viser ${førsteSynligeOppgave} - ${ - sisteOppgave > totalCount ? totalCount : sisteOppgave - } av ${totalCount} saker`} + sisteOppgave > totalElements ? totalElements : sisteOppgave + } av ${totalElements} saker`} diff --git a/client/src/oppgaveliste/paging/Paging.tsx b/client/src/oppgaveliste/paging/Paging.tsx index 6c6b2f54..945d4e6d 100644 --- a/client/src/oppgaveliste/paging/Paging.tsx +++ b/client/src/oppgaveliste/paging/Paging.tsx @@ -13,13 +13,13 @@ const Container = styled.div` export const PAGE_SIZE = 25 interface PagingProps { - totalCount: number + totalElements: number currentPage: number - onPageChange: (...args: any[]) => any + onPageChange(...args: any[]): any } -export function Paging({ totalCount, currentPage, onPageChange }: PagingProps) { - const totalNumberOfPages = Math.ceil(totalCount / PAGE_SIZE) +export function Paging({ totalElements, currentPage, onPageChange }: PagingProps) { + const totalNumberOfPages = Math.ceil(totalElements / PAGE_SIZE) const hasMultiplePages = totalNumberOfPages > 1 return ( @@ -35,7 +35,7 @@ export function Paging({ totalCount, currentPage, onPageChange }: PagingProps) { /> )} - + ) } diff --git a/client/src/oppgaveliste/useOppgaveliste.ts b/client/src/oppgaveliste/useOppgaveliste.ts index 662d2ea2..a85a3117 100644 --- a/client/src/oppgaveliste/useOppgaveliste.ts +++ b/client/src/oppgaveliste/useOppgaveliste.ts @@ -1,19 +1,18 @@ +import { SortState } from '@navikt/ds-react' import { useEffect } from 'react' import useSwr from 'swr' -import { SortState } from '@navikt/ds-react' - import { httpGet } from '../io/http' -import { amplitude_taxonomy, logAmplitudeEvent } from '../utils/amplitude' - import { OmrådeFilter, Oppgave, OppgaveStatusType, SakerFilter, SakstypeFilter } from '../types/types.internal' +import { amplitude_taxonomy, logAmplitudeEvent } from '../utils/amplitude' import { PAGE_SIZE } from './paging/Paging' interface DataResponse { oppgaver: Oppgave[] - totalElements: number - currentPage: number + pageNumber: number pageSize: number + totalPages: number + totalElements: number antallHaster: number isLoading: boolean error: unknown @@ -36,11 +35,10 @@ interface OppgavelisteFilters { export interface OppgavelisteResponse { oppgaver: Oppgave[] + pageNumber: number + pageSize: number + totalPages: number totalElements: number - pageRequest: { - pageNumber: number - pageSize: number - } antallHaster: number } @@ -92,9 +90,10 @@ export function useOppgaveliste(currentPage: number, sort: SortState, filters: O return { oppgaver: data?.data.oppgaver || [], + pageNumber: data?.data.pageNumber || currentPage, + pageSize: data?.data.pageSize || PAGE_SIZE, + totalPages: data?.data.totalPages || 0, totalElements: data?.data.totalElements || 0, - currentPage: data?.data.pageRequest.pageNumber || currentPage, - pageSize: data?.data.pageRequest.pageSize || PAGE_SIZE, antallHaster: data?.data.antallHaster || 0, isLoading: !error && !data, error, diff --git a/client/src/saksbilde/hjelpemidler/Hastesak.tsx b/client/src/saksbilde/hjelpemidler/Hastesak.tsx index bff13974..24db1de7 100644 --- a/client/src/saksbilde/hjelpemidler/Hastesak.tsx +++ b/client/src/saksbilde/hjelpemidler/Hastesak.tsx @@ -1,5 +1,6 @@ -import { Hast, Hasteårsak } from '../../types/types.internal.ts' import { Alert, Box, List } from '@navikt/ds-react' +import { Etikett } from '../../felleskomponenter/typografi.tsx' +import { Hast, Hasteårsak } from '../../types/types.internal.ts' import { Fremhev, HjelpemiddelGrid } from './HjelpemiddelGrid.tsx' export function Hastesak(props: { hast?: Hast }) { @@ -14,18 +15,17 @@ export function Hastesak(props: { hast?: Hast }) { - - {årsaker - .map((årsak) => { - const tekst = tekstByHasteårsak[årsak] - return årsak === Hasteårsak.ANNET && begrunnelse - ? `${tekst} Formidlers begrunnelse: ${begrunnelse}` - : tekst - }) - .map((tekst) => ( - {tekst} - ))} - +
+ Årsak til at det haster: + + {årsaker + .map((årsak) => tekstByHasteårsak[årsak]) + .map((tekst) => ( + {tekst} + ))} + {begrunnelse && {begrunnelse}} + +
diff --git a/client/src/state/authentication.ts b/client/src/state/authentication.ts index bb787984..3ffdaf17 100644 --- a/client/src/state/authentication.ts +++ b/client/src/state/authentication.ts @@ -56,6 +56,11 @@ export function useInnloggetSaksbehandler(): InnloggetSaksbehandler { return useRecoilValue(innloggetSaksbehandlerState) } +export function useSaksbehandlerTilhørerEnhet(...enhet: string[]): boolean { + const { enhetsnumre } = useInnloggetSaksbehandler() + return enhet.some((it) => enhetsnumre.includes(it)) +} + export function useVisOppgavelisteTabs() { return useRecoilValue(visOppgavelisteTabsState) }