Skip to content

Commit 8da17ca

Browse files
committed
fix: Fix naming to make clear difference between view modes
1 parent d79aacf commit 8da17ca

File tree

4 files changed

+32
-24
lines changed

4 files changed

+32
-24
lines changed

app/src/pathways/policy/PolicyPathwayWrapper.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { useNavigate } from 'react-router-dom';
1010
import StandardLayout from '@/components/StandardLayout';
1111
import { useCurrentCountry } from '@/hooks/useCurrentCountry';
1212
import { usePathwayNavigation } from '@/hooks/usePathwayNavigation';
13-
import { PolicyViewMode } from '@/types/pathwayModes/PolicyViewMode';
13+
import { StandalonePolicyViewMode } from '@/types/pathwayModes/PolicyViewMode';
1414
import { PolicyStateProps } from '@/types/pathwayState';
1515
import { createPolicyCallbacks } from '@/utils/pathwayCallbacks';
1616
import { initializePolicyState } from '@/utils/pathwayState/initializePolicyState';
@@ -20,7 +20,7 @@ import PolicyParameterSelectorView from '../report/views/policy/PolicyParameterS
2020
import PolicySubmitView from '../report/views/policy/PolicySubmitView';
2121

2222
// View modes that manage their own AppShell (don't need StandardLayout wrapper)
23-
const MODES_WITH_OWN_LAYOUT = new Set([PolicyViewMode.PARAMETER_SELECTOR]);
23+
const MODES_WITH_OWN_LAYOUT = new Set([StandalonePolicyViewMode.PARAMETER_SELECTOR]);
2424

