Skip to content

Commit

Permalink
react-app: Handle remind to vote button for proposal vote list
Browse files Browse the repository at this point in the history
  • Loading branch information
Rico Wong committed Jun 30, 2022
1 parent a15ed44 commit 3980247
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import { useOutletContext, useSearchParams } from "react-router-dom";
import { toast } from "react-toastify";
import TallyResultIndicator from "../TallyResultIndicator/TallyResultIndicator";
import * as SectionedTable from "../SectionedTable/SectionedTable";
import { VoteOption } from "../../models/cosmos/gov";
import { ProposalStatus, VoteOption } from "../../models/cosmos/gov";
import LocalizedText from "../common/Localized/LocalizedText";
import {
isRequestStateError,
isRequestStateLoaded,
} from "../../models/RequestState";
import PageContoller from "../common/PageController/PageController";
import { useLocale } from "../../providers/AppLocaleProvider";
import AppButton from "../common/Buttons/AppButton";
import {
Proposal,
ProposalVote,
Expand Down Expand Up @@ -147,6 +148,33 @@ const ProposalVoteOption: React.FC<{ option: VoteOption | null }> = ({
}
};

const RemindToVoteButton: React.FC<{
proposal: Proposal;
vote: ProposalVote;
}> = ({ proposal, vote }) => {
if (
vote.option != null ||
vote.voter.__typename !== "Validator" ||
vote.voter.securityContact == null ||
proposal.status !== ProposalStatus.VotingPeriod
) {
return null;
}

const email: string = vote.voter.securityContact;

return (
<AppButton
type="anchor"
theme="secondary"
size="regular"
className={cn("border", "border-likecoin-grey")}
messageID="ProposalDetail.votes.remindToVote"
href={`mailto:${email}`}
/>
);
};

const ProposalVotesPanel: React.FC = () => {
const proposal = useOutletContext<Proposal>();
const { translate } = useLocale();
Expand Down Expand Up @@ -266,6 +294,12 @@ const ProposalVotesPanel: React.FC = () => {
>
{(item) => <ProposalVoteOption option={item.option ?? null} />}
</SectionedTable.Column>
<SectionedTable.Column<ProposalVote>
id="action"
className={cn("text-right")}
>
{(item) => <RemindToVoteButton proposal={proposal} vote={item} />}
</SectionedTable.Column>
</SectionedTable.Table>
<PageContoller
offsetBased={true}
Expand Down
1 change: 1 addition & 0 deletions react-app/src/i18n/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"ProposalDetail.votes.option": "Option",
"ProposalDetail.votes.option.notVoted": "Not Voted Yet",
"ProposalDetail.votes.others": "Others",
"ProposalDetail.votes.remindToVote": "Remind to vote",
"ProposalDetail.votes.requestState.error": "Failed to fetch proposal votes, please try again later.",
"ProposalDetail.votes.voter": "Voter",
"ProposalDetail.votes.voter.validator": "Validator",
Expand Down
1 change: 1 addition & 0 deletions react-app/src/i18n/translations/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"ProposalDetail.votes.option": "Option",
"ProposalDetail.votes.option.notVoted": "Not Voted Yet",
"ProposalDetail.votes.others": "Others",
"ProposalDetail.votes.remindToVote": "Remind to vote",
"ProposalDetail.votes.requestState.error": "Failed to fetch proposal votes, please try again later.",
"ProposalDetail.votes.voter": "Voter",
"ProposalDetail.votes.voter.validator": "Validator",
Expand Down

0 comments on commit 3980247

Please sign in to comment.