"use client"; import { useState, useEffect, useCallback } from "react"; import { SectionHeading } from "@/components/ui/SectionHeading"; import { Reveal } from "@/components/ui/Reveal"; import { TeamCarousel } from "@/components/sections/team/TeamCarousel"; import { TeamMemberInfo } from "@/components/sections/team/TeamMemberInfo"; import { TeamProfile } from "@/components/sections/team/TeamProfile"; import type { SiteContent, ScheduleLocation } from "@/types/content"; interface TeamProps { data: SiteContent["team"]; schedule?: ScheduleLocation[]; } export function Team({ data: team, schedule }: TeamProps) { const [activeIndex, setActiveIndex] = useState(0); const [showProfile, setShowProfile] = useState(false); const openTrainerByName = useCallback((name: string) => { const idx = team.members.findIndex((m) => m.name === name); if (idx >= 0) { setActiveIndex(idx); setShowProfile(true); setTimeout(() => { const el = document.getElementById("team"); if (el) el.scrollIntoView({ behavior: "smooth", block: "start" }); }, 50); } }, [team.members]); useEffect(() => { function handler(e: Event) { const name = (e as CustomEvent).detail; if (name) openTrainerByName(name); } window.addEventListener("openTrainerProfile", handler); return () => window.removeEventListener("openTrainerProfile", handler); }, [openTrainerByName]); return (
{/* Stage spotlight glow */}
{team.title}
{!showProfile ? ( <>
setShowProfile(true)} />
) : ( setShowProfile(false)} schedule={schedule} /> )}
); }