Deploy
This commit is contained in:
@@ -0,0 +1,88 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
import { useMedusaProducts } from '@/hooks/useMedusaProducts'
|
||||||
|
import { Card, CardHeader, CardTitle, CardContent, CardFooter } from '@/components/ui/Card'
|
||||||
|
import Button from '@/components/ui/Button'
|
||||||
|
import Link from 'next/link'
|
||||||
|
import Image from 'next/image'
|
||||||
|
|
||||||
|
export default function VendaHeritageRoomsSection() {
|
||||||
|
const { products: rooms, isLoading, error } = useMedusaProducts(6)
|
||||||
|
|
||||||
|
const CURRENCY_SYMBOLS: Record<string, string> = { zar: 'R', usd: '$', eur: '€', gbp: '£' }
|
||||||
|
const formatPrice = (amount: number, code?: string) => {
|
||||||
|
const sym = CURRENCY_SYMBOLS[(code ?? '').toLowerCase()] ?? (code?.toUpperCase() ?? '')
|
||||||
|
return `${sym}${(amount / 100).toFixed(2)}`
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isLoading) {
|
||||||
|
return (
|
||||||
|
<section data-vula-section="vendaheritagerooms" id="venda-rooms" className="py-20 bg-[#f4f9f5]">
|
||||||
|
<div className="container mx-auto px-4 text-center">
|
||||||
|
<p className="text-[#8b5a3c] animate-pulse">Loading rooms...</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return (
|
||||||
|
<section id="venda-rooms" className="py-20 bg-[#f4f9f5]">
|
||||||
|
<div className="container mx-auto px-4 text-center">
|
||||||
|
<p className="text-red-600">Could not load rooms. Please try again later.</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section id="venda-rooms" className="py-20 bg-[#f4f9f5]">
|
||||||
|
<div className="container mx-auto px-4">
|
||||||
|
<h2 className="text-3xl md:text-4xl font-bold text-[#0d2114] text-center mb-4">
|
||||||
|
Six Rooms, Each a Home
|
||||||
|
</h2>
|
||||||
|
<p className="text-center text-[#8b5a3c] mb-12 max-w-2xl mx-auto">
|
||||||
|
Named after Venda fruit trees — Muvhuyu, Murula, Muumo — each room weaves handcrafted decor with local tradition.
|
||||||
|
</p>
|
||||||
|
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-8">
|
||||||
|
{rooms && rooms.length > 0 ? rooms.map((room: any) => {
|
||||||
|
const price = room.variants?.[0]?.prices?.[0]
|
||||||
|
return (
|
||||||
|
<Card key={room.id} className="overflow-hidden border border-[#d4e2d9] shadow-lg hover:shadow-xl transition-shadow duration-200">
|
||||||
|
<div className="relative h-56 w-full overflow-hidden">
|
||||||
|
<Image
|
||||||
|
src={room.thumbnail || 'https://images.pexels.com/photos/17450215/pexels-photo-17450215.png?auto=compress&cs=tinysrgb&h=350'}
|
||||||
|
alt={room.title}
|
||||||
|
fill
|
||||||
|
sizes="(max-width: 640px) 100vw, (max-width: 1024px) 50vw, 33vw"
|
||||||
|
className="object-cover hover:scale-105 transition-transform duration-500 ease-out"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<CardHeader>
|
||||||
|
<CardTitle className="text-[#0d2114] text-xl">{room.title}</CardTitle>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<p className="text-[#8b5a3c] text-sm mb-2 line-clamp-2">{room.description}</p>
|
||||||
|
{price && (
|
||||||
|
<p className="text-[#16a34a] font-bold text-lg">
|
||||||
|
{formatPrice(price.amount, price.currency_code)} / night
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</CardContent>
|
||||||
|
<CardFooter>
|
||||||
|
<Link href={`/booking/${room.id}`} className="w-full">
|
||||||
|
<Button variant="default" size="sm" className="w-full bg-[#16a34a] hover:bg-[#15803d] text-white">
|
||||||
|
Book Now
|
||||||
|
</Button>
|
||||||
|
</Link>
|
||||||
|
</CardFooter>
|
||||||
|
</Card>
|
||||||
|
)
|
||||||
|
}) : (
|
||||||
|
<p className="col-span-full text-center text-[#8b5a3c]">No rooms available yet. Check back soon.</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user