Skip to content

Commit

Permalink
IS-2795: Add toggle for sok and remove old toggles
Browse files Browse the repository at this point in the history
  • Loading branch information
eirikdahlen committed Nov 18, 2024
1 parent f75d4c4 commit b544a6a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 25 deletions.
6 changes: 1 addition & 5 deletions server/unleash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ export function getToggles(veilederId: any, enhetId: any) {
};
return {
isFlexjarArenaEnabled: unleash.isEnabled('isFlexjarArenaEnabled', context),
isFrisktilarbeidEnabled: unleash.isEnabled('isFrisktilarbeid', context),
isOppfolgingISenFaseEnabled: unleash.isEnabled(
'isOppfolgingISenFaseEnabled',
context
),
isSokEnabled: unleash.isEnabled('isSokEnabled', context),
};
}
21 changes: 5 additions & 16 deletions src/components/HendelseFilterPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { OverviewTabType } from '@/konstanter';
import { useFilters } from '@/context/filters/FilterContext';
import { ActionType } from '@/context/filters/filterContextActions';
import { useTabType } from '@/context/tab/TabTypeContext';
import { useFeatureToggles } from '@/data/unleash/unleashQueryHooks';
import { Toggles } from '@/data/unleash/types/unleash_types';
import {
FilterState,
HendelseTypeFilter,
Expand Down Expand Up @@ -157,11 +155,7 @@ function isChecked(state: HendelseTypeFilter, hendelse: Hendelse): boolean {
}
}

function showCheckbox(
toggles: Toggles,
hendelse: Hendelse,
tabType: OverviewTabType
): boolean {
function showCheckbox(hendelse: Hendelse, tabType: OverviewTabType): boolean {
switch (hendelse) {
case 'AKTIVITETSKRAV':
case 'AKTIVITETSKRAV_VURDER_STANS':
Expand All @@ -174,11 +168,9 @@ function showCheckbox(
case 'MANGLENDE_MEDVIRKNING':
case 'OPPFOLGINGSOPPGAVE':
case 'ARBEIDSUFORHET':
return true;
case 'FRISKMELDING_TIL_ARBEIDSFORMIDLING':
return toggles.isFrisktilarbeidEnabled;
case 'SNART_SLUTT_PA_SYKEPENGENE':
return toggles.isOppfolgingISenFaseEnabled;
return true;
case 'UFORDELTE_BRUKERE':
return tabType === OverviewTabType.ENHET_OVERVIEW;
}
Expand All @@ -195,8 +187,7 @@ interface CheckboxElement {
function hendelseCheckboxes(
personRegister: PersonregisterState | undefined,
filterState: FilterState,
tabType: OverviewTabType,
toggles: Toggles
tabType: OverviewTabType
): CheckboxElement[] {
return Object.entries(HendelseTekster).map(([hendelse, tekst]) => {
const filter = initFilter(hendelse as Hendelse);
Expand All @@ -207,7 +198,7 @@ function hendelseCheckboxes(
filterState.selectedHendelseType,
hendelse as Hendelse
);
const isVisible = showCheckbox(toggles, hendelse as Hendelse, tabType);
const isVisible = showCheckbox(hendelse as Hendelse, tabType);
return {
hendelse: hendelse,
tekst,
Expand All @@ -232,15 +223,13 @@ function CheckboxLabel({ labelText, antallHendelser }: CheckboxLabelProps) {
}

export function HendelseFilterPanel({ personRegister }: Props) {
const { toggles } = useFeatureToggles();
const { filterState, dispatch: dispatchFilterAction } = useFilters();
const { selectedTab } = useTabType();

const checkboxElements = hendelseCheckboxes(
personRegister,
filterState,
selectedTab,
toggles
selectedTab
).filter((checkboksElement) => checkboksElement.isVisible);

const onChange = (value: string) => {
Expand Down
6 changes: 2 additions & 4 deletions src/data/unleash/types/unleash_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ export type Toggles = {
// See toggles: https://teamsykefravr-unleash-web.nav.cloud.nais.io/features
export enum ToggleNames {
isFlexjarArenaEnabled = 'isFlexjarArenaEnabled',
isFrisktilarbeidEnabled = 'isFrisktilarbeidEnabled',
isOppfolgingISenFaseEnabled = 'isOppfolgingISenFaseEnabled',
isSokEnabled = 'isSokEnabled',
}

export const defaultToggles: Toggles = {
isFlexjarArenaEnabled: false,
isFrisktilarbeidEnabled: false,
isOppfolgingISenFaseEnabled: false,
isSokEnabled: false,
};

0 comments on commit b544a6a

Please sign in to comment.