Skip to content

Commit cb89ef4

Browse files
authored
Merge pull request #69 from wulfland/fix-meso-navigation
Enhance MesocycleDashboard navigation by adding onNavigate prop for p…
2 parents 6bb8827 + 0932eec commit cb89ef4

3 files changed

Lines changed: 21 additions & 11 deletions

File tree

src/App.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,9 @@ function App() {
349349
)}
350350
</div>
351351

352-
{currentPage === 'mesocycles' && <MesocycleDashboard />}
352+
{currentPage === 'mesocycles' && (
353+
<MesocycleDashboard onNavigate={setCurrentPage} />
354+
)}
353355

354356
{currentPage === 'workout' && (
355357
<WorkoutSession onNavigate={setCurrentPage} />

src/components/mesocycles/MesocycleDashboard.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,19 @@ import {
1010
updateMesocycle,
1111
} from '../../hooks/useDatabase';
1212
import type { Mesocycle } from '../../types/models';
13+
import type { Page } from '../../layouts/Layout';
1314
import MesocycleCard from './MesocycleCard';
1415
import MesocycleForm from './MesocycleForm';
1516
import SplitProgressTracker from './SplitProgressTracker';
1617
import './MesocycleDashboard.css';
1718

18-
export default function MesocycleDashboard() {
19+
interface MesocycleDashboardProps {
20+
onNavigate?: (page: Page) => void;
21+
}
22+
23+
export default function MesocycleDashboard({
24+
onNavigate,
25+
}: MesocycleDashboardProps) {
1926
const allMesocycles = useMesocycles();
2027
const activeMesocycle = useActiveMesocycle();
2128
const [showForm, setShowForm] = useState(false);
@@ -112,14 +119,10 @@ export default function MesocycleDashboard() {
112119
const handleStartWorkout = (splitDayId: string) => {
113120
// Store the selected split day ID in localStorage for the workout session to pick up
114121
localStorage.setItem('selectedSplitDayId', splitDayId);
115-
// In a real app with routing, we would navigate to /workout
116-
// For now, we'll just alert (the parent App component would handle navigation)
117-
alert(
118-
'Navigate to workout session with split day: ' +
119-
splitDayId +
120-
'\n\n' +
121-
'Note: Full integration requires navigation support in the parent component.'
122-
);
122+
// Navigate to workout page
123+
if (onNavigate) {
124+
onNavigate('workout');
125+
}
123126
};
124127

125128
return (

src/layouts/Layout.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import type { ReactNode } from 'react';
22
import './Layout.css';
33

4-
type Page = 'mesocycles' | 'workout' | 'exercises' | 'progress' | 'settings';
4+
export type Page =
5+
| 'mesocycles'
6+
| 'workout'
7+
| 'exercises'
8+
| 'progress'
9+
| 'settings';
510

611
interface LayoutProps {
712
children: ReactNode;

0 commit comments

Comments
 (0)