{
//submit
updatePollMutation(data, { onSuccess: closePollDetailsModal });
}}
/>
),
});
return (
{changeOptionsModalContextHolder}
{changePollDetailsModalContextHolder}
{resetModalContext}
}>Manage}
>
{
const header = [
t("participantCount", {
count: poll.participants.length,
}),
...poll.options.map((option) => {
const decodedOption = decodeDateOption(
option.value,
poll.timeZone,
targetTimeZone,
);
const day = `${decodedOption.dow} ${decodedOption.day} ${decodedOption.month}`;
return decodedOption.type === "date"
? day
: `${day} ${decodedOption.startTime} - ${decodedOption.endTime}`;
}),
].join(",");
const rows = poll.participants.map((participant) => {
return [
participant.name,
...poll.options.map((option) => {
if (
participant.votes.some((vote) => {
return vote.optionId === option.id;
})
) {
return "Yes";
}
return "No";
}),
].join(",");
});
const csv = `data:text/csv;charset=utf-8,${[header, ...rows].join(
"\r\n",
)}`;
const encodedCsv = encodeURI(csv);
var link = document.createElement("a");
link.setAttribute("href", encodedCsv);
link.setAttribute(
"download",
`${poll.title.replace(/\s/g, "_")}-${format(
Date.now(),
"yyyyMMddhhmm",
)}`,
);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}}
/>
{poll.closed ? (
updatePollMutation({ closed: false })}
/>
) : (
updatePollMutation({ closed: true })}
/>
)}
{poll.legacy ? (
{
openResetModal();
}}
/>
) : null}
);
};
export default ManagePoll;