mirror of
https://github.com/fosrl/pangolin.git
synced 2026-07-09 15:39:47 +02:00
25 lines
624 B
TypeScript
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);
|
|
}
|