Skip to content

Commit

Permalink
renaming av funksjoner og components
Browse files Browse the repository at this point in the history
  • Loading branch information
taniaholst committed Feb 6, 2024
1 parent 34dc6d8 commit 70d0e22
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { useHydrateAtoms } from "jotai/utils";
import { ReactNode, useEffect, useState } from "react";
import { AppContextData, modiaContextAtom } from "./hooks/useModiaContext";
import {
Filter,
filterAtom,
FilterMedBrukerIKontekst,
getDefaultFilterForBrukerIKontekst,
} from "@/hooks/useArbeidsmarkedstiltakFilter";
import { ReactQueryProvider } from "@/ReactQueryProvider";
Expand All @@ -21,7 +21,7 @@ function HydrateAtoms({
children,
}: {
appContext: Partial<AppContextData>;
filter: Filter;
filter: FilterMedBrukerIKontekst;
children: ReactNode;
}) {
/**
Expand All @@ -37,7 +37,7 @@ function HydrateAtoms({
export function ModiaContext(props: ModiaContextProps) {
const [contextData, setContextData] = useAtom(modiaContextAtom);

const [loadedFilter, setLoadedFilter] = useState<Filter | null>(null);
const [loadedFilter, setLoadedFilter] = useState<FilterMedBrukerIKontekst | null>(null);

useEffect(() => {
if (props.contextData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import {
ArbeidsmarkedstiltakFilterGruppe,
useArbeidsmarkedstiltakFilter,
} from "@/hooks/useArbeidsmarkedstiltakFilter";
import FilterTag from "../tags/FilterTag";
import styles from "./Filtertags.module.scss";
import { NavEnhetTag } from "../tags/NavEnhetTag";
import FilterTag from "../../../components/tags/FilterTag";
import { NavEnhetTag } from "@/components/tags/NavEnhetTag";
import { FilterTagsContainer } from "@/components/filtrering/FilterTagsContainer";

export function Filtertags() {
export function ModiaFilterTags() {
const [filter, setFilter] = useArbeidsmarkedstiltakFilter();

return (
<div className={styles.filtertags} data-testid="filtertags">
<FilterTagsContainer>
<NavEnhetTag />
{filter.apentForInnsok !== ApentForInnsok.APENT_ELLER_STENGT && (
<FilterTag
Expand Down Expand Up @@ -47,6 +47,6 @@ export function Filtertags() {
handleClick={() => setFilter({ ...filter, search: "" })}
/>
)}
</div>
</FilterTagsContainer>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { TiltakLoader } from "@/components/TiltakLoader";
import { BrukersOppfolgingsenhetVarsel } from "@/apps/modia/varsler/BrukersOppfolgingsenhetVarsel";
import { Feilmelding, ForsokPaNyttLink } from "@/components/feilmelding/Feilmelding";
import { FilterAndTableLayout } from "@/components/filtrering/FilterAndTableLayout";
import { Filtertags } from "@/components/filtrering/Filtertags";
import { ModiaFilterTags } from "@/apps/modia/filtrering/ModiaFilterTags";
import { HistorikkButton } from "@/apps/modia/historikk/HistorikkButton";
import { BrukerHarIkke14aVedtakVarsel } from "@/apps/modia/varsler/BrukerHarIkke14aVedtakVarsel";
import { FiltrertFeilInnsatsgruppeVarsel } from "@/apps/modia/varsler/FiltrertFeilInnsatsgruppeVarsel";
Expand Down Expand Up @@ -142,7 +142,7 @@ export const ModiaArbeidsmarkedstiltakOversikt = () => {
</>
}
filter={<FilterMenyMedSkeletonLoader />}
tags={<Filtertags />}
tags={<ModiaFilterTags />}
table={
<div style={{ marginTop: "1rem" }}>
<BrukersOppfolgingsenhetVarsel brukerdata={brukerdata} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import {
ArbeidsmarkedstiltakFilterGruppe,
useArbeidsmarkedstiltakFilterUtenBrukerIKontekst,
} from "@/hooks/useArbeidsmarkedstiltakFilter";
import FilterTag from "../tags/FilterTag";
import styles from "./Filtertags.module.scss";
import { NavEnhetTag } from "../tags/NavEnhetTag";
import FilterTag from "../../../components/tags/FilterTag";
import { NavEnhetTag } from "../../../components/tags/NavEnhetTag";
import { FilterTagsContainer } from "@/components/filtrering/FilterTagsContainer";

export function FiltertagsArbeidsmarkedstiltak() {
export function NavFilterTags() {
const [filter, setFilter] = useArbeidsmarkedstiltakFilterUtenBrukerIKontekst();

return (
<div className={styles.filtertags} data-testid="filtertags">
<FilterTagsContainer>
{filter.search && (
<FilterTag
options={[{ id: "search", tittel: `'${filter.search}'` }]}
Expand Down Expand Up @@ -54,6 +54,6 @@ export function FiltertagsArbeidsmarkedstiltak() {
})
}
/>
</div>
</FilterTagsContainer>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
useResetArbeidsmarkedstiltakFilterUtenBrukerIKontekst,
valgteEnhetsnumre,
} from "@/hooks/useArbeidsmarkedstiltakFilter";
import { FiltertagsArbeidsmarkedstiltak } from "@/components/filtrering/FiltertagsArbeidsmarkedstiltak";
import { NavFilterTags } from "@/apps/nav/filtrering/NavFilterTags";

interface Props {
preview: boolean;
Expand All @@ -27,7 +27,7 @@ export const NavArbeidsmarkedstiltakOversikt = ({ preview }: Props) => {
<FilterAndTableLayout
buttons={null}
filter={<FilterMenyMedSkeletonLoader />}
tags={<FiltertagsArbeidsmarkedstiltak />}
tags={<NavFilterTags />}
resetButton={
filterHasChanged && (
<Button
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import styles from "@/components/filtrering/FilterTagsContainer.module.scss";
import { PropsWithChildren } from "react";

export function FilterTagsContainer(props: PropsWithChildren) {
return (
<div className={styles.filtertags} data-testid="filtertags">
{props.children}
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,14 @@ export function useResetArbeidsmarkedstiltakFilterUtenBrukerIKontekst() {
};
}

export interface Filter {
export interface FilterMedBrukerIKontekst {
brukerIKontekst: string | null;
filter: ArbeidsmarkedstiltakFilter;
}

export function getDefaultFilterForBrukerIKontekst(brukerIKontekst: string | null): Filter {
export function getDefaultFilterForBrukerIKontekst(
brukerIKontekst: string | null,
): FilterMedBrukerIKontekst {
const defaultFilterForBrukerIKontekst = {
brukerIKontekst,
filter: defaultTiltaksgjennomforingfilter,
Expand All @@ -123,7 +125,9 @@ export function getDefaultFilterForBrukerIKontekst(brukerIKontekst: string | nul
: defaultFilterForBrukerIKontekst;
}

const filterStorage: SyncStorage<Filter> = createJSONStorage(() => sessionStorage);
const filterStorage: SyncStorage<FilterMedBrukerIKontekst> = createJSONStorage(
() => sessionStorage,
);

const ARBEIDSMARKEDSTILTAK_FILTER_KEY = "arbeidsmarkedstiltak-filter";

Expand All @@ -135,7 +139,7 @@ const defaultTiltaksgjennomforingfilter: ArbeidsmarkedstiltakFilter = {
apentForInnsok: ApentForInnsok.APENT_ELLER_STENGT,
};

export const filterAtom = atomWithStorage<Filter>(
export const filterAtom = atomWithStorage<FilterMedBrukerIKontekst>(
ARBEIDSMARKEDSTILTAK_FILTER_KEY,
{ brukerIKontekst: null, filter: defaultTiltaksgjennomforingfilter },
filterStorage,
Expand Down

0 comments on commit 70d0e22

Please sign in to comment.