2026-06-04 22:54:34 +03:00
|
|
|
"use client";
|
|
|
|
|
|
|
|
|
|
import Link from "next/link";
|
2026-06-24 00:07:09 +03:00
|
|
|
import { usePathname } from "next/navigation";
|
2026-06-28 23:22:35 +03:00
|
|
|
import { Home, Building, Calendar, CreditCard, Briefcase, BookOpen } from "lucide-react";
|
2026-06-04 22:54:34 +03:00
|
|
|
import React, { useEffect, useState } from "react";
|
2026-07-01 15:43:58 +03:00
|
|
|
import { useTranslation } from "react-i18next";
|
2026-08-06 22:26:35 +03:00
|
|
|
import { label } from "framer-motion/client";
|
2026-06-04 22:54:34 +03:00
|
|
|
|
2026-06-23 23:32:07 +03:00
|
|
|
export default function BottomNav({ isOwner, isOwnerOrAgent }) {
|
2026-07-01 15:43:58 +03:00
|
|
|
const { t } = useTranslation();
|
2026-06-24 00:07:09 +03:00
|
|
|
const pathname = usePathname();
|
2026-06-04 22:54:34 +03:00
|
|
|
const [isMounted, setIsMounted] = useState(false);
|
|
|
|
|
const bookingsHref = isOwner ? "/owner/reservations" : "/reservations";
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
setIsMounted(true);
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const items = [
|
2026-07-01 15:43:58 +03:00
|
|
|
{ href: "/", label: t("home"), icon: Home },
|
|
|
|
|
{ href: "/properties", label: t("ourProperties"), icon: Building },
|
2026-08-06 22:26:35 +03:00
|
|
|
...(isOwnerOrAgent
|
|
|
|
|
? [
|
|
|
|
|
{ href: "/owner/properties", label: t("myProperties"), icon: Briefcase },
|
|
|
|
|
{ href: "/owner/bookings", label: "عقاراتي المحجوزة", icon: Briefcase },
|
|
|
|
|
{ href: "/reservations", label: "حجوزاتي", icon: Calendar },
|
|
|
|
|
]
|
|
|
|
|
: [{ href: "/booked-properties", label: "حجوزاتي", icon: Briefcase }]),
|
|
|
|
|
{ href: bookingsHref, label: "طلبات الحجز", icon: Calendar },
|
|
|
|
|
|
2026-07-01 15:43:58 +03:00
|
|
|
{ href: "/payments", label: t("payments"), icon: CreditCard },
|
|
|
|
|
...(isOwnerOrAgent ? [{ href: "/owner/account-book", label: t("accountBook"), icon: BookOpen }] : []),
|
2026-06-04 22:54:34 +03:00
|
|
|
];
|
|
|
|
|
|
2026-06-24 00:07:09 +03:00
|
|
|
const isActive = (href) => {
|
|
|
|
|
if (href === "/") return pathname === "/";
|
|
|
|
|
return pathname.startsWith(href);
|
|
|
|
|
};
|
|
|
|
|
|
2026-06-04 22:54:34 +03:00
|
|
|
return (
|
2026-08-08 14:22:34 +03:00
|
|
|
<div className="fixed bottom-0 left-0 right-0 z-50 flex justify-center px-4 pb-3 pt-4 pointer-events-none">
|
|
|
|
|
<nav
|
|
|
|
|
className="
|
|
|
|
|
w-fit max-w-full
|
|
|
|
|
rounded-3xl
|
|
|
|
|
bg-gray-50
|
|
|
|
|
px-2 py-2 sm:px-3
|
|
|
|
|
shadow-[0_4px_24px_rgba(251,146,60,0.25)]
|
|
|
|
|
pointer-events-auto
|
|
|
|
|
"
|
|
|
|
|
>
|
|
|
|
|
<div className="flex items-center justify-center gap-0.5 sm:gap-1 overflow-hidden ">
|
2026-06-28 16:08:46 +03:00
|
|
|
{items.map((it) => {
|
|
|
|
|
const Icon = it.icon;
|
|
|
|
|
const active = isActive(it.href);
|
2026-08-08 14:22:34 +03:00
|
|
|
|
2026-06-28 16:08:46 +03:00
|
|
|
return (
|
|
|
|
|
<Link
|
|
|
|
|
key={it.href}
|
|
|
|
|
href={it.href}
|
2026-08-08 14:22:34 +03:00
|
|
|
className={`
|
|
|
|
|
relative
|
|
|
|
|
flex
|
|
|
|
|
min-w-[58px] sm:min-w-[0px]
|
|
|
|
|
flex-col
|
|
|
|
|
items-center
|
|
|
|
|
justify-center
|
|
|
|
|
rounded-xl
|
|
|
|
|
px-2 py-1.5
|
|
|
|
|
sm:px-1 sm:py-4
|
|
|
|
|
transition-all
|
|
|
|
|
duration-200
|
|
|
|
|
ease-out
|
|
|
|
|
align-middle
|
|
|
|
|
|
|
|
|
|
${active ? "bg-white shadow-sm text-amber-600" : "text-gray-700 hover:bg-white/80 hover:text-amber-600 hover:shadow-md"}
|
|
|
|
|
`}
|
2026-06-28 16:08:46 +03:00
|
|
|
>
|
|
|
|
|
<div className="relative">
|
2026-08-08 14:22:34 +03:00
|
|
|
<Icon className="h-5 w-5 sm:h-6 sm:w-6" />
|
|
|
|
|
|
2026-06-28 16:08:46 +03:00
|
|
|
{it.badge > 0 && (
|
2026-08-08 14:22:34 +03:00
|
|
|
<div
|
|
|
|
|
className="
|
|
|
|
|
absolute -right-2 -top-2
|
|
|
|
|
flex h-6 w-7 sm:h-5 sm:w-5
|
|
|
|
|
items-center justify-center
|
|
|
|
|
rounded-full
|
|
|
|
|
bg-red-500
|
|
|
|
|
text-[9px] sm:text-xs
|
|
|
|
|
font-bold
|
|
|
|
|
text-white
|
|
|
|
|
"
|
|
|
|
|
>
|
|
|
|
|
{it.badge > 9 ? "9+" : it.badge}
|
|
|
|
|
</div>
|
2026-06-28 16:08:46 +03:00
|
|
|
)}
|
|
|
|
|
</div>
|
2026-08-08 14:22:34 +03:00
|
|
|
|
|
|
|
|
<div className="mt-0.5 text-[10px] sm:mt-1 sm:text-xs">{it.label}</div>
|
2026-06-28 16:08:46 +03:00
|
|
|
</Link>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
|
|
|
|
</nav>
|
|
|
|
|
</div>
|
2026-06-04 22:54:34 +03:00
|
|
|
);
|
|
|
|
|
}
|