From 2c22db7393ef191bb9c26d4448e9a25421fe44a6 Mon Sep 17 00:00:00 2001 From: Anders Rognstad Date: Thu, 28 Nov 2024 15:30:52 +0100 Subject: [PATCH] Refactor tab type --- src/components/Filter/HendelseFilter.tsx | 9 ++- src/components/FristDataCell.tsx | 9 ++- src/components/NavigationBar.tsx | 12 ++-- src/components/NewOversiktTable.tsx | 7 +-- src/components/Sokeresultat.tsx | 5 +- .../toolbar/AssignVeileder/TildelVeileder.tsx | 2 +- src/components/toolbar/Toolbar.tsx | 5 +- src/containers/Oversikt.tsx | 5 +- src/containers/OversiktContainer.tsx | 28 ++++----- src/context/tab/TabTypeContext.tsx | 33 ---------- src/hooks/useTabType.ts | 21 +++++++ src/index.tsx | 19 +++--- src/konstanter.ts | 4 -- src/routers/AppRouter.tsx | 22 +++---- src/routers/routes.ts | 7 +++ test/components/FristColumnTest.tsx | 33 ++++++---- test/components/HendelseTypeFilter.test.tsx | 61 +++++++------------ test/components/NewOversiktTableTest.tsx | 9 ++- test/components/Sokeresultat.test.tsx | 14 +++-- test/containers/OversiktContainer.test.tsx | 55 +++++++---------- test/testRenderUtils.tsx | 13 ++++ 21 files changed, 171 insertions(+), 202 deletions(-) delete mode 100644 src/context/tab/TabTypeContext.tsx create mode 100644 src/hooks/useTabType.ts delete mode 100644 src/konstanter.ts create mode 100644 src/routers/routes.ts create mode 100644 test/testRenderUtils.tsx diff --git a/src/components/Filter/HendelseFilter.tsx b/src/components/Filter/HendelseFilter.tsx index e8145748..13c7137c 100644 --- a/src/components/Filter/HendelseFilter.tsx +++ b/src/components/Filter/HendelseFilter.tsx @@ -1,10 +1,8 @@ import React from 'react'; import { PersonregisterState } from '@/api/types/personregisterTypes'; import { filterOnPersonregister } from '@/utils/hendelseFilteringUtils'; -import { OverviewTabType } from '@/konstanter'; import { useFilters } from '@/context/filters/FilterContext'; import { ActionType } from '@/context/filters/filterContextActions'; -import { useTabType } from '@/context/tab/TabTypeContext'; import { FilterState, HendelseTypeFilter, @@ -12,6 +10,7 @@ import { import { Checkbox, CheckboxGroup } from '@navikt/ds-react'; import * as Amplitude from '@/utils/amplitude'; import { EventType } from '@/utils/amplitude'; +import { TabType, useTabType } from '@/hooks/useTabType'; export const HendelseTekster = { UFORDELTE_BRUKERE: 'Ufordelte brukere', // Ikke tildelt veileder @@ -154,7 +153,7 @@ function isChecked(state: HendelseTypeFilter, hendelse: Hendelse): boolean { } } -function showCheckbox(hendelse: Hendelse, tabType: OverviewTabType): boolean { +function showCheckbox(hendelse: Hendelse, tabType: TabType): boolean { switch (hendelse) { case 'AKTIVITETSKRAV': case 'AKTIVITETSKRAV_VURDER_STANS': @@ -171,7 +170,7 @@ function showCheckbox(hendelse: Hendelse, tabType: OverviewTabType): boolean { case 'SNART_SLUTT_PA_SYKEPENGENE': return true; case 'UFORDELTE_BRUKERE': - return tabType === OverviewTabType.ENHET_OVERVIEW; + return tabType === TabType.ENHETENS_OVERSIKT; } } @@ -186,7 +185,7 @@ interface CheckboxElement { function hendelseCheckboxes( personRegister: PersonregisterState | undefined, filterState: FilterState, - tabType: OverviewTabType + tabType: TabType ): CheckboxElement[] { return Object.entries(HendelseTekster).map(([hendelse, tekst]) => { const filter = initFilter(hendelse as Hendelse); diff --git a/src/components/FristDataCell.tsx b/src/components/FristDataCell.tsx index 1fef4477..d18caecd 100644 --- a/src/components/FristDataCell.tsx +++ b/src/components/FristDataCell.tsx @@ -10,8 +10,7 @@ import { AktivitetskravStatus } from '@/api/types/personoversiktTypes'; import { Button, Table, Tooltip } from '@navikt/ds-react'; import OppfolgingsoppgaveModal from '@/components/OppfolgingsoppgaveModal'; import * as Amplitude from '@/utils/amplitude'; -import { useTabType } from '@/context/tab/TabTypeContext'; -import { OverviewTabType } from '@/konstanter'; +import { TabType, useTabType } from '@/hooks/useTabType'; const texts = { tooltipAvventer: 'Avventer til', @@ -51,7 +50,7 @@ function fristerInfo( manglendeMedvirkning, }: PersonData, setIsModalOpen: (open: boolean) => void, - selectedTab: OverviewTabType + selectedTab: TabType ): Frist[] { const frister: Frist[] = []; const aktivitetskravStatus = aktivitetskravvurdering?.status; @@ -88,7 +87,7 @@ function fristerInfo( if (oppfolgingsoppgave?.frist) { frister.push({ icon: () => - selectedTab === OverviewTabType.MY_OVERVIEW ? ( + selectedTab === TabType.MIN_OVERSIKT ? (