mirror of
https://github.com/fosrl/pangolin.git
synced 2026-07-09 23:49:47 +02:00
command palette tweaks
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
"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);
|
||||
}
|
||||
Reference in New Issue
Block a user