import { useMemo } from "react";

/**
 * Check if the user is an employee of the bodyshop
 * @param bodyshop
 * @param userOrEmail
 * @returns {boolean|*}
 */
export function useIsEmployee(bodyshop, userOrEmail) {
  return useMemo(() => {
    if (!bodyshop || !bodyshop.employees) return false;

    // Handle both user object and email string
    const email = typeof userOrEmail === "string" ? userOrEmail : userOrEmail?.email;
    if (!email) return false;

    return bodyshop.employees.some((employee) => employee.user_email === email);
  }, [bodyshop, userOrEmail]);
}
