import { useAuth } from "@/store/auth";
import { Blocks, Home, Settings2, User, Users } from "lucide-react";
import { useCallback, type ReactNode } from "react";
import { useLocation } from "react-router";
export interface BarItem {
icon: ReactNode;
title: string;
tab: string;
pathname: string;
}
export const useBarItems = (): [BarItem[], (item: BarItem) => boolean] => {
const profile = useAuth((state) => state.profile);
const location = useLocation();
const isActive = useCallback(
(item: BarItem) => {
if (item.pathname === "/") return location.pathname === item.pathname;
return location.pathname.startsWith(item.pathname);
},
[location.pathname],
);
if (!profile) {
return [[], isActive];
}
return [
[
{
icon: ,
title: "Home",
tab: "home",
pathname: "/",
},
{
icon: ,
title: "Personal Info",
tab: "personal-info",
pathname: "/personal-info",
},
{
icon: ,
title: "Data & Personalization",
tab: "data-personalization",
pathname: "/data-personalize",
},
...(profile.isAdmin
? [
{
icon: ,
title: "API Services",
tab: "admin.api-services",
pathname: "/admin/api-services",
},
{
icon: ,
title: "Users",
tab: "admin.users",
pathname: "/admin/users",
},
]
: []),
],
isActive,
];
};