-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Legg til erfaring som nytt søkefilter (#765)
Legg til erfaring som nytt søkefilter
- Loading branch information
Showing
9 changed files
with
228 additions
and
13 deletions.
There are no files selected for viewing
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,79 @@ | ||
import PropTypes from "prop-types"; | ||
import React from "react"; | ||
import { BodyShort, Checkbox, CheckboxGroup } from "@navikt/ds-react"; | ||
import { ADD_EXPERIENCE, REMOVE_EXPERIENCE } from "@/app/(sok)/_utils/queryReducer"; | ||
import mergeCount from "@/app/(sok)/_components/utils/mergeCount"; | ||
import { logFilterChanged } from "@/app/_common/monitoring/amplitude"; | ||
|
||
function Experience({ initialValues, updatedValues, query, dispatch }) { | ||
const sortedValues = sortExperienceValues(initialValues); | ||
const values = mergeCount(sortedValues, updatedValues); | ||
|
||
function handleClick(e) { | ||
const { value, checked } = e.target; | ||
if (checked) { | ||
dispatch({ type: ADD_EXPERIENCE, value }); | ||
} else { | ||
dispatch({ type: REMOVE_EXPERIENCE, value }); | ||
} | ||
logFilterChanged({ name: "Erfaring", value, checked }); | ||
} | ||
|
||
return ( | ||
<CheckboxGroup | ||
className="mb-4" | ||
value={query.experience} | ||
legend={ | ||
<> | ||
<BodyShort as="span" visuallyHidden> | ||
Filtrer etter erfaring | ||
</BodyShort> | ||
<span className="capitalize">Erfaring</span> | ||
</> | ||
} | ||
> | ||
{values.map((item) => ( | ||
<Checkbox key={item.key} name="experience[]" value={item.key} onChange={handleClick}> | ||
{`${labelForExperience(item.key)} (${item.count})`} | ||
</Checkbox> | ||
))} | ||
</CheckboxGroup> | ||
); | ||
} | ||
|
||
export const labelForExperience = (key) => { | ||
switch (key) { | ||
case "Ingen": | ||
return "Ingen krav til arbeidserfaring"; | ||
case "Noe": | ||
return "Noe arbeidserfaring (1-3år)"; | ||
case "Mye": | ||
return "Mye arbeidserfaring (4år+)"; | ||
default: | ||
return key; | ||
} | ||
}; | ||
|
||
function sortExperienceValues(facets) { | ||
if (!facets) { | ||
return undefined; | ||
} | ||
const sortedPublishedValues = ["Ingen", "Noe", "Mye", "Ikke oppgitt"]; | ||
return facets.sort((a, b) => sortedPublishedValues.indexOf(a.key) - sortedPublishedValues.indexOf(b.key)); | ||
} | ||
|
||
Experience.propTypes = { | ||
initialValues: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
key: PropTypes.string, | ||
count: PropTypes.number, | ||
}), | ||
).isRequired, | ||
updatedValues: PropTypes.arrayOf(PropTypes.shape({})), | ||
query: PropTypes.shape({ | ||
experience: PropTypes.arrayOf(PropTypes.string), | ||
}).isRequired, | ||
dispatch: PropTypes.func.isRequired, | ||
}; | ||
|
||
export default Experience; |
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
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,14 @@ | ||
import React from "react"; | ||
import { Link as AkselLink } from "@navikt/ds-react"; | ||
|
||
export default function NewFiltersMessage() { | ||
return ( | ||
<> | ||
Vi tester ut nye filtre og jobber med å gjøre dem mer nøyaktige. Vi bruker kunstig intelligens (KI) til å | ||
hjelpe oss med dette. Hvordan opplever du søkeresultatet?{" "} | ||
<AkselLink href="https://surveys.hotjar.com/8eedca7e-3fae-4852-8d96-4c9c80424cdc"> | ||
Skriv en kort tilbakemelding | ||
</AkselLink> | ||
</> | ||
); | ||
} |
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
Oops, something went wrong.