Skip to content

Commit

Permalink
belindas-closet-nextjs_9_469_add-all-products-link-to-nav-bar (#470)
Browse files Browse the repository at this point in the history
* Move arrow icon to the right of the products dropdown

* Add All Products link to nav bar
  • Loading branch information
heosman authored Jul 4, 2024
1 parent 56a8b0a commit 7163795
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions components/CategoryDropDownMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Container, Button, Menu, MenuItem } from "@mui/material";
import { ArrowDropDown } from "@mui/icons-material";
import { useRouter } from "next/navigation";
const navItems = [
"All Products",
"Shirts",
"Shoes",
"Pants",
Expand All @@ -25,8 +26,12 @@ export default function CategoryDropDownMenu() {
};
const router = useRouter();
const navigate = (item: string) => {
const encodedCategoryId = encodeURIComponent(item); //sanitize item name for route
router.push(`/category-page/${encodedCategoryId}`);
if (item === "All Products") {
router.push(`/category-page/all-products`);
} else {
const encodedCategoryId = encodeURIComponent(item); //sanitize item name for route
router.push(`/category-page/${encodedCategoryId}`);
}
handleClose();
};

Expand All @@ -38,7 +43,7 @@ export default function CategoryDropDownMenu() {
aria-haspopup="true"
aria-expanded={open ? "true" : undefined}
onClick={handleClick}
startIcon={<ArrowDropDown />}
endIcon={<ArrowDropDown />}
color={open ? "inherit" : "inherit"}
>
Products
Expand Down

0 comments on commit 7163795

Please sign in to comment.