1+ import CircularProgress from 'material-ui/CircularProgress' ;
12import moment from 'moment' ;
23import React from 'react' ;
34import styled from 'styled-components' ;
45
56import { Button } from 'ts/components/button' ;
67import { ChangePoolDialog } from 'ts/components/staking/change_pool_dialog' ;
8+ import { ErrorButton } from 'ts/components/staking/wizard/wizard_flow' ;
79import { generateUniqueId , Jazzicon } from 'ts/components/ui/jazzicon' ;
10+ import { UseStakeHookResult } from 'ts/hooks/use_stake' ;
811import { colors } from 'ts/style/colors' ;
9- import { PoolWithStats } from 'ts/types' ;
12+ import { PoolWithStats , TransactionLoadingState } from 'ts/types' ;
1013import { DEFAULT_POOL_ID } from 'ts/utils/configs' ;
1114
1215interface IVotingPowerInputProps {
@@ -20,6 +23,8 @@ interface IVotingPowerInputProps {
2023
2124interface IRegistrationSuccess {
2225 nextEpochStart : Date ;
26+ stake : UseStakeHookResult ;
27+ retryFlowZRXAmount : number ;
2328}
2429
2530const ConnectWalletButton = styled ( Button ) `` ;
@@ -270,23 +275,53 @@ const MessageList = styled.ul`
270275 }
271276` ;
272277
273- export const RegistrationSuccess : React . FC < IRegistrationSuccess > = ( { nextEpochStart } ) => {
278+ const LoaderWrapper = styled . div `
279+ display: flex;
280+ align-items: center;
281+ justify-content: center;
282+ ` ;
283+
284+ export const RegistrationSuccess : React . FC < IRegistrationSuccess > = ( { nextEpochStart, stake, retryFlowZRXAmount } ) => {
274285 const nextEpochMoment = moment ( nextEpochStart ) ;
275286 const todayMoment = moment ( ) ;
276287 const daysToNextEpoch = nextEpochMoment . diff ( todayMoment , 'days' ) ;
277288 return (
278289 < SuccessContainer >
279- < Header > Your voting power is now registered</ Header >
280- < MessageList >
281- < li >
282- < strong > Your tokens are now locked.</ strong >
283- Unlocking will be available in { daysToNextEpoch } days
284- </ li >
285- < li >
286- < strong > Additional tip</ strong >
287- Unlocking will be available in { daysToNextEpoch } days
288- </ li >
289- </ MessageList >
290+ { stake . loadingState === TransactionLoadingState . Success ? (
291+ < >
292+ < Header > Your voting power is now registered</ Header >
293+ < MessageList >
294+ < li >
295+ < strong > Your tokens are now locked.</ strong >
296+ Unlocking will be available in { daysToNextEpoch } days
297+ </ li >
298+ < li >
299+ < strong > Additional tip</ strong >
300+ Unlocking will be available in { daysToNextEpoch } days
301+ </ li >
302+ </ MessageList >
303+ </ >
304+ ) : stake . loadingState === TransactionLoadingState . Failed ? (
305+ < ErrorButton
306+ message = { 'Transaction aborted' }
307+ secondaryButtonText = { 'Retry' }
308+ onClose = { ( ) => {
309+ /*noop*/
310+ } }
311+ onSecondaryClick = { ( ) =>
312+ stake . depositAndStake ( [
313+ {
314+ poolId : DEFAULT_POOL_ID ,
315+ zrxAmount : retryFlowZRXAmount ,
316+ } ,
317+ ] )
318+ }
319+ />
320+ ) : (
321+ < LoaderWrapper >
322+ < CircularProgress size = { 40 } thickness = { 2 } color = { colors . brandLight } />
323+ </ LoaderWrapper >
324+ ) }
290325 </ SuccessContainer >
291326 ) ;
292327} ;
0 commit comments