diff --git a/app/ClientLayout.js b/app/ClientLayout.js index 1a50712..164ba89 100644 --- a/app/ClientLayout.js +++ b/app/ClientLayout.js @@ -78,7 +78,7 @@ export default function ClientLayout({ children }) { name: authUser.name || authUser.email, email: authUser.email, phone: authUser.phone, - role: AuthService.isOwner() ? UserRole.OWNER : UserRole.CUSTOMER, + role: AuthService.isOwner() ? UserRole.OWNER : AuthService.isAgent() ? UserRole.AGENT : UserRole.CUSTOMER, }); } else { setUser(null); @@ -135,6 +135,8 @@ export default function ClientLayout({ children }) { const isProfilePage = pathname === "/profile"; const isOwner = user?.role === UserRole.OWNER; + const isAgent = user?.role === UserRole.AGENT; + const isOwnerOrAgent = isOwner || isAgent; const isCustomer = user?.role === UserRole.CUSTOMER; const isAuthenticated = !!user; @@ -718,7 +720,7 @@ export default function ClientLayout({ children }) { {isAuthenticated && !isAuthPage && ( - + )} diff --git a/app/components/BottomNav.js b/app/components/BottomNav.js index 7729c25..e0a61ff 100644 --- a/app/components/BottomNav.js +++ b/app/components/BottomNav.js @@ -1,11 +1,13 @@ "use client"; import Link from "next/link"; -import { Home, Building, Calendar, Heart, Bell, Settings, CreditCard } from "lucide-react"; +import { usePathname } from "next/navigation"; +import { Home, Building, Calendar, Heart, Bell, Settings, CreditCard, Briefcase } from "lucide-react"; import React, { useEffect, useState } from "react"; import { useNotifications } from "@/app/contexts/NotificationsContext"; -export default function BottomNav({ isOwner }) { +export default function BottomNav({ isOwner, isOwnerOrAgent }) { + const pathname = usePathname(); const { unreadCount } = useNotifications(); const [isMounted, setIsMounted] = useState(false); const bookingsHref = isOwner ? "/owner/reservations" : "/reservations"; @@ -17,6 +19,7 @@ export default function BottomNav({ isOwner }) { const items = [ { href: "/", label: "الرئيسية", icon: Home }, { href: "/properties", label: "عقاراتنا", icon: Building }, + ...(isOwnerOrAgent ? [{ href: "/owner/properties", label: "عقاراتي", icon: Briefcase }] : []), { href: bookingsHref, label: "الحجوزات", icon: Calendar }, { href: "/favorites", label: "المفضلة", icon: Heart }, { href: "/payments", label: "المدفوعات", icon: CreditCard }, @@ -24,16 +27,22 @@ export default function BottomNav({ isOwner }) { { href: "/settings", label: "الإعدادات", icon: Settings }, ]; + const isActive = (href) => { + if (href === "/") return pathname === "/"; + return pathname.startsWith(href); + }; + return (