"use client"; import { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import { useRouter } from "next/navigation"; import { motion } from "framer-motion"; import Link from "next/link"; import Image from "next/image"; import { Heart, MapPin, Bed, Bath, Square, X, ImageIcon } from "lucide-react"; import { useFavorites } from "@/app/contexts/FavoritesContext"; import AuthService from "@/app/services/AuthService"; import Loading from "../loading"; export default function FavoritesPage() { const { t } = useTranslation(); const router = useRouter(); const { favorites, isLoading: favoritesLoading, removeFavorite } = useFavorites(); useEffect(() => { // Admin check removed // if (AuthService.isAdmin()) { // router.push('/'); // return; // } // setIsAdmin(AuthService.isAdmin()); }, [router]); const formatCurrency = (amount) => { return amount?.toLocaleString() + " " + t("currency-syp-suffix"); }; if (favoritesLoading && favorites.length === 0) { return ; } return (

{t("favorites")}

{t("saved-properties")}

{favorites.length === 0 ? (

{t("no-favorites")}

{t("add-favorites-hint")}

{t("browse-properties")}
) : (
{favorites.map((property) => (
{property.images && property.images[0] ? ( {property.title} ) : (
)}
{property.type === "apartment" ? t("buildingType.apartment") : property.type === "villa" ? t("buildingType.villa") : t("buildingType.house")}

{property.title}

{property.location.city}، {property.location.district}
{formatCurrency(property.price)}
/{property.priceUnit === "daily" ? t("day") : t("month")}
{property.bedrooms}
{property.bathrooms}
{property.area}م²
{t("viewDetails")}
))}
)}
); }