Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,17 @@ const SendEmailDialog = ({open, onClose, onSubmit, targetedEmail=undefined, elec
}))
}

// The backend re-queries the roll when it sends, so this count has to be of
// the same thing it will find. The roll is refetched when the dialog is
// opened; before that fix the button could offer to send to voters who had
// already voted since the page was loaded (#1287).
const getVoterCount = () => {
if(!electionRoll) return 0;
if(audience == 'single') return 1;
if(audience == 'all') return electionRoll.length;
if(audience == 'has_voted') return electionRoll.filter(roll => roll.submitted).length
if(audience == 'has_not_voted') return electionRoll.filter(roll => !roll.submitted).length
return 0;
}

const warning: string = (() => {
Expand Down Expand Up @@ -174,7 +179,7 @@ const SendEmailDialog = ({open, onClose, onSubmit, targetedEmail=undefined, elec
</Alert>}
<Box sx={{ display: "flex", flexDirection: "row-reverse", gap: 2 }}>
<PrimaryButton
disabled={!templateChosen}
disabled={!templateChosen || getVoterCount() === 0}
onClick={() => {
setTemplateChosen(false)
onSubmit({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ const ViewElectionRolls = () => {
</PermissionHandler>
}
{usesEmail &&
<SecondaryButton onClick={() => setDialogOpen(true)} sx={{ml: 2}}>Draft Email Blast</SecondaryButton>
<SecondaryButton onClick={() => { fetchRolls(); setDialogOpen(true); }} sx={{ml: 2}}>Draft Email Blast</SecondaryButton>
}
{canClearRolls &&
<PermissionHandler permissions={permissions} requiredPermission={'canAddToElectionRoll'}>
Expand Down
Loading