Skip to content

Commit

Permalink
review from valentin
Browse files Browse the repository at this point in the history
  • Loading branch information
desoindx committed Nov 25, 2024
1 parent 084d317 commit 7e6d1af
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
7 changes: 6 additions & 1 deletion src/components/outils/AlimentationSimulator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@ const AlimentationSimulator = () => {
const t = useTranslations('alimentation')
const values = useMemo(() => equivalentsByCategory[category], [category])
const [openCategories, setOpenCategories] = React.useState<Record<string, boolean>>({})

return customList ? (
<CategorySimulator
equivalents={computedEquivalents.filter((equivalent) => equivalents.includes(equivalent.slug))}
equivalents={computedEquivalents.filter(
(equivalent, index) =>
equivalents.includes(equivalent.slug) &&
computedEquivalents.findIndex((e) => e.slug === equivalent.slug) === index
)}
tracking='Alimentation'
reverse
/>
Expand Down
13 changes: 8 additions & 5 deletions src/components/shareable/overScreens/AlimentationListParam.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import classNames from 'classnames'
import { useTranslations } from 'next-intl'
import { SetStateAction } from 'preact/compat'
import React, { Dispatch } from 'react'
import { Dispatch } from 'react'
import useParamContext from 'src/providers/ParamProvider'
import { getNameWithoutSuffix } from 'utils/Equivalent/equivalent'
import { AlimentationCategories, equivalentsByCategory } from 'utils/alimentation'
Expand Down Expand Up @@ -30,11 +30,14 @@ const AlimentationListParam = ({
asLink
type='button'
onClick={() =>
setEquivalents(
equivalents.filter((equivalent) => category.equivalents.every(({ slug }) => equivalent !== slug))
)
setEquivalents([
...equivalents,
...category.equivalents
.map(({ slug }) => slug)
.filter((equivalent) => !equivalents.includes(equivalent)),
])
}>
{t('deselect')}
{t('select')}
</Button>
</div>
<ul className={listStyles.equivalents}>
Expand Down
2 changes: 1 addition & 1 deletion src/providers/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@
"boulangerie": "Bakery",
"epiceriesalee": "Savory groceries",
"epiceriesucree": "Sweet groceries",
"deselect": "deselect all",
"select": "select all",
"integrate": {
"customList": "Custom list",
"hideButtons": "Show buttons"
Expand Down
2 changes: 1 addition & 1 deletion src/providers/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@
"boulangerie": "Panadería",
"epiceriesalee": "Comestibles salados",
"epiceriesucree": "Comestibles dulces",
"deselect": "deseleccionar todo",
"select": "seleccionar todo",
"integrate": {
"customList": "Lista personalizada",
"hideButtons": "Mostrar botones"
Expand Down
2 changes: 1 addition & 1 deletion src/providers/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@
"boulangerie": "Boulangerie",
"epiceriesalee": "Épicerie salée",
"epiceriesucree": "Épicerie sucrée",
"deselect": "tout désélectionner",
"select": "tout sélectionner",
"integrate": {
"customList": "Liste personnalisée",
"hideButtons": "Affichage des boutons"
Expand Down

0 comments on commit 7e6d1af

Please sign in to comment.