Skip to content

Commit

Permalink
refacto: projectCreation reducer split with urbanProject and renewabl…
Browse files Browse the repository at this point in the history
…eEnergyProject
  • Loading branch information
cdhenin committed Oct 29, 2024
1 parent 5caaad9 commit a84c762
Show file tree
Hide file tree
Showing 94 changed files with 1,805 additions and 1,680 deletions.
14 changes: 4 additions & 10 deletions apps/web/src/app/application/store.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { combineReducers, configureStore, Reducer } from "@reduxjs/toolkit";

import projectCreation from "@/features/create-project/application/createProject.reducer";
import { SiteMunicipalityDataGateway as CreateProjectMunicipalityDataGateway } from "@/features/create-project/application/projectSiteLocalAuthorities.actions";
import projectSiteLocalAuthorities from "@/features/create-project/application/projectSiteLocalAuthorities.reducer";
import { PhotovoltaicPerformanceGateway } from "@/features/create-project/application/pvExpectedPerformanceStorage.actions";
import projectPvExpectedPerformancesStorage from "@/features/create-project/application/pvExpectedPerformanceStorage.reducer";
import { SaveReconversionProjectGateway } from "@/features/create-project/application/saveReconversionProject.action";
import projectSoilsCarbonStorage from "@/features/create-project/application/soilsCarbonStorage.reducer";
import { SiteMunicipalityDataGateway as CreateProjectMunicipalityDataGateway } from "@/features/create-project/application/getSiteLocalAuthorities.action";
import { PhotovoltaicPerformanceGateway } from "@/features/create-project/application/renewable-energy/getPhotovoltaicExpectedPerformance.action";
import { SaveReconversionProjectGateway } from "@/features/create-project/application/renewable-energy/saveReconversionProject.action";
import { SaveExpressReconversionProjectGateway } from "@/features/create-project/application/urban-project/urbanProject.actions";
import siteCreation from "@/features/create-site/application/createSite.reducer";
import { SiteMunicipalityDataGateway as CreateSiteMunicipalityDataGateway } from "@/features/create-site/application/siteMunicipalityData.actions";
Expand All @@ -24,7 +21,7 @@ import { CurrentUserGateway } from "@/features/users/application/initCurrentUser
import currentUser from "@/features/users/application/user.reducer";

import { GetSitesByIdGateway } from "../../features/create-project/application/createProject.actions";
import { SoilsCarbonStorageGateway as ProjectSoilsCarbonStorageGateway } from "../../features/create-project/application/soilsCarbonStorage.actions";
import { SoilsCarbonStorageGateway as ProjectSoilsCarbonStorageGateway } from "../../features/create-project/application/soilsCarbonStorage.action";
import { CreateSiteGateway } from "../../features/create-site/application/createSite.actions";
import { SoilsCarbonStorageGateway as SiteSoilsCarbonStorageGateway } from "../../features/create-site/application/siteSoilsCarbonStorage.actions";
import { ReconversionProjectsListGateway } from "../../features/projects/application/projectsList.actions";
Expand Down Expand Up @@ -54,15 +51,12 @@ const rootReducer = combineReducers({
siteCreation,
siteFeatures,
projectCreation,
projectPvExpectedPerformancesStorage,
siteCarbonStorage,
reconversionProjectsList,
currentUser,
projectImpacts,
projectFeatures: projectFeaturesReducer,
projectSoilsCarbonStorage,
siteMunicipalityData,
projectSiteLocalAuthorities,
});

export const createStore = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { createStore, RootState } from "@/app/application/store";
import { AdministrativeDivisionMock } from "@/shared/infrastructure/administrative-division-service/administrativeDivisionMock";
import { getTestAppDependencies } from "@/test/testAppDependencies";

import { Address } from "../domain/project.types";
import { getInitialState as getInitialProjectCreationState } from "./createProject.reducer";
import { fetchSiteLocalAuthorities } from "./projectSiteLocalAuthorities.actions";
import { Address } from "../../domain/project.types";
import { getInitialState as getInitialProjectCreationState } from "../createProject.reducer";
import { fetchSiteLocalAuthorities } from "../getSiteLocalAuthorities.action";
import { relatedSiteData } from "./siteData.mock";

const API_MOCKED_RESULT = {
Expand Down Expand Up @@ -89,9 +89,8 @@ describe("Site Local Authorities reducer", () => {
await store.dispatch(fetchSiteLocalAuthorities());

const state = store.getState();
expect(state.projectSiteLocalAuthorities).toEqual({
expect(state.projectCreation.siteRelatedLocalAuthorities).toEqual({
loadingState: "error",
localAuthorities: undefined,
});
});

Expand Down Expand Up @@ -127,9 +126,9 @@ describe("Site Local Authorities reducer", () => {
await store.dispatch(fetchSiteLocalAuthorities());

const state = store.getState();
expect(state.projectSiteLocalAuthorities).toEqual({
expect(state.projectCreation.siteRelatedLocalAuthorities).toEqual({
loadingState: "success",
localAuthorities: API_MOCKED_RESULT["75110"].localAuthorities,
...API_MOCKED_RESULT["75110"].localAuthorities,
});
});

Expand All @@ -152,9 +151,9 @@ describe("Site Local Authorities reducer", () => {
await store.dispatch(fetchSiteLocalAuthorities());

const state = store.getState();
expect(state.projectSiteLocalAuthorities).toEqual({
expect(state.projectCreation.siteRelatedLocalAuthorities).toEqual({
loadingState: "success",
localAuthorities: API_MOCKED_RESULT["38185"].localAuthorities,
...API_MOCKED_RESULT["38185"].localAuthorities,
});
});

Expand All @@ -175,9 +174,8 @@ describe("Site Local Authorities reducer", () => {
await store.dispatch(fetchSiteLocalAuthorities());

const state = store.getState();
expect(state.projectSiteLocalAuthorities).toEqual({
expect(state.projectCreation.siteRelatedLocalAuthorities).toEqual({
loadingState: "error",
localAuthorities: undefined,
});
});
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ProjectSite } from "../domain/project.types";
import { ProjectSite } from "../../domain/project.types";

export const relatedSiteData = {
id: "28b53918-a6f6-43f2-9554-7b5434428f8b",
Expand Down
Loading

0 comments on commit a84c762

Please sign in to comment.