mirror of
https://github.com/lukevella/rallly.git
synced 2025-05-10 23:46:49 +02:00
Desktop poll code clean up and refinements (#120)
This commit is contained in:
parent
8cd1db41db
commit
00b72d01bf
11 changed files with 160 additions and 146 deletions
|
@ -18,6 +18,7 @@ type PollContextValue = {
|
|||
targetTimeZone: string;
|
||||
setTargetTimeZone: (timeZone: string) => void;
|
||||
pollType: "date" | "timeSlot";
|
||||
highScore: number;
|
||||
getParticipantsWhoVotedForOption: (optionId: string) => Participant[]; // maybe just attach votes to parsed options
|
||||
getParticipantById: (
|
||||
participantId: string,
|
||||
|
@ -60,6 +61,13 @@ export const PollContextProvider: React.VoidFunctionComponent<{
|
|||
}, [participantById, poll.options]);
|
||||
|
||||
const contextValue = React.useMemo<PollContextValue>(() => {
|
||||
let highScore = 1;
|
||||
poll.options.forEach((option) => {
|
||||
if (option.votes.length > highScore) {
|
||||
highScore = option.votes.length;
|
||||
}
|
||||
});
|
||||
|
||||
const parsedOptions = decodeOptions(
|
||||
poll.options,
|
||||
poll.timeZone,
|
||||
|
@ -84,6 +92,7 @@ export const PollContextProvider: React.VoidFunctionComponent<{
|
|||
getParticipantById: (participantId) => {
|
||||
return participantById[participantId];
|
||||
},
|
||||
highScore,
|
||||
getParticipantsWhoVotedForOption: (optionId: string) =>
|
||||
participantsByOptionId[optionId],
|
||||
getVote: (participantId, optionId) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue