import { usePage } from "@inertiajs/react";
export default function hasAnyPermission(permissions = []) {
    const { auth } = usePage().props;
    const allPermissions = auth?.user?.permissions ?? {};

    if (typeof allPermissions !== "object" || allPermissions === null) {
        return false;
    }

    if (!Array.isArray(permissions) || permissions.length === 0) {
        return false;
    }

    const result = permissions.some(
        (permission) => allPermissions?.[permission] === true
    );

    return result;
}
