1
1
import React , { Component } from 'react' ;
2
- import { Alert , Button , Container , Col , Form , Row } from "react-bootstrap" ;
2
+ import { Alert , Button , Container , Col , Form , Row , Spinner } from "react-bootstrap" ;
3
3
4
4
import './App.css' ;
5
5
@@ -23,9 +23,11 @@ class App extends Component {
23
23
const params = { address : inputEthAddress } ;
24
24
Object . keys ( params ) . forEach ( key => url . searchParams . append ( key , params [ key ] ) ) ;
25
25
26
+ this . setState ( { isLoading : true } ) ;
26
27
const response = await fetch ( url , {
27
28
method : 'GET' ,
28
29
} ) ;
30
+ this . setState ( { isLoading : false } ) ;
29
31
if ( response . status !== 200 ) {
30
32
this . setState ( {
31
33
responseMsg : response . statusText ,
@@ -51,9 +53,11 @@ class App extends Component {
51
53
const params = { address : inputEthAddress } ;
52
54
Object . keys ( params ) . forEach ( key => url . searchParams . append ( key , params [ key ] ) ) ;
53
55
56
+ this . setState ( { isLoading : true } ) ;
54
57
const response = await fetch ( url , {
55
58
method : 'GET' ,
56
59
} ) ;
60
+ this . setState ( { isLoading : false } ) ;
57
61
if ( response . status !== 200 ) {
58
62
this . setState ( {
59
63
responseMsg : response . statusText ,
@@ -79,9 +83,11 @@ class App extends Component {
79
83
const params = { address : inputDhxAddress } ;
80
84
Object . keys ( params ) . forEach ( key => url . searchParams . append ( key , params [ key ] ) ) ;
81
85
86
+ this . setState ( { isLoading : true } ) ;
82
87
const response = await fetch ( url , {
83
88
method : 'GET' ,
84
89
} ) ;
90
+ this . setState ( { isLoading : false } ) ;
85
91
if ( response . status !== 200 ) {
86
92
this . setState ( {
87
93
responseMsg : response . statusText ,
@@ -97,7 +103,7 @@ class App extends Component {
97
103
} ;
98
104
99
105
render ( ) {
100
- const { responseMsg, responseTx } = this . state ;
106
+ const { isLoading , responseMsg, responseTx } = this . state ;
101
107
return (
102
108
< Container fluid className = "App" >
103
109
< Row className = "justify-content-md-center" >
@@ -131,6 +137,11 @@ class App extends Component {
131
137
</ Row >
132
138
) : null
133
139
}
140
+ {
141
+ isLoading && ( ! responseMsg || ! responseTx ) ? (
142
+ < Spinner animation = "border" variant = "primary" />
143
+ ) : null
144
+ }
134
145
< hr className = "mb-4" />
135
146
< Form onSubmit = { this . handleSubmitRequestEth } >
136
147
< Form . Group controlId = "formRequestEth" >
0 commit comments