-
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.
refactor/feat: app structure and add confirmation dialog for sign-out (…
…#8) - Moved `Footer` out of `App.jsx` and utilized React Router to manage the current page state. - Added `ConfirmSignOutDialog` to prevent accidental sign-outs, improving user interaction. - Adjusted `Header` position to be outside the content div avoid wrong css styling. - Separated `Streak` component from `App.jsx` for easier future development.
- Loading branch information
Showing
6 changed files
with
117 additions
and
52 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useUser } from '@contexts/UserContext'; | ||
import { Button, Dialog, DialogActions, DialogTitle } from '@mui/material'; | ||
|
||
const ConfirmSignOutDialog = ({ open, onClose }) => { | ||
const { handleSignOut } = useUser(); | ||
|
||
// Function to confirm sign out | ||
const confirmSignOut = async () => { | ||
await handleSignOut(); | ||
onClose(); | ||
}; | ||
|
||
return ( | ||
<Dialog open={open} onClose={onClose}> | ||
<DialogTitle>Confirm Sign Out</DialogTitle> | ||
<DialogActions> | ||
<Button onClick={onClose}>Cancel</Button> | ||
<Button onClick={confirmSignOut} color="error"> | ||
Sign Out | ||
</Button> | ||
</DialogActions> | ||
</Dialog> | ||
); | ||
}; | ||
|
||
export default ConfirmSignOutDialog; |
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,39 @@ | ||
import FlagIcon from '@mui/icons-material/Flag'; | ||
import HomeIcon from '@mui/icons-material/Home'; | ||
import { BottomNavigation, BottomNavigationAction } from '@mui/material'; | ||
import { Link, useLocation } from 'react-router-dom'; | ||
|
||
export default function Footer() { | ||
const location = useLocation(); | ||
|
||
// Get the index of the page based on the path | ||
const getPageIndex = (path) => { | ||
switch (path) { | ||
case '/': | ||
return 0; | ||
case '/streak': | ||
return 1; | ||
default: | ||
return 0; | ||
} | ||
}; | ||
|
||
return ( | ||
<BottomNavigation | ||
className="bottom-nav" | ||
value={getPageIndex(location.pathname)} | ||
showLabels | ||
sx={{ | ||
backgroundColor: 'primary.light', | ||
position: 'fixed', | ||
bottom: 0, | ||
left: 0, | ||
right: 0, | ||
zIndex: 1000, // Ensure the footer is always on top | ||
}} | ||
> | ||
<BottomNavigationAction label="Home" icon={<HomeIcon />} component={Link} to="/" /> | ||
<BottomNavigationAction label="Streak" icon={<FlagIcon />} component={Link} to="/streak" /> | ||
</BottomNavigation> | ||
); | ||
} |
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,11 @@ | ||
import { Box } from '@mui/material'; | ||
|
||
const Streak = () => { | ||
return ( | ||
<Box sx={{ justifyContent: 'center', display: 'flex' }}> | ||
<h1>Streak</h1> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default Streak; |