diff --git a/src/components/sections/LuxuryAccommodationsSection.tsx b/src/components/sections/LuxuryAccommodationsSection.tsx new file mode 100644 index 0000000..4b23aa0 --- /dev/null +++ b/src/components/sections/LuxuryAccommodationsSection.tsx @@ -0,0 +1,84 @@ +'use client' +import Image from "next/image" +import Link from "next/link" +import { useMedusaProducts } from "@/hooks/useMedusaProducts" +import { Card, CardHeader, CardTitle, CardContent, CardFooter } from "@/components/ui/Card" +import Button from "@/components/ui/Button" +import Badge from "@/components/ui/Badge" + +const CURRENCY_SYMBOLS: Record = { 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)}` +} + +const defaultImg = "https://images.pexels.com/photos/38392428/pexels-photo-38392428.jpeg?auto=compress&cs=tinysrgb&h=350" + +export default function LuxuryAccommodationsSection() { + const { products: rooms, isLoading, error } = useMedusaProducts(6) + + return ( +
+
+
+ + The Suites + +
+

+ Where each room tells a wilderness story +

+ {isLoading && ( +
+ {Array.from({ length: 6 }).map((_, i) => ( + +
+
+ + ))} +
+ )} + {error &&

Unable to load rooms. Please try again later.

} + {rooms && rooms.length > 0 && ( +
+ {rooms.map((room) => { + const price = room.variants?.[0]?.prices?.[0] + const img = room.thumbnail || defaultImg + return ( + +
+ {room.title} +
+ + {room.title} + + +

{room.description}

+ {price && ( + + {formatPrice(price.amount, price.currency_code)} / night + + )} +
+ + + + + +
+ ) + })} +
+ )} +
+
+ ) +} \ No newline at end of file