"use client"; import { useEffect, useState } from "react"; interface Webinar { id: string; title: string; description: string; speaker: string; startAt: string; duration: number; bannerUrl?: string; category: string; capacity: number; priceCents: number; } interface RegistrationItem { webinarId: string; registeredAt: string; webinar: { startAt: string; }; } function formatDate(dateString: string) { const date = new Date(dateString); return date.toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric", hour: "2-digit", minute: "2-digit", }); } export default function WebinarsPage() { const [webinars, setWebinars] = useState([]); const [loading, setLoading] = useState(true); const [registeredMap, setRegisteredMap] = useState>({}); useEffect(() => { async function fetchWebinars() { try { const [webinarsRes, registrationsRes] = await Promise.all([ fetch("/api/webinars?limit=50"), fetch("/api/account/webinars"), ]); const webinarsData = await webinarsRes.json(); setWebinars(webinarsData.webinars || []); if (registrationsRes.ok) { const registrationsData = await registrationsRes.json(); const nextMap: Record = {}; (registrationsData.registrations || []).forEach((reg: RegistrationItem) => { nextMap[reg.webinarId] = { registeredAt: reg.registeredAt, startAt: reg.webinar?.startAt, }; }); setRegisteredMap(nextMap); } } catch (error) { console.error("Failed to fetch webinars:", error); } finally { setLoading(false); } } fetchWebinars(); }, []); if (loading) { return (

Estate Planning Academy

Professional Webinars, Clear Outcomes

Curated sessions built by attorneys and planners to help you protect wealth, reduce tax exposure, and plan with confidence.

{[ { label: "Expert Sessions", value: "40+" }, { label: "Live Each Month", value: "8" }, { label: "Average Rating", value: "4.9" }, ].map((stat) => (
{stat.value}

{stat.label}

))}
Loading webinars...
); } return (

Estate Planning Academy

Professional Webinars, Clear Outcomes

Curated sessions built by attorneys and planners to help you protect wealth, reduce tax exposure, and plan with confidence.

Quick stats

Expert Sessions 40+
Live Each Month 8
Average Rating 4.9
{webinars.length === 0 ? (
No webinars available at the moment.
) : (
{webinars.map((webinar) => { const registration = registeredMap[webinar.id]; const isRegistered = Boolean(registration); const startAt = new Date(webinar.startAt); const isPast = startAt.getTime() < Date.now(); return (
{webinar.bannerUrl ? ( {webinar.title} ) : (
Webinar preview
)}
{webinar.category} {webinar.priceCents === 0 ? ( Free ) : null}
{isRegistered && (
{isPast ? "Completed" : "Registered"}
)}

{webinar.title}

{webinar.priceCents > 0 && ( ${(webinar.priceCents / 100).toFixed(2)} )}

{webinar.description}

🎤 {webinar.speaker}
📅 {formatDate(webinar.startAt)}
⏱️ {webinar.duration} min
👥 {webinar.capacity} seats
{isPast ? "Past session" : "Upcoming"} View details
); })}
)}
); }