Skip to content

Commit

Permalink
Merge pull request #42 from fuzue/39-reposition-back-button-on-appbar
Browse files Browse the repository at this point in the history
fix(HeaderBar): fix navigation to new model
  • Loading branch information
eduardoliron authored Jul 14, 2023
2 parents 6d40a97 + 0bf10e0 commit 4534ad6
Showing 1 changed file with 29 additions and 22 deletions.
51 changes: 29 additions & 22 deletions src/components/HeaderBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,39 @@ export default function HeaderBar(props: Props) {
}));

const navigate = useNavigate();
const loaction = useLocation();
const location = useLocation();

function leftButton() {
if(location.pathname.split("/")[1] === "foodpage") {
return (
<IconButton
size="large"
edge="start"
color="inherit"
aria-label="open drawer"
onClick={() => navigate(-1)}
>
<ArrowBackIosNew />
</IconButton>
)
}
return (
<IconButton
size="large"
edge="start"
color="inherit"
aria-label="open drawer"
onClick={props.toggleDrawer}
>
<MenuIcon />
</IconButton>
)
}

return (
<StyledAppBar position="static">
<Toolbar>
{loaction.pathname.split("/")[1] === "foodpage" && (
<IconButton
size="large"
edge="start"
color="inherit"
aria-label="open drawer"
onClick={() => navigate(-1)}
>
<ArrowBackIosNew />
</IconButton>
)}
{leftButton()}
<Search>
<SearchIconWrapper>
<IconButton
Expand All @@ -131,16 +148,6 @@ export default function HeaderBar(props: Props) {
/>
</form>
</Search>
<IconButton
size="large"
edge="start"
color="inherit"
aria-label="open drawer"
onClick={props.toggleDrawer}
sx={{ ml: 0.5 }}
>
<MenuIcon />
</IconButton>
</Toolbar>
</StyledAppBar>
);
Expand Down

0 comments on commit 4534ad6

Please sign in to comment.