import { usePage } from "@inertiajs/react";
import { type SharedData } from "@/types";

/**
 * Tenant Authorization Hook
 * 
 * For tenant users, checks if they have specific permission slugs
 * assigned through their current role.
 */
export default function useAuthorization() {
    const { auth } = usePage<SharedData>().props;

    const can = (permission: string): boolean => {
        // Check if user has specific permission
        return auth?.permissions?.includes(permission) || false;
    };

    return { can };
}
