import { create } from 'zustand';
import type { RolePermissions } from '@/lib/db/schema/users';

interface PermissionsState {
  permissions: RolePermissions | null;
  isSuperAdmin: boolean;
  userId: string | null;
  setPermissions: (
    permissions: RolePermissions | null,
    isSuperAdmin: boolean,
    userId: string | null,
  ) => void;
  reset: () => void;
}

export const usePermissionsStore = create<PermissionsState>()((set) => ({
  permissions: null,
  isSuperAdmin: false,
  userId: null,
  setPermissions: (permissions, isSuperAdmin, userId) => set({ permissions, isSuperAdmin, userId }),
  reset: () => set({ permissions: null, isSuperAdmin: false, userId: null }),
}));
