import dayjs from "dayjs"; import { MapPinIcon, MousePointerClickIcon, TextIcon } from "lucide-react"; import { useTranslation } from "next-i18next"; import { Card } from "@/components/card"; import { DateIcon } from "@/components/date-icon"; import { ParticipantAvatarBar } from "@/components/participant-avatar-bar"; import { useParticipants } from "@/components/participants-provider"; import { PollStatusBadge } from "@/components/poll-status"; import { Trans } from "@/components/trans"; import { IfParticipantsVisible } from "@/components/visibility"; import { usePoll } from "@/contexts/poll"; import { generateGradient } from "@/utils/color-hash"; import { useDayjs } from "@/utils/dayjs"; import { preventWidows } from "@/utils/prevent-widows"; import PollSubheader from "./poll/poll-subheader"; import TruncatedLinkify from "./poll/truncated-linkify"; import VoteIcon from "./poll/vote-icon"; export const EventCard = () => { const { t } = useTranslation(); const poll = usePoll(); const { participants } = useParticipants(); const { adjustTimeZone } = useDayjs(); const attendees = participants.filter((participant) => participant.votes.some( (vote) => vote.optionId === poll?.event?.optionId && (vote.type === "yes" || vote.type === "ifNeedBe"), ), ); const status = poll?.event ? "closed" : poll?.closed ? "paused" : "live"; if (!poll) { return null; } return (
{poll.event ? (
) : null}
{poll.event ? (
{poll.event.duration === 0 ? adjustTimeZone(poll.event.start, !poll.timeZone).format( "LL", ) : `${adjustTimeZone( poll.event.start, !poll.timeZone, ).format("LL LT")} - ${adjustTimeZone( dayjs(poll.event.start).add( poll.event.duration, "minutes", ), !poll.timeZone, ).format("LT")}`}
) : null}

{preventWidows(poll.title)}

{!poll.event ? ( ) : (
)}
{poll.description ? (
{poll.description}
) : null} {poll.location ? (
{poll.location}
) : null}
{t("yes")} {t("ifNeedBe")} {t("no")}
); };