Deploy
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
'use client'
|
||||
|
||||
import { useMedusaProducts } from "@/hooks/useMedusaProducts"
|
||||
import { Card, CardContent } from "@/components/ui/Card"
|
||||
import Badge from "@/components/ui/Badge"
|
||||
import Link from "next/link"
|
||||
|
||||
const CURRENCY_SYMBOLS: Record<string, string> = { zar: "R", usd: "$", eur: "€", gbp: "£", kes: "KSh", ngn: "₦", ghs: "₵" }
|
||||
const formatPrice = (amount: number, code?: string) => {
|
||||
const sym = CURRENCY_SYMBOLS[(code ?? "").toLowerCase()] ?? (code?.toUpperCase() ?? "")
|
||||
return `${sym}${(amount / 100).toFixed(2)}`
|
||||
}
|
||||
|
||||
export default function NewArrivalsSection() {
|
||||
const { products, isLoading } = useMedusaProducts(6)
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="flex justify-center py-16">
|
||||
<div className="w-8 h-8 rounded-full border-2 border-[#ea580c] border-t-transparent animate-spin" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (!products || products.length === 0) return null
|
||||
|
||||
return (
|
||||
<section
|
||||
id="new-arrivals"
|
||||
data-vula-section="new-arrivals"
|
||||
className="bg-[#18181b] py-20 px-4"
|
||||
>
|
||||
<div className="max-w-7xl mx-auto">
|
||||
<h2 className="text-4xl md:text-5xl font-black uppercase tracking-tight text-white mb-2">
|
||||
JUST LANDED
|
||||
</h2>
|
||||
<p className="text-[#ea580c] uppercase tracking-widest text-sm mb-10">
|
||||
Fresh drops from Soweto's finest
|
||||
</p>
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{products.map((product) => {
|
||||
const price = product.variants?.[0]?.prices?.[0]
|
||||
const formattedPrice = price
|
||||
? formatPrice(price.amount, price.currency_code)
|
||||
: "—"
|
||||
return (
|
||||
<Link key={product.id} href={`/products/${product.id}`} className="group">
|
||||
<Card className="bg-white border-2 border-[#18181b] shadow-[6px_6px_0_0_#ea580c] rounded-none overflow-hidden transition-all duration-200 ease-out hover:shadow-[8px_8px_0_0_#ea580c] hover:-translate-x-0.5 hover:-translate-y-0.5">
|
||||
<div className="aspect-square overflow-hidden">
|
||||
<img
|
||||
src={product.thumbnail ?? "/placeholder-product.svg"}
|
||||
alt={product.title}
|
||||
className="w-full h-full object-cover group-hover:scale-105 transition-transform duration-500 ease-out"
|
||||
/>
|
||||
</div>
|
||||
<CardContent className="p-4">
|
||||
<h3 className="text-lg font-bold text-[#18181b] uppercase tracking-wide">
|
||||
{product.title}
|
||||
</h3>
|
||||
<p className="text-[#ea580c] font-semibold text-lg mt-1">
|
||||
{formattedPrice}
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</Link>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user