Skip to content

Commit e371c6c

Browse files
committed
chore: Lint
1 parent cbedd80 commit e371c6c

File tree

75 files changed

+995
-818
lines changed

Some content is hidden

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

75 files changed

+995
-818
lines changed

app/src/Router.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ import SimulationsPage from './pages/Simulations.page';
1515
import SupportersPage from './pages/Supporters.page';
1616
import TeamPage from './pages/Team.page';
1717
import TermsPage from './pages/Terms.page';
18+
import PolicyPathwayWrapper from './pathways/policy/PolicyPathwayWrapper';
19+
import PopulationPathwayWrapper from './pathways/population/PopulationPathwayWrapper';
20+
import ReportPathwayWrapper from './pathways/report/ReportPathwayWrapper';
21+
import SimulationPathwayWrapper from './pathways/simulation/SimulationPathwayWrapper';
1822
import { CountryGuard } from './routing/guards/CountryGuard';
1923
import { MetadataGuard } from './routing/guards/MetadataGuard';
2024
import { MetadataLazyLoader } from './routing/guards/MetadataLazyLoader';
2125
import { USOnlyGuard } from './routing/guards/USOnlyGuard';
2226
import { RedirectToCountry } from './routing/RedirectToCountry';
2327
import { RedirectToLegacy } from './routing/RedirectToLegacy';
24-
import ReportPathwayWrapper from './pathways/report/ReportPathwayWrapper';
25-
import SimulationPathwayWrapper from './pathways/simulation/SimulationPathwayWrapper';
26-
import PopulationPathwayWrapper from './pathways/population/PopulationPathwayWrapper';
27-
import PolicyPathwayWrapper from './pathways/policy/PolicyPathwayWrapper';
2828

