"use client"; import { useEffect, useState } from "react"; import { useParams } from "next/navigation"; import Link from "next/link"; import { motion } from "framer-motion"; import ProductCard from "@/components/storefront/ProductCard"; import StopSetEffect from "@/components/storefront/StopSetEffect"; import StorefrontHeader from "@/components/storefront/StorefrontHeader"; import StorefrontFooter from "@/components/storefront/StorefrontFooter"; import LayoutContainer from "@/components/layout/LayoutContainer"; import { supabase } from "@/lib/supabase"; import { formatDate } from "@/lib/format-date"; type Product = { id: string; name: string; description: string | null; price: number; type: string; image_url: string | null; brand_id: string; is_taxable?: boolean; pickup_type?: "scheduled_stop" | "shed"; }; type Stop = { id: string; city: string; state: string; date: string; time: string; location: string; brand_id: string; }; export default function StopPage() { const params = useParams(); const slug = params.slug as string; const [stop, setStop] = useState<{ id: string; city: string; state: string; date: string; time: string; location: string; brand_id: string; } | null>(null); const [products, setProducts] = useState([]); const [brandSlug, setBrandSlug] = useState("indian-river-direct"); const [brandAccent, setBrandAccent] = useState<"green" | "orange" | "blue">("blue"); useEffect(() => { async function load() { const { data: stopData } = await supabase .from("stops") .select("*") .eq("slug", slug) .eq("active", true) .single() as unknown as { data: Stop | null }; if (!stopData) return; setStop(stopData); const isIndian = slug.includes("indian"); setBrandSlug(isIndian ? "indian-river-direct" : "tuxedo"); setBrandAccent(isIndian ? "blue" : "green"); const { data: productsData } = await supabase .from("products") .select("*") .eq("brand_id", stopData.brand_id) .eq("active", true) as unknown as { data: Product[] | null }; setProducts(productsData ?? []); } load(); }, [slug]); if (!stop) { return (
); } const isBlue = brandAccent === "blue"; const brandLabel = isBlue ? "Indian River Direct" : "Tuxedo Corn"; return (
{/* Back navigation */} All Stops / {stop.city}, {stop.state} {/* Stop header with animation */}

{isBlue ? "Indian River Direct" : "Tuxedo Corn"}

{stop.city},
{stop.state}

{isBlue ? "Order fresh Florida citrus for pickup at this stop." : "Order fresh Olathe Sweet™ sweet corn for pickup at this stop."}

{/* Stop info */}
{/* Date */}

Date

{formatDate(stop.date)}

{/* Time */}

Time

{stop.time}

{/* Location */}

Location

{stop.location}

{/* Available Products — editorial header */}

Farm-Direct

Available Products

Preorder for pickup — add items below and we will have them ready at the stop.

{products.length === 0 ? (

No products available for this stop.

) : (
{products.map((product) => ( ))}
)}
); }