2525
interface PolicyPathwayWrapperProps {
2626
onComplete?: () => void;
@@ -39,7 +39,7 @@ export default function PolicyPathwayWrapper({ onComplete }: PolicyPathwayWrappe
3939

4040
// ========== NAVIGATION ==========
4141
const { currentMode, navigateToMode, goBack, canGoBack } = usePathwayNavigation(
42-
PolicyViewMode.LABEL
42+
StandalonePolicyViewMode.LABEL
4343
);
4444

4545
// ========== CALLBACKS ==========
@@ -49,7 +49,7 @@ export default function PolicyPathwayWrapper({ onComplete }: PolicyPathwayWrappe
4949
(state) => state, // policySelector: return the state itself (PolicyStateProps)
5050
(_state, policy) => policy, // policyUpdater: replace entire state with new policy
5151
navigateToMode,
52-
PolicyViewMode.SUBMIT, // returnMode (not used in standalone mode)
52+
StandalonePolicyViewMode.SUBMIT, // returnMode (not used in standalone mode)
5353
(policyId: string) => {
5454
// onPolicyComplete: custom navigation for standalone pathway
5555
console.log('[PolicyPathwayWrapper] Policy created with ID:', policyId);
@@ -62,31 +62,31 @@ export default function PolicyPathwayWrapper({ onComplete }: PolicyPathwayWrappe
6262
let currentView: React.ReactElement;
6363

6464
switch (currentMode) {
65-
case PolicyViewMode.LABEL:
65+
case StandalonePolicyViewMode.LABEL:
6666
currentView = (
6767
<PolicyLabelView
6868
label={policyState.label}
6969
mode="standalone"
7070
onUpdateLabel={policyCallbacks.updateLabel}
71-
onNext={() => navigateToMode(PolicyViewMode.PARAMETER_SELECTOR)}
71+
onNext={() => navigateToMode(StandalonePolicyViewMode.PARAMETER_SELECTOR)}
7272
onBack={canGoBack ? goBack : undefined}
7373
onCancel={() => navigate(`/${countryId}/policies`)}
7474
/>
7575
);
7676
break;
7777

78-
case PolicyViewMode.PARAMETER_SELECTOR:
78+
case StandalonePolicyViewMode.PARAMETER_SELECTOR:
7979
currentView = (
8080
<PolicyParameterSelectorView
8181
policy={policyState}
8282
onPolicyUpdate={policyCallbacks.updatePolicy}
83-
onNext={() => navigateToMode(PolicyViewMode.SUBMIT)}
83+
onNext={() => navigateToMode(StandalonePolicyViewMode.SUBMIT)}
8484
onBack={canGoBack ? goBack : undefined}
8585
/>
8686
);
8787
break;
8888

89-
case PolicyViewMode.SUBMIT:
89+
case StandalonePolicyViewMode.SUBMIT:
9090
currentView = (
9191
<PolicySubmitView
9292
policy={policyState}
@@ -104,7 +104,7 @@ export default function PolicyPathwayWrapper({ onComplete }: PolicyPathwayWrappe
104104

105105
// Conditionally wrap with StandardLayout
106106
// PolicyParameterSelectorView manages its own AppShell
107-
if (MODES_WITH_OWN_LAYOUT.has(currentMode as PolicyViewMode)) {
107+
if (MODES_WITH_OWN_LAYOUT.has(currentMode as StandalonePolicyViewMode)) {
108108
return currentView;
109109
}
110110

app/src/pathways/population/PopulationPathwayWrapper.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { useCurrentCountry } from '@/hooks/useCurrentCountry';
1313
import { usePathwayNavigation } from '@/hooks/usePathwayNavigation';
1414
import { RootState } from '@/store';
1515
import { Household } from '@/types/ingredients/Household';
16-
import { PopulationViewMode } from '@/types/pathwayModes/PopulationViewMode';
16+
import { StandalonePopulationViewMode } from '@/types/pathwayModes/PopulationViewMode';
1717
import { PopulationStateProps } from '@/types/pathwayState';
1818
import { createPopulationCallbacks } from '@/utils/pathwayCallbacks';
1919
import { initializePopulationState } from '@/utils/pathwayState/initializePopulationState';
@@ -43,7 +43,7 @@ export default function PopulationPathwayWrapper({ onComplete }: PopulationPathw
4343

4444
// ========== NAVIGATION ==========
4545
const { currentMode, navigateToMode, goBack, canGoBack } = usePathwayNavigation(
46-
PopulationViewMode.SCOPE
46+
StandalonePopulationViewMode.SCOPE
4747
);
4848

4949
// ========== CALLBACKS ==========
@@ -53,8 +53,8 @@ export default function PopulationPathwayWrapper({ onComplete }: PopulationPathw
5353
(state) => state, // populationSelector: return the state itself (PopulationStateProps)
5454
(_state, population) => population, // populationUpdater: replace entire state
5555
navigateToMode,
56-
PopulationViewMode.GEOGRAPHIC_CONFIRM, // returnMode (not used in standalone mode)
57-
PopulationViewMode.LABEL, // labelMode
56+
StandalonePopulationViewMode.GEOGRAPHIC_CONFIRM, // returnMode (not used in standalone mode)
57+
StandalonePopulationViewMode.LABEL, // labelMode
5858
{
5959
// Custom navigation for standalone pathway: exit to households list
6060
onHouseholdComplete: (householdId: string, _household: Household) => {
@@ -74,7 +74,7 @@ export default function PopulationPathwayWrapper({ onComplete }: PopulationPathw
7474
let currentView: React.ReactElement;
7575

7676
switch (currentMode) {
77-
case PopulationViewMode.SCOPE:
77+
case StandalonePopulationViewMode.SCOPE:
7878
currentView = (
7979
<PopulationScopeView
8080
countryId={countryId}
@@ -86,7 +86,7 @@ export default function PopulationPathwayWrapper({ onComplete }: PopulationPathw
8686
);
8787
break;
8888

89-
case PopulationViewMode.LABEL:
89+
case StandalonePopulationViewMode.LABEL:
9090
currentView = (
9191
<PopulationLabelView
9292
population={populationState}
@@ -95,17 +95,17 @@ export default function PopulationPathwayWrapper({ onComplete }: PopulationPathw
9595
onNext={() => {
9696
// Navigate based on population type
9797
if (populationState.type === 'household') {
98-
navigateToMode(PopulationViewMode.HOUSEHOLD_BUILDER);
98+
navigateToMode(StandalonePopulationViewMode.HOUSEHOLD_BUILDER);
9999
} else {
100-
navigateToMode(PopulationViewMode.GEOGRAPHIC_CONFIRM);
100+
navigateToMode(StandalonePopulationViewMode.GEOGRAPHIC_CONFIRM);
101101
}
102102
}}
103103
onBack={canGoBack ? goBack : undefined}
104104
/>
105105
);
106106
break;
107107

108-
case PopulationViewMode.HOUSEHOLD_BUILDER:
108+
case StandalonePopulationViewMode.HOUSEHOLD_BUILDER:
109109
currentView = (
110110
<HouseholdBuilderView
111111
population={populationState}
@@ -116,7 +116,7 @@ export default function PopulationPathwayWrapper({ onComplete }: PopulationPathw
116116
);
117117
break;
118118

119-
case PopulationViewMode.GEOGRAPHIC_CONFIRM:
119+
case StandalonePopulationViewMode.GEOGRAPHIC_CONFIRM:
120120
currentView = (
121121
<GeographicConfirmationView
122122
population={populationState}

app/src/types/pathwayModes/PolicyViewMode.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
/**
2-
* PolicyViewMode - Enum for policy creation pathway view states
2+
* StandalonePolicyViewMode - Enum for standalone policy creation pathway view states
3+
*
4+
* This is used by the standalone PolicyPathwayWrapper.
5+
* For policy modes used within composite pathways (Report, Simulation),
6+
* see PolicyViewMode in SharedViewModes.ts
37
*
48
* Maps to the frames in PolicyCreationFlow:
59
* - LABEL: PolicyCreationFrame (enter policy name)
610
* - PARAMETER_SELECTOR: PolicyParameterSelectorFrame (select and configure parameters)
711
* - SUBMIT: PolicySubmitFrame (review and submit policy)
812
*/
9-
export enum PolicyViewMode {
13+
export enum StandalonePolicyViewMode {
1014
LABEL = 'LABEL',
1115
PARAMETER_SELECTOR = 'PARAMETER_SELECTOR',
1216
SUBMIT = 'SUBMIT',

app/src/types/pathwayModes/PopulationViewMode.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
/**
2-
* PopulationViewMode - Enum for population creation pathway view states
2+
* StandalonePopulationViewMode - Enum for standalone population creation pathway view states
3+
*
4+
* This is used by the standalone PopulationPathwayWrapper.
5+
* For population modes used within composite pathways (Report, Simulation),
6+
* see PopulationViewMode in SharedViewModes.ts
37
*
48
* Maps to the frames in PopulationCreationFlow:
59
* - SCOPE: SelectGeographicScopeFrame (choose household vs geographic scope)
610
* - LABEL: SetPopulationLabelFrame (enter population name)
711
* - HOUSEHOLD_BUILDER: HouseholdBuilderFrame (configure household members)
812
* - GEOGRAPHIC_CONFIRM: GeographicConfirmationFrame (confirm geographic population)
913
*/
10-
export enum PopulationViewMode {
14+
export enum StandalonePopulationViewMode {
1115
SCOPE = 'SCOPE',
1216
LABEL = 'LABEL',
1317
HOUSEHOLD_BUILDER = 'HOUSEHOLD_BUILDER',

0 commit comments

Comments
 (0)