Skip to content

Commit ef59d35

Browse files
authored
Merge pull request #414 from PolicyEngine/feat/flow-refactor-2
Refactor flows into pathways
2 parents 93d38b5 + 2095c61 commit ef59d35

File tree

226 files changed

+12503
-20987
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

226 files changed

+12503
-20987
lines changed

app/src/Router.tsx

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
import { createBrowserRouter, Navigate, RouterProvider } from 'react-router-dom';
2-
import FlowRouter from './components/FlowRouter';
3-
import Layout from './components/Layout';
1+
import { createBrowserRouter, Navigate, Outlet, RouterProvider } from 'react-router-dom';
2+
import PathwayLayout from './components/PathwayLayout';
3+
import StandardLayout from './components/StandardLayout';
44
import StaticLayout from './components/StaticLayout';
5-
import { PolicyCreationFlow } from './flows/policyCreationFlow';
6-
import { PopulationCreationFlow } from './flows/populationCreationFlow';
7-
import { ReportCreationFlow } from './flows/reportCreationFlow';
8-
import { SimulationCreationFlow } from './flows/simulationCreationFlow';
95
import AppPage from './pages/AppPage';
106
import BlogPage from './pages/Blog.page';
117
import DashboardPage from './pages/Dashboard.page';
@@ -21,6 +17,10 @@ import SimulationsPage from './pages/Simulations.page';
2117
import SupportersPage from './pages/Supporters.page';
2218
import TeamPage from './pages/Team.page';
2319
import TermsPage from './pages/Terms.page';
20+
import PolicyPathwayWrapper from './pathways/policy/PolicyPathwayWrapper';
21+
import PopulationPathwayWrapper from './pathways/population/PopulationPathwayWrapper';
22+
import ReportPathwayWrapper from './pathways/report/ReportPathwayWrapper';
23+
import SimulationPathwayWrapper from './pathways/simulation/SimulationPathwayWrapper';
2424
import { CountryAppGuard } from './routing/guards/CountryAppGuard';
2525
import { CountryGuard } from './routing/guards/CountryGuard';
2626
import { MetadataGuard } from './routing/guards/MetadataGuard';
@@ -43,7 +43,11 @@ const router = createBrowserRouter(
4343
element: <MetadataGuard />,
4444
children: [
4545
{
46-
element: <Layout />,
46+
element: (
47+
<StandardLayout>
48+
<Outlet />
49+
</StandardLayout>
50+
),
4751
children: [
4852
{
4953
path: 'report-output/:reportId/:subpage?/:view?',
@@ -57,8 +61,13 @@ const router = createBrowserRouter(
5761
{
5862
element: <MetadataLazyLoader />,
5963
children: [
64+
// Regular routes with standard layout
6065
{
61-
element: <Layout />,
66+
element: (
67+
<StandardLayout>
68+
<Outlet />
69+
</StandardLayout>
70+
),
6271
children: [
6372
{
6473
path: 'dashboard',
@@ -69,49 +78,45 @@ const router = createBrowserRouter(
6978
path: 'reports',
7079
element: <ReportsPage />,
7180
},
72-
{
73-
path: 'reports/create',
74-
element: <FlowRouter flow={ReportCreationFlow} returnPath="reports" />,
75-
},
7681
{
7782
path: 'simulations',
7883
element: <SimulationsPage />,
7984
},
80-
{
81-
path: 'simulations/create',
82-
element: <FlowRouter flow={SimulationCreationFlow} returnPath="simulations" />,
83-
},
8485
{
8586
path: 'households',
8687
element: <PopulationsPage />,
8788
},
88-
{
89-
path: 'households/create',
90-
element: <FlowRouter flow={PopulationCreationFlow} returnPath="households" />,
91-
},
9289
{
9390
path: 'policies',
9491
element: <PoliciesPage />,
9592
},
96-
{
97-
path: 'policies/create',
98-
element: <FlowRouter flow={PolicyCreationFlow} returnPath="policies" />,
99-
},
10093
{
10194
path: 'account',
10295
element: <div>Account settings page</div>,
10396
},
10497
],
10598
},
106-
],
107-
},
108-
// Routes that don't need metadata at all (no guard)
109-
{
110-
element: <Layout />,
111-
children: [
99+
// Pathway routes that manage their own layouts
112100
{
113-
path: 'configurations',
114-
element: <div>Configurations page</div>,
101+
element: <PathwayLayout />,
102+
children: [
103+
{
104+
path: 'reports/create',
105+
element: <ReportPathwayWrapper />,
106+
},
107+
{
108+
path: 'simulations/create',
109+
element: <SimulationPathwayWrapper />,
110+
},
111+
{
112+
path: 'households/create',
113+
element: <PopulationPathwayWrapper />,
114+
},
115+
{
116+
path: 'policies/create',
117+
element: <PolicyPathwayWrapper />,
118+
},
119+
],
115120
},
116121
],
117122
},

app/src/api/geographicAssociation.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,8 @@ export class LocalStorageGeographicStore implements UserGeographicStore {
116116

117117
const populations = this.getStoredPopulations();
118118

119-
// Check for duplicates
120-
const exists = populations.some(
121-
(p) => p.userId === population.userId && p.geographyId === population.geographyId
122-
);
123-
124-
if (exists) {
125-
throw new Error('Geographic population already exists');
126-
}
127-
119+
// Allow duplicates - users can create multiple entries for the same geography
120+
// Each entry has a unique ID from the caller
128121
const updatedPopulations = [...populations, newPopulation];
129122
this.setStoredPopulations(updatedPopulations);
130123

app/src/components/FlowContainer.tsx

Lines changed: 0 additions & 128 deletions
This file was deleted.

app/src/components/FlowRouter.tsx

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)