"use client"; import { cn, SrcRoot, trimSlash } from "@/app/utils/functions"; import { ArrowDownIcon } from "@/app/utils/svgs/arrowDownIcon"; import Link from "next/link"; import { memo, useState } from "react"; import ImageWithFallback from "../../reuseableUI/ImageWithFallback"; type MenuItem = { __typename: "MenuItem"; id: string; level: number; name: string; url: string; children: MenuItem[]; }; const AccordionSection = memo(function AccordionSection({ section }: { section: MenuItem }) { const [open, setOpen] = useState(false); const isExternal = (href: string) => /^https?:\/\//i.test(href); return (
{open && (
{section.children.map((child) => { const href = child.url || "#"; const external = isExternal(href); return ( {child.name} ); })}
)}
); }); export const MobileAccordion = ({ sections }: { sections: MenuItem[] }) => { const TENANT_NAME = process.env.NEXT_PUBLIC_TENANT_NAME || "default"; const BASE_URL = trimSlash(process.env.NEXT_PUBLIC_ASSETS_BASE_URL); const brandName = TENANT_NAME || "WSM"; const logoSrcRoot: SrcRoot = { basePath: `${BASE_URL}/storage/v1/object/public/storefront-assets/${TENANT_NAME}`, fileName: "logo", }; return (
{sections.map((section) => ( ))}
); };