@@ -18,6 +18,7 @@ import {NavigationActions} from 'react-navigation';
18
18
import UpdateUserMutation from '../mutations/UpdateUserMutation'
19
19
import TechnologiesBlock from "./TechnologiesBlock" ;
20
20
import CheckinList from "./CheckinList" ;
21
+ import main from "../styles/main" ;
21
22
22
23
class Profile extends React . Component {
23
24
@@ -31,7 +32,8 @@ class Profile extends React.Component {
31
32
edit : false ,
32
33
text : "testing" ,
33
34
technologies : [ ] ,
34
- technologiesToRemove : [ ]
35
+ technologiesToRemove : [ ] ,
36
+ wait : false
35
37
}
36
38
37
39
componentDidMount ( ) {
@@ -122,6 +124,8 @@ class Profile extends React.Component {
122
124
123
125
if ( profilePic ) {
124
126
127
+ this . setState ( { wait : true } )
128
+
125
129
const file = {
126
130
uri : profilePic ,
127
131
name : uuidv4 ( ) + ".jpg" ,
@@ -140,6 +144,7 @@ class Profile extends React.Component {
140
144
const s3Res = await RNS3 . put ( file , options ) ;
141
145
142
146
if ( s3Res . status !== 201 ) {
147
+ this . setState ( { wait : false } )
143
148
console . log ( '\n>>>>> Fail to upload profile pic to S3' , s3Res ) ;
144
149
alert ( 'Fail to upload profile picture, please try again later' ) ;
145
150
return ;
@@ -149,9 +154,13 @@ class Profile extends React.Component {
149
154
options . keyPrefix + file . name ;
150
155
}
151
156
157
+ this . setState ( { wait : true } )
158
+
152
159
UpdateUserMutation ( userForm . id , userForm . name ,
153
160
userForm . bio , profilePicUrl , techs , oldTechsIds ,
154
161
async ( err , res ) => {
162
+ this . setState ( { wait : false } )
163
+
155
164
if ( err ) {
156
165
console . log ( 'Error while updating Profile' , err ) ;
157
166
alert ( 'Error while updating Profile: ' + err ) ;
@@ -256,7 +265,7 @@ class Profile extends React.Component {
256
265
label = "EMAIL"
257
266
value = { user . email }
258
267
onChange = { ( v ) => this . _setUserField ( 'email' , v ) }
259
- readOnly = { ! edit } />
268
+ readOnly = { true } />
260
269
</ View >
261
270
</ View >
262
271
@@ -308,13 +317,18 @@ class Profile extends React.Component {
308
317
</ Text >
309
318
</ TouchableOpacity > : null }
310
319
</ View > : null }
311
-
312
- { edit ? < View >
313
- < Button title = { 'Submit Profile Update' }
314
- onPress = { this . _submitProfile } />
315
- </ View > : null }
316
320
</ View >
317
321
</ ScrollView >
322
+
323
+ { edit ? < View >
324
+ < TouchableOpacity
325
+ style = { main . bottomPrimaryButton }
326
+ onPress = { ! this . state . wait ? this . _submitProfile : ( ) => null } >
327
+ < Text style = { main . primaryButtonText } >
328
+ { this . state . wait ? 'Please wait...' : 'Submit' }
329
+ </ Text >
330
+ </ TouchableOpacity >
331
+ </ View > : null }
318
332
</ View >
319
333
) ;
320
334
}
0 commit comments