feat: phase 4 - frontend groups UI, permission-matrix, usePermission hook, field-level permissions tab, authStore permissions
This commit is contained in:
@@ -14,6 +14,9 @@ export interface User {
|
||||
role: string;
|
||||
avatar_url: string | null;
|
||||
tenants: Tenant[];
|
||||
permissions?: string[];
|
||||
is_system_admin?: boolean;
|
||||
field_permissions?: Record<string, any>;
|
||||
}
|
||||
|
||||
export interface AuthState {
|
||||
@@ -26,6 +29,7 @@ export interface AuthState {
|
||||
setAuthenticated: (authed: boolean) => void;
|
||||
setLoading: (loading: boolean) => void;
|
||||
setError: (error: string | null) => void;
|
||||
setPermissions: (perms: string[], isSystemAdmin: boolean, fieldPerms: Record<string, any>) => void;
|
||||
logout: () => void;
|
||||
}
|
||||
|
||||
@@ -45,6 +49,17 @@ export const useAuthStore = create<AuthState>((set) => ({
|
||||
setAuthenticated: (authed) => set({ isAuthenticated: authed }),
|
||||
setLoading: (loading) => set({ isLoading: loading }),
|
||||
setError: (error) => set({ error }),
|
||||
setPermissions: (perms, isSystemAdmin, fieldPerms) =>
|
||||
set((state) => ({
|
||||
user: state.user
|
||||
? {
|
||||
...state.user,
|
||||
permissions: perms,
|
||||
is_system_admin: isSystemAdmin,
|
||||
field_permissions: fieldPerms,
|
||||
}
|
||||
: null,
|
||||
})),
|
||||
logout: () =>
|
||||
set({
|
||||
user: null,
|
||||
|
||||
Reference in New Issue
Block a user