App.PollList = function PollList() {
const [polls, setPolls] = React.useState([]);
const [loading, setLoading] = React.useState(true);
const loadPolls = () => {
setLoading(true);
App.API.get('polls?fingerprint=' + App.fingerprint).then(data => {
setPolls(data);
setLoading(false);
});
};
React.useEffect(() => { loadPolls(); }, []);
const handleDelete = (shareCode, title) => {
if (!confirm('Delete poll "' + title + '"? All votes will be lost.')) return;
App.API.post('polls/' + shareCode, {
_action: 'delete',
fingerprint: App.fingerprint,
})
.then(() => loadPolls())
.catch(err => alert(err.message));
};
if (loading) return
Active polls for voting on race combinations
{polls.length === 0 ? (No active polls yet.
Create Poll