feature/IO-3228-Notifications-1.6-and-Deprecations
- See Ticket for full details (Notifications restrictions, AntD deprecations)
This commit is contained in:
19
client/src/utils/useIsEmployee.js
Normal file
19
client/src/utils/useIsEmployee.js
Normal file
@@ -0,0 +1,19 @@
|
||||
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]);
|
||||
}
|
||||
Reference in New Issue
Block a user