refactor: permission
This commit is contained in:
@@ -20,6 +20,7 @@ export type AuthUser = {
|
||||
status: string;
|
||||
role_code: string | null;
|
||||
is_system_admin: boolean;
|
||||
permissions: string[];
|
||||
};
|
||||
|
||||
export type AuthWorkspace = {
|
||||
@@ -312,3 +313,8 @@ export function useApi(): WorkspaceBoundApi {
|
||||
deleteWorkspaceMember: (workspaceId, userId) => rawApi.deleteWorkspaceMember(workspaceId, userId),
|
||||
}), [workspaceId]);
|
||||
}
|
||||
|
||||
export function usePermission(code: string): boolean {
|
||||
const { user } = useAuth();
|
||||
return user?.permissions.includes(code) ?? false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user