2026-08-04 12:51:47 +03:00
|
|
|
// app/hooks/useAuth.js
|
|
|
|
|
import AuthService from "../services/AuthService";
|
|
|
|
|
|
|
|
|
|
export default function useAuth() {
|
|
|
|
|
const authUser = AuthService.getUser();
|
|
|
|
|
const role = authUser?.roles;
|
|
|
|
|
return {
|
|
|
|
|
user: authUser,
|
|
|
|
|
name: authUser?.name ?? "Not found",
|
|
|
|
|
email: authUser?.email ?? "Not found",
|
|
|
|
|
isOwner: role?.includes("Owner"),
|
2026-08-26 20:50:25 +03:00
|
|
|
isAgent: role?.includes("RealEstateAgent"),
|
2026-08-04 12:51:47 +03:00
|
|
|
isCustomer: role?.includes("Customer"),
|
|
|
|
|
role: role,
|
|
|
|
|
isGuest: !authUser,
|
|
|
|
|
isAuthenticated: !!authUser,
|
|
|
|
|
};
|
|
|
|
|
}
|