feat: refactor organization membership logic and simplify admin role checks

This commit is contained in:
Abhimanyu Saharan
2026-02-08 23:49:34 +05:30
parent cd732e312f
commit a4aced9a88
12 changed files with 55 additions and 187 deletions

View File

@@ -15,10 +15,7 @@ import {
import { useAuth } from "@/auth/clerk";
import { ApiError } from "@/api/mutator";
import {
type getMyMembershipApiV1OrganizationsMeMemberGetResponse,
useGetMyMembershipApiV1OrganizationsMeMemberGet,
} from "@/api/generated/organizations/organizations";
import { useOrganizationMembership } from "@/lib/use-organization-membership";
import {
type healthzHealthzGetResponse,
useHealthzHealthzGet,
@@ -28,19 +25,7 @@ import { cn } from "@/lib/utils";
export function DashboardSidebar() {
const pathname = usePathname();
const { isSignedIn } = useAuth();
const membershipQuery = useGetMyMembershipApiV1OrganizationsMeMemberGet<
getMyMembershipApiV1OrganizationsMeMemberGetResponse,
ApiError
>({
query: {
enabled: Boolean(isSignedIn),
refetchOnMount: "always",
retry: false,
},
});
const member =
membershipQuery.data?.status === 200 ? membershipQuery.data.data : null;
const isAdmin = member ? ["owner", "admin"].includes(member.role) : false;
const { isAdmin } = useOrganizationMembership(isSignedIn);
const healthQuery = useHealthzHealthzGet<healthzHealthzGetResponse, ApiError>(
{
query: {