import { useState } from "react"; import { ChevronDown, ChevronUp } from "lucide-react"; import { Link } from "react-router-dom"; import { useSessionQuizPollsRtdb } from "../hooks/useSessionQuizPollsRtdb"; function typeBadgeClass(type: string): string { const t = type.toLowerCase(); if (t === "poll") return "bg-[#eaddff]"; if (t === "survey") return "bg-[#e5e5ea]"; return "bg-[#ebffee]"; } function typeLabel(type: string): string { const t = type.toLowerCase(); if (t === "poll") return "Poll"; if (t === "survey") return "Survey"; return "Quiz"; } function actionLabel(type: string): string { const t = type.toLowerCase(); if (t === "poll") return "Take Poll"; if (t === "survey") return "Take Survey"; return "Take Quiz"; } type SessionQuizPollsSectionProps = { eventId: string; sessionId: string; }; export function SessionQuizPollsSection({ eventId, sessionId }: SessionQuizPollsSectionProps) { const [open, setOpen] = useState(true); const { items, loading, error } = useSessionQuizPollsRtdb(sessionId); const eid = eventId.trim(); const sid = sessionId.trim(); const live = Boolean(eid && sid); const takeHref = (quizPollId: string) => `/quiz-poll?${new URLSearchParams({ event_id: eid, session_id: sid, quiz_poll_id: quizPollId, }).toString()}`; return (
{open ? (
{!live ? (

Join a session to see quizzes.

) : error ? (

{error}

) : loading ? (

Loading quizzes…

) : items.length === 0 ? (

No live quizzes or polls right now.

) : ( )}
) : null}
); }