"use client";

import React from "react";
import { usePathname } from "next/navigation";
import { useMenuStore } from "@/stores";

export function useNavigationData() {
  const pathname = usePathname();
  const menus = useMenuStore((state) => state.menus);
  return React.useMemo(() => {
    const current = menus.find((m) => pathname === m.path || pathname.startsWith(`${m.path}/`));
    const navMain = (current?.children || []).map((second) => ({
      title: second.title,
      items: (second.children || []).map((third) => ({ title: third.title, url: third.path }))
    }));
    return { navMain };
  }, [menus, pathname]);
}
