-
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.
chore(web): reorganize project creation code in webapp
- Loading branch information
1 parent
992c196
commit bce3a90
Showing
176 changed files
with
422 additions
and
320 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
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
2 changes: 1 addition & 1 deletion
2
...ct/application/__tests__/siteData.mock.ts → ...e-project/core/__tests__/siteData.mock.ts
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
2 changes: 1 addition & 1 deletion
2
...ject/application/createProject.actions.ts → ...ate-project/core/createProject.actions.ts
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
2 changes: 1 addition & 1 deletion
2
...able-energy/__tests__/projectData.mock.ts → ...able-energy/__tests__/projectData.mock.ts
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
File renamed without changes.
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
2 changes: 1 addition & 1 deletion
2
...-energy/saveReconversionProject.action.ts → ...actions/saveReconversionProject.action.ts
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
6 changes: 3 additions & 3 deletions
6
...able-energy/soilsCarbonStorage.actions.ts → ...rgy/actions/soilsCarbonStorage.actions.ts
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
File renamed without changes.
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
4 changes: 2 additions & 2 deletions
4
...rgy/photovoltaicPowerStation.selectors.ts → ...ors/photovoltaicPowerStation.selectors.ts
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
4 changes: 2 additions & 2 deletions
4
...enewable-energy/stakeholders.selectors.ts → ...nergy/selectors/stakeholders.selectors.ts
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
104 changes: 104 additions & 0 deletions
104
apps/web/src/features/create-project/core/renewable-energy/soilsTransformation.selectors.ts
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,104 @@ | ||
import { createSelector } from "@reduxjs/toolkit"; | ||
import { SoilsDistribution, SoilType, sumSoilsSurfaceAreasWhere } from "shared"; | ||
|
||
import { typedObjectKeys } from "@/shared/services/object-keys/objectKeys"; | ||
|
||
import { selectSiteData, selectSiteSoilsDistribution } from "../createProject.selectors"; | ||
import { selectPhotovoltaicPanelsSurfaceArea } from "./selectors/photovoltaicPowerStation.selectors"; | ||
import { | ||
selectCreationData, | ||
selectProjectSoilsDistribution, | ||
} from "./selectors/renewableEnergy.selector"; | ||
import { | ||
getNonSuitableSoilsForPhotovoltaicPanels, | ||
getSuitableSoilsForTransformation, | ||
getSuitableSurfaceAreaForPhotovoltaicPanels, | ||
isBiodiversityAndClimateSensibleSoil, | ||
willTransformationNoticeablyImpactBiodiversityAndClimate, | ||
getBioversityAndClimateSensitiveSoilsSurfaceAreaDestroyed, | ||
} from "./soilsTransformation"; | ||
|
||
export const selectSuitableSurfaceAreaForPhotovoltaicPanels = createSelector( | ||
selectSiteData, | ||
(state): number => { | ||
return getSuitableSurfaceAreaForPhotovoltaicPanels(state?.soilsDistribution ?? {}); | ||
}, | ||
); | ||
|
||
export const selectNonSuitableSoilsForPhototovoltaicPanels = createSelector( | ||
selectSiteData, | ||
(state): SoilsDistribution => { | ||
return state ? getNonSuitableSoilsForPhotovoltaicPanels(state.soilsDistribution) : {}; | ||
}, | ||
); | ||
|
||
export const selectMissingSuitableSurfaceAreaForPhotovoltaicPanels = createSelector( | ||
[selectPhotovoltaicPanelsSurfaceArea, selectSuitableSurfaceAreaForPhotovoltaicPanels], | ||
(neededSurfaceArea, suitableSurfaceArea): number => { | ||
return neededSurfaceArea - suitableSurfaceArea; | ||
}, | ||
); | ||
|
||
const selectNonSuitableSoilsSelected = createSelector( | ||
selectCreationData, | ||
(creationData): SoilType[] => creationData.nonSuitableSoilsToTransform ?? [], | ||
); | ||
|
||
export const selectNonSuitableSoilsForPhototovoltaicPanelsToTransform = createSelector( | ||
[selectNonSuitableSoilsForPhototovoltaicPanels, selectNonSuitableSoilsSelected], | ||
(nonSuitableSoils, selectedNonSuitableSoilsToTransform): SoilsDistribution => { | ||
return typedObjectKeys(nonSuitableSoils) | ||
.filter((soilType) => selectedNonSuitableSoilsToTransform.includes(soilType)) | ||
.reduce((soilsDistribution, soilType) => { | ||
return { ...soilsDistribution, [soilType]: nonSuitableSoils[soilType] }; | ||
}, {}); | ||
}, | ||
); | ||
|
||
export const selectFutureSoils = createSelector(selectCreationData, (creationData): SoilType[] => { | ||
return creationData.futureSoilsSelection ?? []; | ||
}); | ||
|
||
export const selectBiodiversityAndClimateSensibleSoilsSurfaceAreaDestroyed = createSelector( | ||
[selectSiteSoilsDistribution, selectProjectSoilsDistribution], | ||
(siteSoilsDistribution, projectSoilsDistribution): number => { | ||
return getBioversityAndClimateSensitiveSoilsSurfaceAreaDestroyed( | ||
siteSoilsDistribution, | ||
projectSoilsDistribution, | ||
); | ||
}, | ||
); | ||
|
||
export const selectWillSoilsTransformationHaveNegativeImpactOnBiodiversityAndClimate = | ||
createSelector( | ||
[selectSiteSoilsDistribution, selectProjectSoilsDistribution], | ||
(siteSoilsDistribution, projectSoilsDistribution): boolean => { | ||
return willTransformationNoticeablyImpactBiodiversityAndClimate( | ||
siteSoilsDistribution, | ||
projectSoilsDistribution, | ||
); | ||
}, | ||
); | ||
|
||
export const selectFutureBiodiversityAndClimateSensibleSoilsSurfaceArea = createSelector( | ||
selectProjectSoilsDistribution, | ||
(futureSoilsDistribution): number => { | ||
return sumSoilsSurfaceAreasWhere(futureSoilsDistribution, isBiodiversityAndClimateSensibleSoil); | ||
}, | ||
); | ||
|
||
export const selectBaseSoilsDistributionForTransformation = createSelector( | ||
selectCreationData, | ||
selectSiteData, | ||
(creationData, siteData): SoilsDistribution => { | ||
return creationData.baseSoilsDistributionForTransformation ?? siteData?.soilsDistribution ?? {}; | ||
}, | ||
); | ||
|
||
export const selectTransformableSoils = createSelector( | ||
selectBaseSoilsDistributionForTransformation, | ||
(baseSoilsDistributionForTransformation): SoilType[] => { | ||
const currentSoils = typedObjectKeys(baseSoilsDistributionForTransformation); | ||
return getSuitableSoilsForTransformation(currentSoils); | ||
}, | ||
); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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.