"use client"; import { useCompare } from "@/context/CompareContext"; import { properties } from "@/data/properties"; import Header from "@/components/Header"; import Footer from "@/components/Footer"; import InnerBanner from "@/components/InnerBanner"; import Image from "next/image"; import Link from "next/link"; import { useState } from "react"; export default function CompareClient() { const { compareList, removeFromCompare, addToCompare } = useCompare(); const [showAddModal, setShowAddModal] = useState(false); // Get properties not in compare list for adding const availableProperties = properties.filter( p => !compareList.find(c => c.id === p.id) ); const handleAddProperty = (property: typeof properties[0]) => { addToCompare(property); setShowAddModal(false); }; return (
{compareList.length < 2 ? (

Select at least 2 properties to compare

Go to the properties page and click the compare icon on the properties you want to compare

Browse Properties
) : (
{compareList.map((property) => ( ))} {/* Add Property Slot */} {compareList.length < 4 && ( )} {/* Price */} {compareList.map((property) => ( ))} {compareList.length < 4 && } {/* Configuration */} {compareList.map((property) => ( ))} {compareList.length < 4 && } {/* Area */} {compareList.map((property) => ( ))} {compareList.length < 4 && } {/* Possession */} {compareList.map((property) => ( ))} {compareList.length < 4 && } {/* Total Units */} {compareList.map((property) => ( ))} {compareList.length < 4 && } {/* Category */} {compareList.map((property) => ( ))} {compareList.length < 4 && } {/* Status */} {compareList.map((property) => ( ))} {compareList.length < 4 && } {/* Amenities Header */} {/* Amenities - Get all unique amenities */} {Array.from(new Set(compareList.flatMap(p => p.amenities))).map((amenity, idx) => ( {compareList.map((property) => ( ))} {compareList.length < 4 && } ))} {/* View Details */} {compareList.map((property) => ( ))} {compareList.length < 4 && }
Features
{property.title}

{property.title}

{property.location}

Price {property.price}
Configuration{property.overview.bhk}
Area{property.overview.size}
Possession{property.overview.possession}
Total Units{property.overview.totalUnits}
Property Type{property.category}
Status {property.status}
Amenities
{amenity} {property.amenities.includes(amenity) ? ( ) : ( )}
Actions View Details
)}
{/* Add Property Modal */} {showAddModal && (
{/* Modal Header */}

Add Property to Compare

{/* Modal Content */}
{availableProperties.length === 0 ? (

All properties are already in comparison

) : (
{availableProperties.map((property) => ( ))}
)}
)}
); }