-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(goalDetails): Goals list redirects to goalDetails pages (#26)
- Add `goalDetials` page. Use `react-router-dom` to redirect to a new page. - Add multiple style refines for UX. - Remove: - `expanded` for `goal` since nouse for that property anymore. - `toggleGoalExpansion ` since we will not use that anymore. - Rename: - `toggleMicroGoalExpansion` to `toggleExpansion` for consistency. --------- Co-authored-by: ZL Asica <[email protected]>
- Loading branch information
1 parent
3910db1
commit 229455a
Showing
9 changed files
with
87 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import AddItem from '@/components/Home/AddItem' | ||
import MicroGoal from '@/components/Home/MicroGoal' | ||
import ProgressIndicator from '@/components/Home/ProgressIndicator' | ||
import { useUser } from '@/contexts/UserContext' | ||
import useGoalsUpdater from '@/hooks/useGoalsUpdater' | ||
import { calculateProgress } from '@/utils/calculateProgress' | ||
import { Box, List, Paper, Typography } from '@mui/material' | ||
import { useParams } from 'react-router-dom' | ||
|
||
const GoalDetails = () => { | ||
const { macroGoalIndex } = useParams() | ||
const { user } = useUser() | ||
const { addMicrogoal } = useGoalsUpdater() | ||
|
||
const macroGoal = user.goals[macroGoalIndex] | ||
const progress = calculateProgress(macroGoal.microgoals) | ||
|
||
return ( | ||
<Box sx={{ p: 4 }}> | ||
<Paper | ||
elevation={3} | ||
sx={{ | ||
p: 2, | ||
mb: 3, | ||
borderRadius: 2, | ||
border: '2px solid', | ||
borderColor: macroGoal.category ? macroGoal.category : '#000', | ||
}} | ||
> | ||
<Box display='flex' alignItems='center'> | ||
<ProgressIndicator value={progress} size={50} thickness={4} /> | ||
<Typography variant='h5' sx={{ ml: 2 }}> | ||
{macroGoal.name} | ||
</Typography> | ||
</Box> | ||
</Paper> | ||
|
||
<AddItem | ||
label='New MicroGoal' | ||
onAdd={(microGoalName) => addMicrogoal(macroGoalIndex, microGoalName)} | ||
/> | ||
|
||
<List sx={{ mt: 3 }}> | ||
{macroGoal.microgoals.map((microGoal, microGoalIndex) => ( | ||
<MicroGoal | ||
key={microGoalIndex} | ||
microGoal={microGoal} | ||
macroGoalIndex={macroGoalIndex} | ||
microGoalIndex={microGoalIndex} | ||
/> | ||
))} | ||
</List> | ||
</Box> | ||
) | ||
} | ||
|
||
export default GoalDetails |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters