🔥 Supprime reselect
parent
df93f40da3
commit
560513a6e7
|
@ -87,7 +87,6 @@
|
|||
"recharts": "^2.1.8",
|
||||
"reduce-reducers": "^1.0.4",
|
||||
"redux": "^4.0.4",
|
||||
"reselect": "^4.0.0",
|
||||
"styled-components": "^5.3.1",
|
||||
"whatwg-fetch": "^3.0.0",
|
||||
"yaml": "^1.9.2"
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { DottedName } from 'modele-social'
|
||||
import { RootState, SimulationConfig } from 'Reducers/rootReducer'
|
||||
import { createSelector } from 'reselect'
|
||||
|
||||
export const configSelector = (state: RootState): Partial<SimulationConfig> =>
|
||||
state.simulation?.config ?? {}
|
||||
|
||||
export const objectifsSelector = createSelector([configSelector], (config) => {
|
||||
export const objectifsSelector = (state: RootState) => {
|
||||
const config = configSelector(state)
|
||||
const primaryObjectifs = (config.objectifs ?? ([] as any))
|
||||
.map((obj: DottedName | { objectifs: Array<DottedName> }) =>
|
||||
typeof obj === 'string' ? [obj] : obj.objectifs
|
||||
|
@ -14,7 +14,7 @@ export const objectifsSelector = createSelector([configSelector], (config) => {
|
|||
|
||||
const objectifs = [...primaryObjectifs, ...(config['objectifs cachés'] ?? [])]
|
||||
return objectifs
|
||||
})
|
||||
}
|
||||
|
||||
const emptySituation: Partial<
|
||||
Record<DottedName, string | number | Record<string, unknown>>
|
||||
|
@ -29,18 +29,18 @@ export const initialSituationSelector = (state: RootState) =>
|
|||
export const configSituationSelector = (state: RootState) =>
|
||||
configSelector(state).situation ?? emptySituation
|
||||
|
||||
export const firstStepCompletedSelector = createSelector(
|
||||
[situationSelector, configSituationSelector, initialSituationSelector],
|
||||
(situation, baseSituation, initialSituation) => {
|
||||
return (
|
||||
Object.keys(situation).filter(
|
||||
(dottedName) =>
|
||||
!Object.keys(baseSituation).includes(dottedName) &&
|
||||
!Object.keys(initialSituation).includes(dottedName)
|
||||
).length > 0
|
||||
)
|
||||
}
|
||||
)
|
||||
export const firstStepCompletedSelector = (state: RootState) => {
|
||||
const situation = situationSelector(state)
|
||||
const baseSituation = configSituationSelector(state)
|
||||
const initialSituation = initialSituationSelector(state)
|
||||
return (
|
||||
Object.keys(situation).filter(
|
||||
(dottedName) =>
|
||||
!Object.keys(baseSituation).includes(dottedName) &&
|
||||
!Object.keys(initialSituation).includes(dottedName)
|
||||
).length > 0
|
||||
)
|
||||
}
|
||||
|
||||
export const targetUnitSelector = (state: RootState) =>
|
||||
state.simulation?.targetUnit ?? '€/mois'
|
||||
|
|
|
@ -5600,11 +5600,6 @@ requires-port@^1.0.0:
|
|||
resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff"
|
||||
integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=
|
||||
|
||||
reselect@^4.0.0:
|
||||
version "4.1.5"
|
||||
resolved "https://registry.yarnpkg.com/reselect/-/reselect-4.1.5.tgz#852c361247198da6756d07d9296c2b51eddb79f6"
|
||||
integrity sha512-uVdlz8J7OO+ASpBYoz1Zypgx0KasCY20H+N8JD13oUMtPvSHQuscrHop4KbXrbsBcdB9Ds7lVK7eRkBIfO43vQ==
|
||||
|
||||
resize-observer-polyfill@^1.5.1:
|
||||
version "1.5.1"
|
||||
resolved "https://registry.yarnpkg.com/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz#0e9020dd3d21024458d4ebd27e23e40269810464"
|
||||
|
|
Loading…
Reference in New Issue