import { useLocation, useNavigate } from 'react-router-dom';
import { useState } from 'react';
import Header from '@/components/Header';
import Footer from '@/components/Footer';
import { Button } from '@/components/ui/button';
import { Badge } from '@/components/ui/badge';
import { Card, CardContent } from '@/components/ui/card';
import {
Star,
Heart,
Phone,
MapPin,
ExternalLink,
Expand,
Calendar,
User,
Video,
Fan,
Waves,
Wifi,
Car,
Utensils,
Shield,
Coffee
} from 'lucide-react';
import BookingSidebar from '@/components/BookingSidebar';
import { useCart } from '@/contexts/CartContext';
import { useToast } from '@/hooks/use-toast';
export function ListingDetails() {
const location = useLocation();
const navigate = useNavigate();
const { listing } = location.state || {};
const { addToCart } = useCart();
const { toast } = useToast();
const [isBookmarked, setIsBookmarked] = useState(false);
if (!listing) {
return (
Listing not found
navigate('/explore')}>
Back to Explore
);
}
const amenities = [
{ icon: Video, name: "Security cameras" },
{ icon: Fan, name: "Garden" },
{ icon: Waves, name: "Jacuzzi" },
{ icon: Wifi, name: "Free WiFi" },
{ icon: Car, name: "Parking" },
{ icon: Utensils, name: "Restaurant" },
{ icon: Shield, name: "24/7 Security" },
{ icon: Coffee, name: "Breakfast" }
];
const galleryImages = [
"https://themes.easital.com/html/liston/v2.3/assets/images/listing-details/gallery/08.jpg",
"https://themes.easital.com/html/liston/v2.3/assets/images/listing-details/gallery/09.jpg",
"https://themes.easital.com/html/liston/v2.3/assets/images/listing-details/gallery/10.jpg"
];
// Convert listing to offer format for BookingSidebar
const offerForBooking = {
id: listing?.id || 'default-id',
title: listing?.title || 'Listing',
price: listing?.priceRange?.min || 12,
category: 'hotel',
images: listing?.image ? [listing.image] : [],
location: {
address: listing?.location || 'Unknown location',
},
};
const handleAddToCart = (date: Date | undefined, guests: number, timeSlot?: string) => {
const cartItem = {
id: offerForBooking.id,
title: offerForBooking.title,
price: offerForBooking.price,
image: offerForBooking.images[0],
category: offerForBooking.category,
location: offerForBooking.location.address,
selectedDate: date?.toISOString().split('T')[0] || '',
guests: guests || undefined,
timeSlot
};
addToCart(cartItem);
toast({
title: '¡Agregado al carrito!',
description: `${offerForBooking.title} se ha agregado a tu carrito.`,
});
};
const handleBookNow = (date: Date | undefined, guests: number, timeSlot?: string) => {
// This will be handled by BookingModal in BookingSidebar
};
return (
{/* Details Header */}
{listing.title || 'Chuijhal Hotel And Restaurant'}
Posted 7 hours ago
1123 Fictional St, San Francisco
Full time
{/* Gallery */}
View photos
View photos
Published:
November 21, 2023
{/* Main Content */}
{/* Description */}
Latest Property Reviews
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
when an unknown printer took a galley of type and scrambled it to make a type
specimen book. It is a long established fact that a reader will be distracted
by the readable content of a page when looking at its layout.
It has survived not only five centuries, but also the leap into electronic
typesetting, remaining essentially unchanged. It was popularised in the 1960s
with the release of Letraset sheets containing Lorem Ipsum passages, and more
recently with desktop publishing software like Aldus PageMaker including
versions of Lorem Ipsum.
{/* Amenities */}
Amenities Available
{amenities.map((amenity, index) => (
))}
{/* Sidebar */}
);
}