-
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.
- Loading branch information
1 parent
404e28e
commit 344ec38
Showing
9 changed files
with
169 additions
and
61 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
52 changes: 52 additions & 0 deletions
52
...lighetsrommet-veileder-flate/src/components/filtrering/FiltertagsArbeidsmarkedstiltak.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,52 @@ | ||
import { ApentForInnsok } from "mulighetsrommet-api-client"; | ||
import { | ||
ArbeidsmarkedstiltakFilterGruppe, | ||
useArbeidsmarkedstiltakFilter, | ||
} from "@/hooks/useArbeidsmarkedstiltakFilter"; | ||
import FilterTag from "../tags/FilterTag"; | ||
import styles from "./Filtertags.module.scss"; | ||
import { NavEnhetTag } from "./NavEnhetTag"; | ||
|
||
export function Filtertags() { | ||
const [filter, setFilter] = useArbeidsmarkedstiltakFilter(); | ||
|
||
return ( | ||
<div className={styles.filtertags} data-testid="filtertags"> | ||
<NavEnhetTag /> | ||
{filter.apentForInnsok !== ApentForInnsok.APENT_ELLER_STENGT && ( | ||
<FilterTag | ||
options={[ | ||
{ | ||
id: filter.apentForInnsok, | ||
tittel: filter.apentForInnsok === ApentForInnsok.APENT ? "Åpent" : "Stengt", | ||
}, | ||
]} | ||
handleClick={() => | ||
setFilter({ | ||
...filter, | ||
apentForInnsok: ApentForInnsok.APENT_ELLER_STENGT, | ||
}) | ||
} | ||
/> | ||
)} | ||
{filter.innsatsgruppe && <FilterTag options={[filter.innsatsgruppe]} />} | ||
<FilterTag | ||
options={filter.tiltakstyper} | ||
handleClick={(id: string) => | ||
setFilter({ | ||
...filter, | ||
tiltakstyper: filter.tiltakstyper?.filter( | ||
(tiltakstype: ArbeidsmarkedstiltakFilterGruppe<string>) => tiltakstype.id !== id, | ||
), | ||
}) | ||
} | ||
/> | ||
{filter.search && ( | ||
<FilterTag | ||
options={[{ id: "search", tittel: `'${filter.search}'` }]} | ||
handleClick={() => setFilter({ ...filter, search: "" })} | ||
/> | ||
)} | ||
</div> | ||
); | ||
} |
Empty file.
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
39 changes: 0 additions & 39 deletions
39
frontend/mulighetsrommet-veileder-flate/src/components/filtrering/NavEnhetTag.tsx
This file was deleted.
Oops, something went wrong.
62 changes: 62 additions & 0 deletions
62
frontend/mulighetsrommet-veileder-flate/src/components/tags/NavEnhetTag.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,62 @@ | ||
import { Tag } from "@navikt/ds-react"; | ||
import { | ||
useArbeidsmarkedstiltakFilterValue, | ||
valgteEnhetsnumre, | ||
} from "@/hooks/useArbeidsmarkedstiltakFilter"; | ||
import { useNavEnheter } from "@/core/api/queries/useNavEnheter"; | ||
import { NavEnhet } from "mulighetsrommet-api-client"; | ||
import Ikonknapp from "@/components/knapper/Ikonknapp"; | ||
import { XMarkIcon } from "@navikt/aksel-icons"; | ||
import { kebabCase } from "@/utils/Utils"; | ||
import styles from "./Filtertag.module.scss"; | ||
|
||
interface Props { | ||
handleClick?: (id: string) => void; | ||
} | ||
|
||
export function NavEnhetTag({ handleClick }: Props) { | ||
const filter = useArbeidsmarkedstiltakFilterValue(); | ||
const { data: alleEnheter } = useNavEnheter(); | ||
const enheter = valgteEnhetsnumre(filter); | ||
|
||
if (!alleEnheter || !filter || enheter.length === 0) { | ||
return null; | ||
} | ||
|
||
function tagLabel() { | ||
const firstEnhetName = alleEnheter?.find( | ||
(enhet: NavEnhet) => enhet.enhetsnummer === enheter[0], | ||
)?.navn; | ||
if (enheter.length > 1) { | ||
return `${firstEnhetName} +${enheter.length - 1}`; | ||
} | ||
return firstEnhetName; | ||
} | ||
|
||
return ( | ||
<Tag | ||
key="navenhet" | ||
size="small" | ||
data-testid="filtertag_navenhet" | ||
title="Valgt enhet" | ||
variant="info" | ||
> | ||
{tagLabel()} | ||
{handleClick ? ( | ||
<Ikonknapp | ||
className={styles.overstyrt_ikon_knapp} | ||
handleClick={() => handleClick(filtertype.id)} | ||
ariaLabel="Lukke" | ||
data-testid={`filtertag_lukkeknapp_${kebabCase(filtertype.tittel)}`} | ||
icon={ | ||
<XMarkIcon | ||
data-testid={`filtertag_lukkeknapp_${kebabCase(filtertype.tittel)}`} | ||
className={styles.ikon} | ||
aria-label="Lukke" | ||
/> | ||
} | ||
/> | ||
) : null} | ||
</Tag> | ||
); | ||
} |
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