From 04a62f26ff28a83ffd9e0ad07e227db7a7b3765c Mon Sep 17 00:00:00 2001 From: chip <49256163+chipanyanwu@users.noreply.github.com> Date: Sun, 27 Oct 2024 15:26:32 -0500 Subject: [PATCH] add header and goal tracker to home page --- src/App.jsx | 21 ++++++++++-- src/pages/Home.jsx | 82 +++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 96 insertions(+), 7 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 2fa360c..3683dcc 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -10,6 +10,7 @@ import { theme } from '@utils/theme'; import Home from './pages/Home'; +import Header from '@components/common/Header'; import './App.css'; const App = () => { @@ -22,8 +23,24 @@ const App = () => {
{/* Main content area where pages will render */} - } /> - } /> + +
+ + + } + /> + +
+ + + } + />
diff --git a/src/pages/Home.jsx b/src/pages/Home.jsx index ced5c3b..5198d38 100644 --- a/src/pages/Home.jsx +++ b/src/pages/Home.jsx @@ -1,11 +1,83 @@ -import Header from '@components/common/Header'; +import GoalTracker from '@components/Home/GoalTracker'; +import { Box } from '@mui/material'; +import { useState } from 'react'; const Home = () => { + const [goals, setGoals] = useState([ + { + id: '1', + title: 'Improve Coding Skills', + expanded: true, + microGoals: [ + { + id: '1-1', + title: 'Learn React', + expanded: true, + tasks: [ + { id: '1-1-1', title: 'Complete React tutorial', completed: true }, + { id: '1-1-2', title: 'Build a small project', completed: false }, + ], + }, + { + id: '1-2', + title: 'Master JavaScript', + expanded: false, + tasks: [ + { id: '1-2-1', title: 'Study ES6+ features', completed: false }, + { id: '1-2-2', title: 'Practice coding challenges', completed: false }, + ], + }, + ], + }, + ]); + + const handleToggleTask = (macroGoalId, microGoalId, taskId) => { + setGoals((prevGoals) => + prevGoals.map((macroGoal) => + macroGoal.id === macroGoalId + ? { + ...macroGoal, + microGoals: macroGoal.microGoals.map((microGoal) => + microGoal.id === microGoalId + ? { + ...microGoal, + tasks: microGoal.tasks.map((task) => + task.id === taskId ? { ...task, completed: !task.completed } : task, + ), + } + : microGoal, + ), + } + : macroGoal, + ), + ); + }; + + const handleToggleExpand = (goalId, goalType) => { + setGoals((prevGoals) => + prevGoals.map((macroGoal) => + goalType === 'macro' && macroGoal.id === goalId + ? { ...macroGoal, expanded: !macroGoal.expanded } + : { + ...macroGoal, + microGoals: macroGoal.microGoals.map((microGoal) => + goalType === 'micro' && microGoal.id === goalId + ? { ...microGoal, expanded: !microGoal.expanded } + : microGoal, + ), + }, + ), + ); + }; + return ( -
-
-

Home

-
+ + + ); };