11// @flow
2- import React , { Component } from 'react' ;
2+ import React , { Component , Fragment } from 'react' ;
33import { bindActionCreators , compose } from 'redux' ;
44import { connect } from 'react-redux' ;
55import styled from 'styled-components' ;
@@ -23,7 +23,7 @@ import {
2323type Props = {
2424 selectedAccountHash ?: string ,
2525 selectedParentHash ?: string ,
26- address ?: string ,
26+ address ?: string | null ,
2727 delegate ?: ( ) => { } ,
2828 fetchDelegationAverageFees : ( ) => { } ,
2929 getIsReveal : ( ) => { } ,
@@ -108,24 +108,6 @@ const SetADelegate = styled.div`
108108 margin-bottom: 14px;
109109 color: ${ ( { theme : { colors } } ) => colors . black2 } ;
110110` ;
111- const WarningContainer = styled . div `
112- height: 91px;
113- width: 60%;
114- border: solid 1px rgba(148, 169, 209, 0.49);
115- border-radius: 3px;
116- background-color: ${ ( { theme : { colors } } ) => colors . light } ;
117- display: flex;
118- align-items: center;
119- padding: 0 19px;
120- margin-right: 5%;
121- ` ;
122- const InfoText = styled . div `
123- color: ${ ( { theme : { colors } } ) => colors . primary } ;
124- font-size: 16px;
125- letter-spacing: 0.7px;
126- margin-left: 11px;
127- line-height: 21px;
128- ` ;
129111
130112const initialState = {
131113 open : false ,
@@ -200,12 +182,6 @@ class Delegate extends Component<Props> {
200182 handleFeeChange = fee => this . setState ( { fee } ) ;
201183 setIsLoading = isLoading => this . setState ( { isLoading } ) ;
202184
203- getAddress = ( ) => {
204- const { tempAddress } = this . state ;
205- const { address } = this . props ;
206- return tempAddress || address ;
207- } ;
208-
209185 onDelegate = async ( ) => {
210186 const { password, fee, tempAddress } = this . state ;
211187 const {
@@ -287,33 +263,29 @@ class Delegate extends Component<Props> {
287263 < Container >
288264 < Title > { t ( 'components.delegate.delegate_settings' ) } </ Title >
289265 < DelegateContainer >
290- { address && (
291- < DelegateInputContainer >
292- < SetADelegate >
293- { t ( 'components.delegate.current_delegate' ) } :
294- </ SetADelegate >
295- < TezosAddress
296- address = { address }
297- size = "16px"
298- color = "primary"
299- color2 = "index0"
300- />
301- < UpdateButton
302- disabled = { isLoading }
303- onClick = { this . openConfirmation }
304- buttonTheme = "secondary"
305- small
306- >
307- { t ( 'components.delegate.change_delegate' ) }
308- </ UpdateButton >
309- </ DelegateInputContainer >
310- ) }
311- { ! address && (
312- < WarningContainer >
313- < TezosIcon iconName = "info" size = { ms ( 5 ) } color = "info" />
314- < InfoText > { t ( 'components.delegate.delegate_warning' ) } </ InfoText >
315- </ WarningContainer >
316- ) }
266+ < DelegateInputContainer >
267+ { ! ! address && (
268+ < Fragment >
269+ < SetADelegate >
270+ { t ( 'components.delegate.current_delegate' ) } :
271+ </ SetADelegate >
272+ < TezosAddress
273+ address = { address }
274+ size = "16px"
275+ color = "primary"
276+ color2 = "index0"
277+ />
278+ </ Fragment >
279+ ) }
280+ < UpdateButton
281+ disabled = { isLoading }
282+ onClick = { this . openConfirmation }
283+ buttonTheme = "secondary"
284+ small
285+ >
286+ { t ( 'components.delegate.change_delegate' ) }
287+ </ UpdateButton >
288+ </ DelegateInputContainer >
317289 < DelegationTipsContainer >
318290 < DelegationTitle >
319291 { t ( 'components.addressBlock.delegation_tips' ) }
@@ -359,6 +331,10 @@ class Delegate extends Component<Props> {
359331 }
360332}
361333
334+ Delegate . defaultProps = {
335+ address : ''
336+ } ;
337+
362338function mapStateToProps ( state ) {
363339 return {
364340 isLedger : getIsLedger ( state )
0 commit comments