"use client"; import Link from "next/link"; import { useState } from "react"; import { buildCategoryTree, categoryLabel } from "@/lib/meshkee/format"; import type { Category } from "@/lib/meshkee/types"; import { storeCategoryHref } from "@/lib/meshkee/urls"; export function ProductsMegaMenu({ categories }: { categories: Category[] }) { const [open, setOpen] = useState(false); const tree = buildCategoryTree(categories).filter( (node) => node.children.length > 0 || !node.parentId, ); return (
setOpen(true)} onMouseLeave={() => setOpen(false)} > setOpen(true)} aria-expanded={open} > محصولات {open ? (
{tree.length === 0 ? (

دسته‌بندی‌ای برای نمایش وجود ندارد.

) : (
{tree.map((parent) => (
setOpen(false)} > {categoryLabel(parent)} {parent.children.length > 0 ? (
    {parent.children.map((child) => (
  • setOpen(false)} > {categoryLabel(child)}
  • ))}
) : null}
))}
)}
) : null}
); }