"use client" import Image from "next/image" import Link from "next/link" import { useState, useEffect } from "react" import { Button } from "@/components/ui/button" import { Card, CardContent } from "@/components/ui/card" interface StripeProduct { id: string name: string description: string | null images: string[] price: { id: string amount: number | null currency: string } } export default function MasksArtPage() { const [products, setProducts] = useState([]) const [loading, setLoading] = useState(true) const [error, setError] = useState(null) useEffect(() => { fetchProducts() }, []) const fetchProducts = async () => { try { const response = await fetch("/api/products") const data = await response.json() if (!response.ok) { throw new Error(data.error || "Failed to fetch products") } setProducts(data.products) } catch (err) { console.error("[v0] Error fetching products:", err) setError(err instanceof Error ? err.message : "Failed to load products") } finally { setLoading(false) } } const handlePurchase = async (priceId: string, productName: string) => { try { console.log("[v0] Starting purchase for:", productName) const response = await fetch("/api/create-product-checkout", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ priceId }), }) const data = await response.json() if (!response.ok) { throw new Error(data.error || "Failed to create checkout session") } console.log("[v0] Checkout session created, redirecting to:", data.url) // Open in new tab to avoid ad blocker issues const newWindow = window.open(data.url, "_blank") if (!newWindow) { // Fallback: copy URL to clipboard await navigator.clipboard.writeText(data.url) alert( "Popup blocked! The checkout URL has been copied to your clipboard. Please paste it in a new tab to complete your purchase.", ) } } catch (err) { console.error("[v0] Error during purchase:", err) alert(`Error: ${err instanceof Error ? err.message : "Failed to start checkout"}`) } } const formatPrice = (amount: number | null, currency: string) => { if (!amount) return "Price not available" return new Intl.NumberFormat("en-US", { style: "currency", currency: currency.toUpperCase(), }).format(amount / 100) } return (
{/* Header */}

Welcome to

AlertBayTrumpeter.com!

{/* Navigation */}
{/* Masks & Art Content */}

Traditional Indigenous Masks & Art

Alert Bay is home to rich Indigenous culture and traditional art. Explore and purchase beautiful masks and artwork that represent the heritage and traditions of the local First Nations communities.

{loading && (

Loading products...

)} {error && (

Error loading products: {error}

)} {!loading && !error && products.length === 0 && (

No products available at this time.

)} {!loading && !error && products.length > 0 && (
{products.map((product) => (
{product.name}

{product.name}

{product.description &&

{product.description}

}
{formatPrice(product.price.amount, product.price.currency)}
))}
)}
{/* Get in Touch call-to-action section */}

Interested in Jerry's Art?

Have questions about a piece or want to commission custom artwork? Jerry would love to hear from you!

Get in Touch
{/* Footer with Jerry's contact information */}
) }