import { format } from "date-fns"; import { useTranslation } from "next-i18next"; import * as React from "react"; import { ScoreSummary } from "../poll/score-summary"; import UserAvatar from "../poll/user-avatar"; import VoteIcon from "../poll/vote-icon"; const sidebarWidth = 180; const participants = [ { name: "Reed", color: "bg-sky-400", votes: [0, 2], }, { name: "Susan", color: "bg-blue-400", votes: [0, 1, 2], }, { name: "Johnny", color: "bg-primary-400", votes: [2, 3], }, { name: "Ben", color: "bg-purple-400", votes: [0, 1, 2, 3], }, ]; const options = ["2022-12-14", "2022-12-15", "2022-12-16", "2022-12-17"]; const PollDemo: React.VoidFunctionComponent = () => { const { t } = useTranslation("app"); return (
{t("participantCount", { count: participants.length })}
{options.map((option, i) => { const d = new Date(option); let score = 0; participants.forEach((participant) => { if (participant.votes.includes(i)) { score++; } }); return (
{format(d, "E")}
{format(d, "dd")}
{format(d, "MMM")}
); })}
{participants.map((participant, i) => (
{options.map((_, i) => { return (
{participant.votes.some((vote) => vote === i) ? ( ) : ( )}
); })}
))}
); }; export default PollDemo;