diff --git a/src/components/ProductCard.tsx b/src/components/ProductCard.tsx new file mode 100644 index 0000000..f84ab4a --- /dev/null +++ b/src/components/ProductCard.tsx @@ -0,0 +1,73 @@ +'use client'; + +import Image from 'next/image'; +import { Button } from '@/components/ui/button'; +import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '@/components/ui/card'; + +interface StripeProduct { + id: string; + name: string; + description: string | null; + images: string[]; + default_price: { + id: string; + unit_amount: number; + currency: string; + } | null; + metadata: Record; +} + +interface ProductCardProps { + product: StripeProduct; + onCheckout: (productId: string, priceId: string) => void; +} + +export default function ProductCard({ product, onCheckout }: ProductCardProps) { + const formatPrice = (amount: number, currency: string) => { + return new Intl.NumberFormat('en-US', { + style: 'currency', + currency: currency.toUpperCase(), + }).format(amount / 100); + }; + + return ( + + {product.images[0] && ( +
+ {product.name} +
+ )} + + {product.name} + {product.default_price && ( +

+ {formatPrice(product.default_price.unit_amount, product.default_price.currency)} +

+ )} +
+ + {product.description && ( + {product.description} + )} + + + + +
+ ); +}