Skip to content

Commit c91d21e

Browse files
committed
Merge branch 'placeholder'
2 parents 68621ac + 5d1b53e commit c91d21e

File tree

1 file changed

+7
-14
lines changed
  • frontends/web/src/routes/account/add

1 file changed

+7
-14
lines changed

frontends/web/src/routes/account/add/add.tsx

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ interface State {
4545
step: TStep;
4646
supportedCoins: backendAPI.ICoin[];
4747
adding: boolean; // true while the backend is working to add the account.
48-
accountNamePlaceholder: string;
4948
}
5049

5150
class AddAccount extends Component<Props, State> {
@@ -57,7 +56,6 @@ class AddAccount extends Component<Props, State> {
5756
step: 'select-coin',
5857
supportedCoins: [],
5958
adding: false,
60-
accountNamePlaceholder: '',
6159
};
6260

6361
private onlyOneSupportedCoin = (): boolean => {
@@ -87,14 +85,9 @@ class AddAccount extends Component<Props, State> {
8785
}
8886
}
8987

90-
private accountName = (): string => {
91-
const { accountName, accountNamePlaceholder } = this.state;
92-
return accountName === '' ? accountNamePlaceholder : accountName;
93-
}
94-
9588
private next = (e: Event) => {
9689
e.preventDefault();
97-
const { accountCode, coinCode, step } = this.state;
90+
const { accountName, accountCode, coinCode, step } = this.state;
9891
const { t } = this.props;
9992
switch (step) {
10093
case 'select-coin':
@@ -110,7 +103,7 @@ class AddAccount extends Component<Props, State> {
110103
this.setState({ adding: true });
111104
apiPost('account-add', {
112105
coinCode,
113-
name: this.accountName(),
106+
name: accountName,
114107
})
115108
.then((data: ResponseData) => {
116109
this.setState({ adding: false });
@@ -162,12 +155,12 @@ class AddAccount extends Component<Props, State> {
162155

163156
private renderContent = () => {
164157
const { t } = this.props;
165-
const { accountName, accountNamePlaceholder, coinCode, step, supportedCoins} = this.state;
158+
const { accountName, coinCode, step, supportedCoins} = this.state;
166159
switch (step) {
167160
case 'select-coin':
168161
return (
169162
<CoinDropDown
170-
onChange={coin => this.setState({ coinCode: coin.coinCode, accountNamePlaceholder: coin.suggestedAccountName })}
163+
onChange={coin => this.setState({ coinCode: coin.coinCode, accountName: coin.suggestedAccountName })}
171164
supportedCoins={supportedCoins}
172165
value={coinCode} />
173166
);
@@ -178,7 +171,6 @@ class AddAccount extends Component<Props, State> {
178171
getRef={this.focusRef}
179172
id="accountName"
180173
onInput={e => this.setState({ accountName: e.target.value })}
181-
placeholder={accountNamePlaceholder}
182174
value={accountName} />
183175
);
184176
case 'success':
@@ -187,7 +179,7 @@ class AddAccount extends Component<Props, State> {
187179
<img src={checkicon} className={styles.successCheck} /><br />
188180
<SimpleMarkup
189181
className={styles.successMessage}
190-
markup={t('addAccount.success.message', { accountName: this.accountName() })}
182+
markup={t('addAccount.success.message', { accountName })}
191183
tagName="p" />
192184
</div>
193185
);
@@ -218,6 +210,7 @@ class AddAccount extends Component<Props, State> {
218210
public render(
219211
{ t }: RenderableProps<Props>,
220212
{
213+
accountName,
221214
coinCode,
222215
errorMessage,
223216
step,
@@ -270,7 +263,7 @@ class AddAccount extends Component<Props, State> {
270263
<Button
271264
disabled={
272265
(step === 'select-coin' && coinCode === 'choose')
273-
|| (step === 'choose-name' && adding)
266+
|| (step === 'choose-name' && (accountName === '' || adding))
274267
}
275268
primary
276269
type="submit">

0 commit comments

Comments
 (0)