chore: setup project for production
This commit is contained in:
54
components/dynamic-navbar/dynamicNavbar.jsx
Normal file
54
components/dynamic-navbar/dynamicNavbar.jsx
Normal file
@@ -0,0 +1,54 @@
|
||||
import React, { useContext } from "react";
|
||||
import Link from "next/link";
|
||||
import {
|
||||
NavigationMenu,
|
||||
NavigationMenuItem,
|
||||
NavigationMenuList,
|
||||
NavigationMenuLink,
|
||||
navigationMenuTriggerStyle,
|
||||
} from "@/components/ui/navigation-menu";
|
||||
import ProductContext from "@/app/contexts/productContext";
|
||||
|
||||
const DynamicNavbar = ({ toggleMenu }) => {
|
||||
const { category } = useContext(ProductContext);
|
||||
|
||||
if (!category) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const categoryItems = category?.map((category) => ({
|
||||
label: category.category_name,
|
||||
url: `/collections/${category.id}`,
|
||||
}));
|
||||
|
||||
const consultation = {
|
||||
label: "Rudraksha consultation",
|
||||
url: "/products/premium-rudraksha-consultation-astrology",
|
||||
};
|
||||
|
||||
const visibleItems = [...categoryItems.slice(0, 4), consultation];
|
||||
|
||||
return (
|
||||
<NavigationMenu className="text-xl">
|
||||
<NavigationMenuList className="text-2xl">
|
||||
{visibleItems.map((item) => (
|
||||
<NavigationMenuItem key={item.label}>
|
||||
<Link href={item.url} legacyBehavior passHref>
|
||||
<NavigationMenuLink className={navigationMenuTriggerStyle()}>
|
||||
{item.label}
|
||||
</NavigationMenuLink>
|
||||
</Link>
|
||||
</NavigationMenuItem>
|
||||
))}
|
||||
|
||||
<NavigationMenuItem>
|
||||
<button onClick={toggleMenu} className={navigationMenuTriggerStyle()}>
|
||||
More
|
||||
</button>
|
||||
</NavigationMenuItem>
|
||||
</NavigationMenuList>
|
||||
</NavigationMenu>
|
||||
);
|
||||
};
|
||||
|
||||
export default DynamicNavbar;
|
||||
Reference in New Issue
Block a user