2929
const router = createBrowserRouter(
3030
[

app/src/components/common/MultiButtonFooter.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Box, Button, Group, SimpleGrid } from '@mantine/core';
21
import { IconChevronLeft, IconChevronRight } from '@tabler/icons-react';
2+
import { Box, Button, Group, SimpleGrid } from '@mantine/core';
33
import PaginationControls, { PaginationConfig } from './PaginationControls';
44

55
export interface ButtonConfig {
@@ -42,10 +42,7 @@ export default function MultiButtonFooter(props: MultiButtonFooterProps) {
4242
{/* Left side: Cancel button */}
4343
<Box style={{ display: 'flex', justifyContent: 'flex-start' }}>
4444
{cancelAction && (
45-
<Button
46-
variant="outline"
47-
onClick={cancelAction.onClick}
48-
>
45+
<Button variant="outline" onClick={cancelAction.onClick}>
4946
{cancelAction.label}
5047
</Button>
5148
)}

app/src/components/common/PaginationControls.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { ActionIcon, Group, Text } from '@mantine/core';
21
import { IconChevronLeft, IconChevronRight } from '@tabler/icons-react';
2+
import { ActionIcon, Group, Text } from '@mantine/core';
33

44
export interface PaginationConfig {
55
currentPage: number;
@@ -33,7 +33,9 @@ export default function PaginationControls({ pagination }: PaginationControlsPro
3333
</Text>
3434
<ActionIcon
3535
variant="default"
36-
onClick={() => pagination.onPageChange(Math.min(pagination.totalPages, pagination.currentPage + 1))}
36+
onClick={() =>
37+
pagination.onPageChange(Math.min(pagination.totalPages, pagination.currentPage + 1))
38+
}
3739
disabled={pagination.currentPage === pagination.totalPages}
3840
aria-label="Next page"
3941
>

app/src/components/common/PathwayView.tsx

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -113,27 +113,35 @@ export default function PathwayView({
113113
if (useNewLayout) {
114114
return {
115115
buttons: [] as ButtonConfig[],
116-
cancelAction: cancelAction?.onClick ? {
117-
label: cancelAction.label || 'Cancel',
118-
onClick: cancelAction.onClick,
119-
} : undefined,
120-
backAction: backAction ? {
121-
label: backAction.label || 'Back',
122-
onClick: backAction.onClick,
123-
} : undefined,
124-
primaryAction: primaryAction ? {
125-
label: primaryAction.label,
126-
onClick: primaryAction.onClick,
127-
isLoading: primaryAction.isLoading,
128-
isDisabled: primaryAction.isDisabled,
129-
} : undefined,
130-
pagination: shouldShowPaginationInFooter ? {
131-
currentPage,
132-
totalPages,
133-
totalItems,
134-
itemsPerPage,
135-
onPageChange: setCurrentPage,
136-
} : undefined,
116+
cancelAction: cancelAction?.onClick
117+
? {
118+
label: cancelAction.label || 'Cancel',
119+
onClick: cancelAction.onClick,
120+
}
121+
: undefined,
122+
backAction: backAction
123+
? {
124+
label: backAction.label || 'Back',
125+
onClick: backAction.onClick,
126+
}
127+
: undefined,
128+
primaryAction: primaryAction
129+
? {
130+
label: primaryAction.label,
131+
onClick: primaryAction.onClick,
132+
isLoading: primaryAction.isLoading,
133+
isDisabled: primaryAction.isDisabled,
134+
}
135+
: undefined,
136+
pagination: shouldShowPaginationInFooter
137+
? {
138+
currentPage,
139+
totalPages,
140+
totalItems,
141+
itemsPerPage,
142+
onPageChange: setCurrentPage,
143+
}
144+
: undefined,
137145
};
138146
}
139147

@@ -158,7 +166,8 @@ export default function PathwayView({
158166
};
159167

160168
const footerProps = getFooterProps();
161-
const hasFooter = footerProps.buttons?.length > 0 ||
169+
const hasFooter =
170+
footerProps.buttons?.length > 0 ||
162171
footerProps.cancelAction ||
163172
footerProps.backAction ||
164173
footerProps.primaryAction;

app/src/hooks/usePathwayNavigation.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@ export function usePathwayNavigation<TMode>(initialMode: TMode) {
1111
const [currentMode, setCurrentMode] = useState<TMode>(initialMode);
1212
const [history, setHistory] = useState<TMode[]>([]);
1313

14-
const navigateToMode = useCallback((mode: TMode) => {
15-
console.log('[usePathwayNavigation] Navigating to mode:', mode);
16-
setHistory((prev) => [...prev, currentMode]);
17-
setCurrentMode(mode);
18-
}, [currentMode]);
14+
const navigateToMode = useCallback(
15+
(mode: TMode) => {
16+
console.log('[usePathwayNavigation] Navigating to mode:', mode);
17+
setHistory((prev) => [...prev, currentMode]);
18+
setCurrentMode(mode);
19+
},
20+
[currentMode]
21+
);
1922

2023
const goBack = useCallback(() => {
2124
if (history.length > 0) {

app/src/pathways/policy/PolicyPathwayWrapper.tsx

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@
77

88
import { useCallback, useState } from 'react';
99
import { useNavigate } from 'react-router-dom';
10-
import { PolicyStateProps } from '@/types/pathwayState';
11-
import { PolicyViewMode } from '@/types/pathwayModes/PolicyViewMode';
12-
import { initializePolicyState } from '@/utils/pathwayState/initializePolicyState';
1310
import StandardLayout from '@/components/StandardLayout';
14-
import { usePathwayNavigation } from '@/hooks/usePathwayNavigation';
1511
import { useCurrentCountry } from '@/hooks/useCurrentCountry';
16-
12+
import { usePathwayNavigation } from '@/hooks/usePathwayNavigation';
13+
import { PolicyViewMode } from '@/types/pathwayModes/PolicyViewMode';
14+
import { PolicyStateProps } from '@/types/pathwayState';
15+
import { initializePolicyState } from '@/utils/pathwayState/initializePolicyState';
1716
// Policy views (reusing from report pathway)
1817
import PolicyLabelView from '../report/views/policy/PolicyLabelView';
1918
import PolicyParameterSelectorView from '../report/views/policy/PolicyParameterSelectorView';
@@ -38,7 +37,9 @@ export default function PolicyPathwayWrapper({ onComplete }: PolicyPathwayWrappe
3837
});
3938

4039
// ========== NAVIGATION ==========
41-
const { currentMode, navigateToMode, goBack, canGoBack } = usePathwayNavigation(PolicyViewMode.LABEL);
40+
const { currentMode, navigateToMode, goBack, canGoBack } = usePathwayNavigation(
41+
PolicyViewMode.LABEL
42+
);
4243

4344
// ========== CALLBACKS ==========
4445
const updateLabel = useCallback((label: string) => {
@@ -49,21 +50,24 @@ export default function PolicyPathwayWrapper({ onComplete }: PolicyPathwayWrappe
4950
setPolicyState(updatedPolicy);
5051
}, []);
5152

52-
const handleSubmitSuccess = useCallback((policyId: string) => {
53-
console.log('[PolicyPathwayWrapper] Policy created with ID:', policyId);
53+
const handleSubmitSuccess = useCallback(
54+
(policyId: string) => {
55+
console.log('[PolicyPathwayWrapper] Policy created with ID:', policyId);
5456

55-
setPolicyState((prev) => ({
56-
...prev,
57-
id: policyId,
58-
}));
57+
setPolicyState((prev) => ({
58+
...prev,
59+
id: policyId,
60+
}));
5961

60-
// Navigate back to policies list page
61-
navigate(`/${countryId}/policies`);
62+
// Navigate back to policies list page
63+
navigate(`/${countryId}/policies`);
6264

63-
if (onComplete) {
64-
onComplete();
65-
}
66-
}, [navigate, countryId, onComplete]);
65+
if (onComplete) {
66+
onComplete();
67+
}
68+
},
69+
[navigate, countryId, onComplete]
70+
);
6771

6872
// ========== VIEW RENDERING ==========
6973
let currentView: React.ReactElement;

app/src/pathways/population/PopulationPathwayWrapper.tsx

Lines changed: 64 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,22 @@
66
*/
77

88
import { useCallback, useState } from 'react';
9-
import { useNavigate } from 'react-router-dom';
109
import { useSelector } from 'react-redux';
11-
import { PopulationStateProps } from '@/types/pathwayState';
12-
import { PopulationViewMode } from '@/types/pathwayModes/PopulationViewMode';
13-
import { initializePopulationState } from '@/utils/pathwayState/initializePopulationState';
14-
import { RootState } from '@/store';
10+
import { useNavigate } from 'react-router-dom';
1511
import StandardLayout from '@/components/StandardLayout';
16-
import { usePathwayNavigation } from '@/hooks/usePathwayNavigation';
1712
import { useCurrentCountry } from '@/hooks/useCurrentCountry';
13+
import { usePathwayNavigation } from '@/hooks/usePathwayNavigation';
14+
import { RootState } from '@/store';
1815
import { Geography } from '@/types/ingredients/Geography';
1916
import { Household } from '@/types/ingredients/Household';
20-
17+
import { PopulationViewMode } from '@/types/pathwayModes/PopulationViewMode';
18+
import { PopulationStateProps } from '@/types/pathwayState';
19+
import { initializePopulationState } from '@/utils/pathwayState/initializePopulationState';
20+
import GeographicConfirmationView from '../report/views/population/GeographicConfirmationView';
21+
import HouseholdBuilderView from '../report/views/population/HouseholdBuilderView';
22+
import PopulationLabelView from '../report/views/population/PopulationLabelView';
2123
// Population views (reusing from report pathway)
2224
import PopulationScopeView from '../report/views/population/PopulationScopeView';
23-
import PopulationLabelView from '../report/views/population/PopulationLabelView';
24-
import HouseholdBuilderView from '../report/views/population/HouseholdBuilderView';
25-
import GeographicConfirmationView from '../report/views/population/GeographicConfirmationView';
2625

2726
interface PopulationPathwayWrapperProps {
2827
onComplete?: () => void;
@@ -43,57 +42,68 @@ export default function PopulationPathwayWrapper({ onComplete }: PopulationPathw
4342
const metadata = useSelector((state: RootState) => state.metadata);
4443

4544
// ========== NAVIGATION ==========
46-
const { currentMode, navigateToMode, goBack, canGoBack } = usePathwayNavigation(PopulationViewMode.SCOPE);
45+
const { currentMode, navigateToMode, goBack, canGoBack } = usePathwayNavigation(
46+
PopulationViewMode.SCOPE
47+
);
4748

4849
// ========== CALLBACKS ==========
4950
const updateLabel = useCallback((label: string) => {
5051
setPopulationState((prev) => ({ ...prev, label }));
5152
}, []);
5253

53-
const handleScopeSelected = useCallback((geography: Geography | null, _scopeType: string) => {
54-
setPopulationState((prev) => ({
55-
...prev,
56-
geography: geography || null,
57-
type: geography ? 'geography' : 'household',
58-
}));
59-
navigateToMode(PopulationViewMode.LABEL);
60-
}, [navigateToMode]);
61-
62-
const handleHouseholdSubmitSuccess = useCallback((householdId: string, household: Household) => {
63-
console.log('[PopulationPathwayWrapper] Household created with ID:', householdId);
64-
65-
setPopulationState((prev) => ({
66-
...prev,
67-
household: { ...household, id: householdId },
68-
}));
69-
70-
// Navigate back to populations list page
71-
navigate(`/${countryId}/households`);
72-
73-
if (onComplete) {
74-
onComplete();
75-
}
76-
}, [navigate, countryId, onComplete]);
77-
78-
const handleGeographicSubmitSuccess = useCallback((geographyId: string, label: string) => {
79-
console.log('[PopulationPathwayWrapper] Geographic population created with ID:', geographyId);
80-
81-
setPopulationState((prev) => {
82-
const updatedPopulation = { ...prev };
83-
if (updatedPopulation.geography) {
84-
updatedPopulation.geography.id = geographyId;
54+
const handleScopeSelected = useCallback(
55+
(geography: Geography | null, _scopeType: string) => {
56+
setPopulationState((prev) => ({
57+
...prev,
58+
geography: geography || null,
59+
type: geography ? 'geography' : 'household',
60+
}));
61+
navigateToMode(PopulationViewMode.LABEL);
62+
},
63+
[navigateToMode]
64+
);
65+
66+
const handleHouseholdSubmitSuccess = useCallback(
67+
(householdId: string, household: Household) => {
68+
console.log('[PopulationPathwayWrapper] Household created with ID:', householdId);
69+
70+
setPopulationState((prev) => ({
71+
...prev,
72+
household: { ...household, id: householdId },
73+
}));
74+
75+
// Navigate back to populations list page
76+
navigate(`/${countryId}/households`);
77+
78+
if (onComplete) {
79+
onComplete();
8580
}
86-
updatedPopulation.label = label;
87-
return updatedPopulation;
88-
});
89-
90-
// Navigate back to populations list page
91-
navigate(`/${countryId}/households`);
92-
93-
if (onComplete) {
94-
onComplete();
95-
}
96-
}, [navigate, countryId, onComplete]);
81+
},
82+
[navigate, countryId, onComplete]
83+
);
84+
85+
const handleGeographicSubmitSuccess = useCallback(
86+
(geographyId: string, label: string) => {
87+
console.log('[PopulationPathwayWrapper] Geographic population created with ID:', geographyId);
88+
89+
setPopulationState((prev) => {
90+
const updatedPopulation = { ...prev };
91+
if (updatedPopulation.geography) {
92+
updatedPopulation.geography.id = geographyId;
93+
}
94+
updatedPopulation.label = label;
95+
return updatedPopulation;
96+
});
97+
98+
// Navigate back to populations list page
99+
navigate(`/${countryId}/households`);
100+
101+
if (onComplete) {
102+
onComplete();
103+
}
104+
},
105+
[navigate, countryId, onComplete]
106+
);
97107

98108
// ========== VIEW RENDERING ==========
99109
let currentView: React.ReactElement;

0 commit comments

Comments
 (0)