Files
pangolin/src/components/command-palette/useCanUseCommandPalette.ts
T
2026-07-07 21:55:15 -04:00

25 lines
624 B
TypeScript

"use client";
import { useUserContext } from "@app/hooks/useUserContext";
import { ListUserOrgsResponse } from "@server/routers/org";
import { usePathname } from "next/navigation";
export function useCanUseCommandPalette(
orgId?: string,
orgs?: ListUserOrgsResponse["orgs"]
) {
const pathname = usePathname();
const { user } = useUserContext();
if (pathname?.startsWith("/admin")) {
return user.serverAdmin;
}
if (!orgId) {
return false;
}
const currentOrg = orgs?.find((org) => org.orgId === orgId);
return Boolean(currentOrg?.isAdmin || currentOrg?.isOwner);
}