import { useAuth } from "@/app/auth/AuthProvider.jsx";
import { PERMISSIONS } from "@/app/permissions";

export function useExternalAdminUserAbilities() {
    const { can } = useAuth();
    const canCreateAccount = can(PERMISSIONS.externalAdminUserCreate);
    const canManagePermissions = can(PERMISSIONS.externalAdminUserPermissions);

    return {
        // 创建必须同时能配置权限，禁止通过“省略权限字段使用默认值”绕过独立授权边界。
        canCreate: canCreateAccount && canManagePermissions,
        canCreateAccount,
        canManagePermissions,
        canResetPassword: can(PERMISSIONS.externalAdminUserResetPassword),
        canStatus: can(PERMISSIONS.externalAdminUserStatus),
        canView: can(PERMISSIONS.externalAdminUserView),
    };
}
