"use client"; import Link from "next/link"; import { useEffect, useState } from "react"; export default function UpcomingWebinars() { const [data, setData] = useState(null); const [categories, setCategories] = useState([]); const [active, setActive] = useState("All"); useEffect(() => { fetch("/api/public/app-setup") .then((r) => r.json()) .then((d) => setCategories(["All", ...(d?.setup?.categories || [])])) .catch(() => setCategories(["All"])); }, []); useEffect(() => { fetch("/api/webinars") .then((r) => r.json()) .then(setData) .catch(() => setData({ ok: false, message: "Something went wrong. Please contact the website owner." })); }, []); const webinars = data?.ok ? data.webinars : []; const filtered = active === "All" ? webinars : webinars.filter((w: any) => w.category === active); return (
{/* Header */}

📚 Upcoming Webinars

Register now to secure your spot in our expert-led sessions

{/* Category Filter */}
{categories.map((c) => ( ))}
{/* Webinars Table */}
📝 Webinar
📅 Date & Time
👨‍🏫 Instructor
💰 Price
{!data ? (
Loading webinars...
) : !data.ok ? (
{data.message}
) : filtered.length === 0 ? (
No webinars found in this category
) : ( filtered.map((w: any) => (
{/* Webinar Title & Tags */}
{w.title}
{w.priceCents <= 0 ? "✨ FREE" : "⭐ PREMIUM"} {w.category}
{/* Date & Time */}
{new Date(w.startAt).toLocaleDateString()}
{new Date(w.startAt).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}
{/* Instructor */}
{w.speaker}
{/* Price & Button */}
{w.priceCents <= 0 ? "FREE" : `$${(w.priceCents / 100).toFixed(0)}`}
{w.priceCents <= 0 ? "🎓 Register" : "💳 Purchase"}
)) )}
{/* View All Link */}
🔗 View All Webinars
); }