-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: voting power delegation confirmation dialog
- Loading branch information
Szymon Masłowski
committed
Nov 15, 2024
1 parent
b205fce
commit c47c9b1
Showing
4 changed files
with
189 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
...derer/app/components/voting/voting-governance/VotingPowerDelegationConfirmationDialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import React, { useState } from 'react'; | ||
import BigNumber from 'bignumber.js'; | ||
import { Input } from 'react-polymorph/lib/components/Input'; | ||
import { InputSkin } from 'react-polymorph/lib/skins/simple/InputSkin'; | ||
import { noop } from 'lodash'; | ||
import Dialog from '../../widgets/Dialog'; | ||
import DialogCloseButton from '../../widgets/DialogCloseButton'; | ||
import { formattedWalletAmount } from '../../../utils/formatters'; | ||
import Wallet from '../../../domains/Wallet'; | ||
|
||
type VotingPowerDelegationConfirmationDialogProps = { | ||
fees: BigNumber; | ||
onClose: () => void; | ||
onConfirm: (passphrase: string) => void; | ||
selectedWallet: Wallet; | ||
vote: string; | ||
}; | ||
|
||
type State = 'Awaiting' | 'Submitting'; | ||
|
||
export function VotingPowerDelegationConfirmationDialog({ | ||
fees, | ||
onClose, | ||
onConfirm, | ||
selectedWallet, | ||
vote, | ||
}: VotingPowerDelegationConfirmationDialogProps) { | ||
const [state, setState] = useState<State>(); | ||
const [passphrase, setPassphrase] = useState(''); | ||
|
||
const handleClose = state === 'Submitting' ? noop : onClose; | ||
|
||
const handleConfirm = | ||
state === 'Submitting' | ||
? noop | ||
: () => { | ||
setState('Submitting'); | ||
onConfirm(passphrase); | ||
}; | ||
|
||
return ( | ||
<Dialog | ||
title={'Confirm transaction'} | ||
actions={[ | ||
{ | ||
label: 'Cancel', | ||
onClick: handleClose, | ||
disabled: state === 'Submitting', | ||
}, | ||
{ | ||
label: 'Confirm', | ||
onClick: handleConfirm, | ||
primary: true, | ||
disabled: state === 'Submitting', | ||
}, | ||
]} | ||
onClose={handleClose} | ||
closeButton={<DialogCloseButton onClose={handleClose} />} | ||
> | ||
<h4>Vote</h4> | ||
<br /> | ||
{vote} | ||
<br /> | ||
<br /> | ||
|
||
<h4>Average fees</h4> | ||
<br /> | ||
{formattedWalletAmount(fees, false)} | ||
<br /> | ||
<br /> | ||
|
||
{selectedWallet.isHardwareWallet ? ( | ||
<div>{'TODO <HardwareWalletStatus />'}</div> | ||
) : ( | ||
<Input | ||
value={passphrase} | ||
onChange={(value) => setPassphrase(value)} | ||
type={'password'} | ||
label={'Type your password'} | ||
skin={InputSkin} | ||
/> | ||
)} | ||
</Dialog> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters