Total HT |
{quarters.map((q) => {
- const value = sum(
+ const value = arraySum(
Object.values(budget[selectedYear]?.[q] ?? {})
)
@@ -150,9 +153,11 @@ export default function Budget() {
})}
{formatValue(
- sum(
+ arraySum(
quarters.map((q) =>
- sum(Object.values(budget[selectedYear]?.[q] ?? {}))
+ arraySum(
+ Object.values(budget[selectedYear]?.[q] ?? {})
+ )
)
),
{
@@ -166,7 +171,8 @@ export default function Budget() {
| Total TTC |
{quarters.map((q) => {
const value = Math.round(
- sum(Object.values(budget[selectedYear]?.[q] ?? {})) * 1.2
+ arraySum(Object.values(budget[selectedYear]?.[q] ?? {})) *
+ 1.2
)
return (
@@ -183,10 +189,10 @@ export default function Budget() {
{formatValue(
Math.round(
- sum(
+ arraySum(
quarters.map(
(q) =>
- sum(
+ arraySum(
Object.values(budget[selectedYear]?.[q] ?? {})
) * 1.2
)
diff --git a/site/source/pages/Creer/GuideStatut/PickLegalStatus.tsx b/site/source/pages/Creer/GuideStatut/PickLegalStatus.tsx
index 2725f2ceb..c451e9966 100644
--- a/site/source/pages/Creer/GuideStatut/PickLegalStatus.tsx
+++ b/site/source/pages/Creer/GuideStatut/PickLegalStatus.tsx
@@ -2,7 +2,6 @@ import { SitePathsContext } from '@/components/utils/SitePathsContext'
import { Button } from '@/design-system/buttons'
import { H2, H3 } from '@/design-system/typography/heading'
import { Body } from '@/design-system/typography/paragraphs'
-import { filter } from 'ramda'
import { Fragment, useContext } from 'react'
import { Helmet } from 'react-helmet-async'
import { Trans, useTranslation } from 'react-i18next'
@@ -111,20 +110,25 @@ export default function SetMainStatus() {
)}
- {Object.keys(filter(Boolean, possibleStatus)).map(
- /* https://github.com/microsoft/TypeScript/issues/32811 */
- (statut: any) => (
-
-
-
-
-
-
-
-
-
- )
- )}
+ {Object.entries(possibleStatus)
+ .filter(([, v]) => Boolean(v))
+ .map(
+ /* https://github.com/microsoft/TypeScript/issues/32811 */
+ ([statut]) => (
+
+
+
+
+
+
+
+
+
+ )
+ )}
>
)
}
diff --git a/site/source/pages/Creer/GuideStatut/PreviousAnswers.tsx b/site/source/pages/Creer/GuideStatut/PreviousAnswers.tsx
index c989edb5b..3aad115ec 100644
--- a/site/source/pages/Creer/GuideStatut/PreviousAnswers.tsx
+++ b/site/source/pages/Creer/GuideStatut/PreviousAnswers.tsx
@@ -1,6 +1,5 @@
import { SitePathsContext } from '@/components/utils/SitePathsContext'
import { Link } from '@/design-system/typography/link'
-import { isNil } from 'ramda'
import { useContext } from 'react'
import { Trans } from 'react-i18next'
import { useSelector } from 'react-redux'
@@ -77,7 +76,7 @@ export default function PreviousAnswers() {
{Object.entries(legalStatus).map(
([key, value]) =>
- !isNil(value) && (
+ value !== undefined && (
{
) as (keyof typeof state.choixStatutJuridique.companyLegalStatus)[]
)
useEffect(() => {
- const companyStatusCurrentQuestionName = (toPairs(
+ const companyStatusCurrentQuestionName = (Object.entries(
sitePaths.créer.guideStatut
).find(([, pathname]) => location.pathname === pathname) || [])[0]
if (!companyStatusCurrentQuestionName) {
return
}
- const answersToReset = dropWhile(
- (a) => a !== companyStatusCurrentQuestionName,
- answeredQuestion
+ const firstAnswerToResetIndex = answeredQuestion.findIndex(
+ (a) => a === companyStatusCurrentQuestionName
)
- if (!answersToReset.length) {
- return
+
+ if (firstAnswerToResetIndex !== -1) {
+ dispatch(
+ resetCompanyStatusChoice(
+ answeredQuestion.slice(firstAnswerToResetIndex)
+ )
+ )
}
- dispatch(resetCompanyStatusChoice(answersToReset))
}, [location.pathname, dispatch, sitePaths.créer.guideStatut])
}
diff --git a/site/source/pages/Simulateurs/EconomieCollaborative/ActivitésSelection.tsx b/site/source/pages/Simulateurs/EconomieCollaborative/ActivitésSelection.tsx
index ade87e11a..57534db3a 100644
--- a/site/source/pages/Simulateurs/EconomieCollaborative/ActivitésSelection.tsx
+++ b/site/source/pages/Simulateurs/EconomieCollaborative/ActivitésSelection.tsx
@@ -5,7 +5,6 @@ import { ScrollToTop } from '@/components/utils/Scroll'
import { Spacing } from '@/design-system/layout'
import { H1, H2 } from '@/design-system/typography/heading'
import { Body, SmallBody } from '@/design-system/typography/paragraphs'
-import { intersection } from 'ramda'
import { useContext } from 'react'
import { Trans, useTranslation } from 'react-i18next'
import { TrackPage } from '../../../ATInternetTracking'
@@ -90,10 +89,9 @@ export const ActivitéSelection = ({
}: ActivitéSelectionProps) => {
const { state } = useContext(StoreContext)
const activitéRépondue = activitésRéponduesSelector(state)
- const nextButtonDisabled = !intersection(
- activitésEffectuéesSelector(state),
- activités
- ).length
+ const nextButtonDisabled = activitésEffectuéesSelector(state).every(
+ (a) => !activités.includes(a)
+ )
return (
<>
diff --git a/site/source/pages/Stats/SatisfactionChart.tsx b/site/source/pages/Stats/SatisfactionChart.tsx
index 22a0a157c..4202b7876 100644
--- a/site/source/pages/Stats/SatisfactionChart.tsx
+++ b/site/source/pages/Stats/SatisfactionChart.tsx
@@ -3,7 +3,6 @@ import Emoji from '@/components/utils/Emoji'
import { Strong } from '@/design-system/typography'
import { Li, Ul } from '@/design-system/typography/list'
import { Body } from '@/design-system/typography/paragraphs'
-import { add, mapObjIndexed } from 'ramda'
import {
Bar,
BarChart,
@@ -25,9 +24,11 @@ export const SatisfactionStyle: [
]
function toPercentage(data: Record): Record {
- const total = Object.values(data).reduce(add)
+ const total = Object.values(data).reduce((a, b: number) => a + b, 0)
- return { ...mapObjIndexed((value) => (100 * value) / total, data), total }
+ return Object.fromEntries(
+ Object.entries(data).map(([key, value]) => [key, (100 * value) / total])
+ )
}
type SatisfactionChartProps = {
diff --git a/site/source/pages/Stats/Stats.tsx b/site/source/pages/Stats/Stats.tsx
index 19509de88..b321975ae 100644
--- a/site/source/pages/Stats/Stats.tsx
+++ b/site/source/pages/Stats/Stats.tsx
@@ -8,7 +8,7 @@ import { Item, Select } from '@/design-system/field/Select'
import { Spacing } from '@/design-system/layout'
import { H2, H3 } from '@/design-system/typography/heading'
import { formatValue } from 'publicodes'
-import { add, groupBy, mapObjIndexed, mergeWith, toPairs } from 'ramda'
+import { add, groupBy, mapObjIndexed, mergeWith } from 'ramda'
import { useCallback, useEffect, useMemo, useState } from 'react'
import { Trans } from 'react-i18next'
import { useHistory, useLocation } from 'react-router-dom'
@@ -46,7 +46,7 @@ const isPAM = (name: string | undefined) =>
].includes(name)
const filterByChapter2 = (pages: Pageish[], chapter2: Chapter2 | '') => {
- return toPairs(
+ return Object.entries(
groupBy(
(p) => ('date' in p ? p.date : p.month),
pages.filter(
@@ -67,7 +67,7 @@ const filterByChapter2 = (pages: Pageish[], chapter2: Chapter2 | '') => {
}
function groupByDate(data: Pageish[]) {
- return toPairs(
+ return Object.entries(
groupBy(
(p) => ('date' in p ? p.date : p.month),
data.filter((d) => 'page' in d && d.page === 'accueil')
diff --git a/site/source/pages/gerer/demande-mobilité/index.tsx b/site/source/pages/gerer/demande-mobilité/index.tsx
index 2fad2074a..0d554f154 100644
--- a/site/source/pages/gerer/demande-mobilité/index.tsx
+++ b/site/source/pages/gerer/demande-mobilité/index.tsx
@@ -10,11 +10,10 @@ import { Button } from '@/design-system/buttons'
import { Spacing } from '@/design-system/layout'
import { headings } from '@/design-system/typography'
import { Intro, SmallBody } from '@/design-system/typography/paragraphs'
-import { evaluateQuestion, hash } from '@/utils'
+import { evaluateQuestion, hash, omit } from '@/utils'
import { Grid } from '@mui/material'
import { DottedName } from 'modele-social'
import Engine, { PublicodesExpression } from 'publicodes'
-import { omit } from 'ramda'
import {
Fragment,
lazy,
@@ -80,7 +79,7 @@ function FormulairePublicodes() {
const onChange = useCallback(
(dottedName, value) => {
if (value === undefined) {
- setSituation((situation) => omit([dottedName], situation))
+ setSituation((situation) => omit(situation, dottedName))
} else {
setSituation((situation) => ({
...situation,
diff --git a/site/source/reducers/rootReducer.ts b/site/source/reducers/rootReducer.ts
index e1c5d3e80..17be2d1ff 100644
--- a/site/source/reducers/rootReducer.ts
+++ b/site/source/reducers/rootReducer.ts
@@ -2,7 +2,6 @@ import { Action } from '@/actions/actions'
import { Commune } from '@/api/commune'
import { PreviousSimulation } from '@/selectors/previousSimulationSelectors'
import { DottedName } from 'modele-social'
-import { defaultTo, without } from 'ramda'
import reduceReducers from 'reduce-reducers'
import { combineReducers, Reducer } from 'redux'
import { objectifsSelector } from '../selectors/simulationSelectors'
@@ -114,17 +113,16 @@ function simulation(
}
case 'UPDATE_SITUATION': {
- const objectifs = without(
- ['entreprise . charges'],
- objectifsSelector({ simulation: state } as RootState)
- )
+ const objectifs = objectifsSelector({
+ simulation: state,
+ } as RootState).filter((name) => name !== 'entreprise . charges')
const situation = state.situation
const { fieldName: dottedName, value } = action
if (value === undefined) {
return { ...state, situation: omit(situation, dottedName) }
}
if (objectifs.includes(dottedName)) {
- const objectifsToReset = without([dottedName], objectifs)
+ const objectifsToReset = objectifs.filter((name) => name !== dottedName)
const newSituation = Object.fromEntries(
Object.entries(situation).filter(
([dottedName]) =>
@@ -160,7 +158,7 @@ function simulation(
if (name === 'unfold') {
return {
...state,
- foldedSteps: without([step], state.foldedSteps),
+ foldedSteps: state.foldedSteps.filter((name) => name !== step),
unfoldedStep: step,
}
}
@@ -197,7 +195,7 @@ const mainReducer = combineReducers({
explainedVariable,
simulation,
companySituation,
- previousSimulation: defaultTo(null) as Reducer,
+ previousSimulation: ((p) => p ?? null) as Reducer,
activeTargetInput,
choixStatutJuridique,
})
diff --git a/site/source/selectors/previousSimulationSelectors.ts b/site/source/selectors/previousSimulationSelectors.ts
index c8c71297c..53768d642 100644
--- a/site/source/selectors/previousSimulationSelectors.ts
+++ b/site/source/selectors/previousSimulationSelectors.ts
@@ -3,7 +3,7 @@ import { DottedName } from 'modele-social'
export type PreviousSimulation = {
situation: Simulation['situation']
- activeTargetInput: RootState['activeTargetInput']
+ activeTargetInput: DottedName | null
foldedSteps: Array | undefined
}
diff --git a/site/source/sitePaths.ts b/site/source/sitePaths.ts
index ba5aea76d..11542bc12 100644
--- a/site/source/sitePaths.ts
+++ b/site/source/sitePaths.ts
@@ -1,5 +1,4 @@
import { MetadataSrc } from 'pages/Simulateurs/metadata-src'
-import { reduce, toPairs, zipObj } from 'ramda'
import { LegalStatus } from '@/selectors/companyStatusSelectors'
export const LANDING_LEGAL_STATUS_LIST: Array = [
@@ -235,13 +234,12 @@ export const constructLocalizedSitePath = (language: 'en' | 'fr') => {
export type SitePathsType = ReturnType
const deepReduce = (fn: any, initialValue?: any, object?: any): any =>
- reduce(
+ Object.entries(object).reduce(
(acc, [key, value]) =>
typeof value === 'object'
? deepReduce(fn, acc, value)
: fn(acc, value, key),
- initialValue,
- toPairs(object)
+ initialValue
)
type SiteMap = Array
@@ -271,12 +269,10 @@ const frSiteMap = generateSiteMap(constructLocalizedSitePath('fr')).map(
)
export const hrefLangLink = {
- en: zipObj(
- enSiteMap,
- frSiteMap.map((href) => [{ href, hrefLang: 'fr' }])
+ en: Object.fromEntries(
+ enSiteMap.map((key, i) => [key, { href: frSiteMap[i], hrefLang: 'fr' }])
),
- fr: zipObj(
- frSiteMap,
- enSiteMap.map((href) => [{ href, hrefLang: 'en' }])
+ fr: Object.fromEntries(
+ frSiteMap.map((key, i) => [key, { href: enSiteMap[i], hrefLang: 'en' }])
),
}
diff --git a/site/source/storage/persistSimulation.ts b/site/source/storage/persistSimulation.ts
index 80e05df7f..4f5780673 100644
--- a/site/source/storage/persistSimulation.ts
+++ b/site/source/storage/persistSimulation.ts
@@ -1,7 +1,6 @@
import { Action } from '@/actions/actions'
import { RootState } from '@/reducers/rootReducer'
import { PreviousSimulation } from '@/selectors/previousSimulationSelectors'
-import { isEmpty } from 'ramda'
import { Store } from 'redux'
import { debounce } from '../utils'
import * as safeLocalStorage from './safeLocalStorage'
@@ -21,7 +20,7 @@ export function setupSimulationPersistence(
if (!state.simulation?.url) {
return
}
- if (isEmpty(state.simulation?.situation)) {
+ if (Object.keys(state.simulation?.situation).length === 0) {
return
}
safeLocalStorage.setItem(
diff --git a/site/source/storage/serializeSimulation.ts b/site/source/storage/serializeSimulation.ts
index 8293dc928..82c9582df 100644
--- a/site/source/storage/serializeSimulation.ts
+++ b/site/source/storage/serializeSimulation.ts
@@ -1,6 +1,7 @@
-import { pipe } from 'ramda'
import { currentSimulationSelector } from '@/selectors/previousSimulationSelectors'
-export const serialize = pipe(currentSimulationSelector, JSON.stringify)
+export const serialize = (
+ ...args: Parameters
+) => JSON.stringify(currentSimulationSelector(...args))
export const deserialize = JSON.parse
diff --git a/site/source/utils.ts b/site/source/utils.ts
index e107bd38e..52511a6e5 100644
--- a/site/source/utils.ts
+++ b/site/source/utils.ts
@@ -77,8 +77,7 @@ export function hash(str: string): number {
}
export function omit(obj: T, key: K): Omit {
- const returnObject = { ...obj }
- delete returnObject[key]
+ const { [key]: _ignore, ...returnObject } = obj
return returnObject
}
diff --git a/site/test/unit-translations.test.js b/site/test/unit-translations.test.js
index 66b135247..3a55b5a47 100644
--- a/site/test/unit-translations.test.js
+++ b/site/test/unit-translations.test.js
@@ -1,22 +1,23 @@
import { it, expect, describe } from 'vitest'
import { parsePublicodes } from 'publicodes'
-import { uniq } from 'ramda'
import rawRules from 'modele-social'
import unitsTranslations from '../source/locales/units.yaml'
describe('Tests units', function () {
it('use unit that exists in publicodes', function () {
const { parsedRules } = parsePublicodes(rawRules)
- const units = uniq(
- Object.keys(parsedRules).reduce(
- (prev, name) => [
- ...prev,
- ...(parsedRules[name].unit?.numerators ?? []),
- ...(parsedRules[name].unit?.denumerators ?? []),
- ],
- []
- )
- )
+ const units = [
+ ...new Set(
+ Object.keys(parsedRules).reduce(
+ (prev, name) => [
+ ...prev,
+ ...(parsedRules[name].unit?.numerators ?? []),
+ ...(parsedRules[name].unit?.denumerators ?? []),
+ ],
+ []
+ )
+ ),
+ ]
const blackList = ['€', '%']
const translatedKeys = Object.keys(unitsTranslations.en)
|