mirror of https://github.com/certusone/oyster.git
fix: fix vote refund and token withdrawal messages
This commit is contained in:
parent
af2969ea35
commit
e6a6122142
|
@ -12,7 +12,11 @@ import {
|
|||
actions,
|
||||
} from '@oyster/common';
|
||||
|
||||
import { TimelockSet, TimelockState } from '../models/timelock';
|
||||
import {
|
||||
TimelockSet,
|
||||
TimelockState,
|
||||
TimelockStateStatus,
|
||||
} from '../models/timelock';
|
||||
import { AccountLayout } from '@solana/spl-token';
|
||||
import { withdrawVotingTokensInstruction } from '../models/withdrawVotingTokens';
|
||||
import { LABELS } from '../constants';
|
||||
|
@ -141,8 +145,13 @@ export const withdrawVotingTokens = async (
|
|||
),
|
||||
);
|
||||
|
||||
const [msg, completedMsg] =
|
||||
state.info.status === TimelockStateStatus.Voting
|
||||
? [LABELS.WITHDRAWING_YOUR_VOTE, LABELS.VOTE_WITHDRAWN]
|
||||
: [LABELS.REFUNDING_YOUR_TOKENS, LABELS.TOKENS_REFUNDED];
|
||||
|
||||
notify({
|
||||
message: LABELS.WITHDRAWING_VOTING_TOKENS,
|
||||
message: msg,
|
||||
description: LABELS.PLEASE_WAIT,
|
||||
type: 'warn',
|
||||
});
|
||||
|
@ -157,7 +166,7 @@ export const withdrawVotingTokens = async (
|
|||
);
|
||||
|
||||
notify({
|
||||
message: LABELS.TOKENS_WITHDRAWN,
|
||||
message: completedMsg,
|
||||
type: 'success',
|
||||
description: LABELS.TRANSACTION + ` ${tx}`,
|
||||
});
|
||||
|
|
|
@ -10,11 +10,7 @@ import {
|
|||
import { LABELS } from '../../constants';
|
||||
import { depositSourceTokensAndVote } from '../../actions/depositSourceTokensAndVote';
|
||||
import { contexts, hooks } from '@oyster/common';
|
||||
import {
|
||||
ExclamationCircleOutlined,
|
||||
CheckOutlined,
|
||||
CloseOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import { CheckOutlined, CloseOutlined } from '@ant-design/icons';
|
||||
|
||||
import './style.less';
|
||||
|
||||
|
|
|
@ -40,23 +40,41 @@ export function WithdrawVote({
|
|||
((noVoteAccount && noVoteAccount.info.amount.toNumber()) || 0);
|
||||
|
||||
const eligibleToView =
|
||||
votingTokens > 0 && state.info.status === TimelockStateStatus.Voting;
|
||||
votingTokens > 0 &&
|
||||
(state.info.status === TimelockStateStatus.Voting ||
|
||||
state.info.status === TimelockStateStatus.Completed ||
|
||||
state.info.status === TimelockStateStatus.Defeated);
|
||||
|
||||
const [btnLabel, title, msg, action] =
|
||||
state.info.status === TimelockStateStatus.Voting
|
||||
? [
|
||||
LABELS.WITHDRAW_VOTE,
|
||||
LABELS.WITHDRAW_YOUR_VOTE_QUESTION,
|
||||
LABELS.WITHDRAW_YOUR_VOTE_MSG,
|
||||
LABELS.WITHDRAW,
|
||||
]
|
||||
: [
|
||||
LABELS.REFUND_TOKENS,
|
||||
LABELS.REFUND_YOUR_TOKENS_QUESTION,
|
||||
LABELS.REFUND_YOUR_TOKENS_MSG,
|
||||
LABELS.REFUND,
|
||||
];
|
||||
|
||||
return eligibleToView ? (
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() =>
|
||||
confirm({
|
||||
title: LABELS.WITHDRAW_YOUR_VOTE_QUESTION,
|
||||
title: title,
|
||||
icon: <ExclamationCircleOutlined />,
|
||||
content: (
|
||||
<Row>
|
||||
<Col span={24}>
|
||||
<p>{LABELS.WITHDRAW_YOUR_VOTE_MSG}</p>
|
||||
<p>{msg}</p>
|
||||
</Col>
|
||||
</Row>
|
||||
),
|
||||
okText: LABELS.WITHDRAW,
|
||||
okText: action,
|
||||
cancelText: LABELS.CANCEL,
|
||||
onOk: async () => {
|
||||
if (userAccount) {
|
||||
|
@ -76,7 +94,7 @@ export function WithdrawVote({
|
|||
})
|
||||
}
|
||||
>
|
||||
{LABELS.WITHDRAW_VOTE}
|
||||
{btnLabel}
|
||||
</Button>
|
||||
) : null;
|
||||
}
|
||||
|
|
|
@ -64,31 +64,39 @@ export const LABELS = {
|
|||
VOTE_YEAH: 'Yeah',
|
||||
VOTE_YEAH_QUESTION: 'Vote Yeah?',
|
||||
VOTE_YEAH_MSG: 'Vote in favour of the proposal.',
|
||||
VOTING_YEAH: 'Voting for the proposal.',
|
||||
VOTED_YEAH: 'Voted for the proposal.',
|
||||
VOTING_YEAH: 'Voting for the proposal',
|
||||
VOTED_YEAH: 'Voted for the proposal',
|
||||
|
||||
VOTE_NAY: 'Nay',
|
||||
VOTE_NAY_QUESTION: 'Vote Nay?',
|
||||
VOTE_NAY_MSG: 'Vote against the proposal.',
|
||||
VOTING_NAY: 'Voting against the proposal.',
|
||||
VOTED_NAY: 'Voted against the proposal.',
|
||||
VOTING_NAY: 'Voting against the proposal',
|
||||
VOTED_NAY: 'Voted against the proposal',
|
||||
|
||||
TOKENS_VOTED_FOR_THE_PROPOSAL: 'tokens voted for the proposal',
|
||||
TOKENS_VOTED_AGAINST_THE_PROPOSAL: 'tokens voted against the proposal',
|
||||
|
||||
EXECUTING: 'Executing...',
|
||||
EXECUTED: 'Executed.',
|
||||
WITHDRAWING_VOTING_TOKENS: 'Refunding voting tokens as Source Tokens',
|
||||
TOKENS_WITHDRAWN: 'Voting tokens refunded as Source Tokens',
|
||||
|
||||
CONFIRM: 'Confirm',
|
||||
CANCEL: 'Cancel',
|
||||
|
||||
WITHDRAW_VOTE: 'Withdraw My Vote',
|
||||
WITHDRAW: 'Withdraw',
|
||||
|
||||
WITHDRAW_YOUR_VOTE_QUESTION: 'Withdraw your vote?',
|
||||
WITHDRAW_YOUR_VOTE_MSG:
|
||||
'Once you withdraw your vote it won’t count towards the proposal voting outcome.',
|
||||
WITHDRAW: 'Withdraw',
|
||||
WITHDRAWING_YOUR_VOTE: 'Withdrawing your vote',
|
||||
VOTE_WITHDRAWN: 'Your vote has been withdrawn',
|
||||
|
||||
REFUND_TOKENS: 'Refund My Tokens',
|
||||
REFUND_YOUR_TOKENS_QUESTION: 'Refund your tokens?',
|
||||
REFUND_YOUR_TOKENS_MSG:
|
||||
'The proposal has been voted. Refunding your tokens won’t change the outcome.',
|
||||
REFUND: 'Refund',
|
||||
REFUNDING_YOUR_TOKENS: 'Refunding your tokens',
|
||||
TOKENS_REFUNDED: 'Your voting tokens have been refunded',
|
||||
|
||||
REGISTER_GOVERNANCE: 'Register',
|
||||
PROGRAM: 'Program ID',
|
||||
|
|
Loading…
Reference in New Issue