"use client" import Image from "next/image" import Link from "next/link" import { Button } from "@/components/ui/button" import { Card, CardContent } from "@/components/ui/card" import { useEffect, useState } from "react" interface SubscriptionProduct { id: string name: string description: string | null price: number | null currency: string lookup_key: string | null images: string[] } export default function HomePage() { const [subscriptionProducts, setSubscriptionProducts] = useState([]) const [loading, setLoading] = useState(true) const [error, setError] = useState(null) useEffect(() => { fetchSubscriptionProducts() }, []) const fetchSubscriptionProducts = async () => { try { console.log("[v0] Fetching subscription products...") const response = await fetch("/api/subscription-products") if (!response.ok) { const errorData = await response.json() throw new Error(errorData.error || "Failed to fetch products") } const data = await response.json() console.log("[v0] Received subscription products:", data.products) setSubscriptionProducts(data.products) } catch (error) { console.error("[v0] Error fetching subscription products:", error) setError(error instanceof Error ? error.message : "Failed to load products") } finally { setLoading(false) } } const handleDonate = async (product: SubscriptionProduct) => { try { console.log("[v0] Starting donation process for product:", product.name) let requestBody: any if (product.lookup_key) { // Use lookup_key for one-time donations (legacy sponsor tiers) requestBody = { lookup_key: product.lookup_key } } else { // Use product info for subscription checkouts requestBody = { productId: product.id, productName: product.name, price: product.price, currency: product.currency, description: product.description, mode: "subscription", } } const response = await fetch("/api/create-checkout-session", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(requestBody), }) if (!response.ok) { const errorData = await response.json() throw new Error(errorData.error || `HTTP error! status: ${response.status}`) } const data = await response.json() console.log("[v0] Checkout session created, opening checkout:", data.url) if (data.url) { const newWindow = window.open(data.url, "_blank", "noopener,noreferrer") if (!newWindow) { const userConfirmed = confirm( "Please allow popups for this site to complete your donation, or click OK to copy the checkout link.", ) if (userConfirmed) { navigator.clipboard .writeText(data.url) .then(() => { alert("Checkout link copied to clipboard! Please paste it in a new tab to complete your donation.") }) .catch(() => { alert(`Please visit this link to complete your donation: ${data.url}`) }) } } } else if (data.error) { throw new Error(data.error) } else { throw new Error("No checkout URL received from server") } } catch (error) { console.error("[v0] Error in donation process:", error) let errorMessage = "Unknown error occurred" if (error instanceof Error) { errorMessage = error.message } alert(`Error processing donation: ${errorMessage}`) } } const formatPrice = (price: number | null, currency: string) => { if (!price) return "Contact for pricing" return new Intl.NumberFormat("en-CA", { style: "currency", currency: currency.toUpperCase(), }).format(price / 100) } const getSponsorTierInfo = (index: number) => { const tiers = [ { name: "Copper", color: "orange", bgGradient: "from-white to-orange-50", borderColor: "orange-300", buttonColor: "orange-600", }, { name: "Bronze", color: "amber", bgGradient: "from-white to-amber-50", borderColor: "amber-400", buttonColor: "amber-600", }, { name: "Silver", color: "gray", bgGradient: "from-white to-gray-50", borderColor: "gray-400", buttonColor: "gray-600", }, { name: "Gold", color: "yellow", bgGradient: "from-white to-yellow-50", borderColor: "yellow-400", buttonColor: "yellow-600", }, ] return tiers[index] || tiers[0] } const getSponsorImage = (index: number) => { const images = [ "/images/copper-sponsor.avif", "/images/gold-sponsor.avif", "/images/silver-sponsor.avif", "/images/bronze-sponsor.avif", ] return images[index] || images[0] } const getSponsorCardClasses = (index: number) => { const cardClasses = [ { card: "text-center hover:shadow-xl transition-all duration-300 border-2 hover:border-orange-300 bg-gradient-to-b from-white to-orange-50", title: "text-xl font-bold text-orange-600 mb-3", }, { card: "text-center hover:shadow-xl transition-all duration-300 border-2 hover:border-amber-400 bg-gradient-to-b from-white to-amber-50", title: "text-xl font-bold text-amber-600 mb-3", }, { card: "text-center hover:shadow-xl transition-all duration-300 border-2 hover:border-gray-400 bg-gradient-to-b from-white to-gray-50", title: "text-xl font-bold text-gray-600 mb-3", }, { card: "text-center hover:shadow-xl transition-all duration-300 border-2 hover:border-yellow-400 bg-gradient-to-b from-white to-yellow-50", title: "text-xl font-bold text-yellow-600 mb-3", }, ] return cardClasses[index] || cardClasses[0] } return (
{/* Header */}

Welcome to

AlertBayTrumpeter.com!

{/* Navigation */}
{/* Hero Section */}
Jerry Higginson on boat with Alert Bay Trumpeter flag
{/* Jerry's Story Section */}

The Story of Jerry Higginson, the Alert Bay Trumpeter

Over 1000 nautical serenades to cruise ship passengers since 1996

If you've ever cruised through the Johnstone Straits of northern Vancouver Island, you've probably met Jerry Higginson. Jerry has been energetically entertaining passengers of his hometown of Alert Bay for over 27 years, to the delight of millions.

Donate to support Jerry's mission to spread smiles at sea!

{/* Support Musicians Section */}

Support Independent Artists at Sea!

Donations to the Alert Bay Trumpeter go to support Jerry in his mission to spread smiles at sea by serenading cruise ship passengers with his trumpet.

{/* Sponsor Cards */}
{loading ? (

Loading sponsorship options...

) : error ? (

Error loading sponsorship options: {error}

) : subscriptionProducts.length === 0 ? (

No sponsorship options available at this time.

) : ( subscriptionProducts.slice(0, 4).map((product, index) => { const cardClasses = getSponsorCardClasses(index) return (
{`${product.name}

{product.name}

{formatPrice(product.price, product.currency)}/month

{product.description &&

{product.description}

}
) }) )}
{/* Videos Section */}

All Videos

{/* Listen to Jerry Section */}

Listen to Jerry Singing with the Eagles

Jerry and his eagle friend have been flying and singing together for years.

{/* Art Collection Call-to-Action Section */}

Buy Traditional Indigenous Artwork

Explore Jerry's beautiful collection of traditional Indigenous masks and artwork, each piece telling a story of cultural heritage and artistic mastery.

Traditional Indigenous masks with cedar bark fringe
{/* Footer with Jerry's Contact Information */}
) }