Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
InvestCustomer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Giang Tran
InvestCustomer
Commits
c3631d0b
Commit
c3631d0b
authored
May 12, 2021
by
Nguyễn Thị Thúy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug timeout
parent
20e8226c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
165 additions
and
135 deletions
+165
-135
Profile.js
src/Screens/AccountVerification/Tab/Profile.js
+13
-7
helpers.js
src/apis/helpers.js
+138
-122
PickerAvatart.js
src/components/Picker/PickerAvatart.js
+14
-6
No files found.
src/Screens/AccountVerification/Tab/Profile.js
View file @
c3631d0b
...
@@ -106,15 +106,21 @@ const Profile = (props) => {
...
@@ -106,15 +106,21 @@ const Profile = (props) => {
const
res
=
await
verifyAccountApi
(
data
);
const
res
=
await
verifyAccountApi
(
data
);
props
.
hideLoading
();
props
.
hideLoading
();
console
.
log
(
res
);
console
.
log
(
res
);
if
(
res
.
data
.
code
==
200
)
{
if
(
res
?.
status
==
200
&&
res
.
data
)
{
setTimeout
(()
=>
{
if
(
res
.
data
.
code
==
200
)
{
props
.
saveUserToRedux
(
res
.
data
.
data
);
setTimeout
(()
=>
{
Alert
.
alert
(
I18n
.
t
(
'Notification'
),
res
.
data
.
message
);
props
.
saveUserToRedux
(
res
.
data
.
data
);
props
.
navigation
.
popToTop
();
Alert
.
alert
(
I18n
.
t
(
'Notification'
),
res
.
data
.
message
);
},
500
);
props
.
navigation
.
popToTop
();
},
500
);
}
else
{
setTimeout
(()
=>
{
Alert
.
alert
(
I18n
.
t
(
'Notification'
),
res
.
data
.
message
);
},
500
);
}
}
else
{
}
else
{
setTimeout
(()
=>
{
setTimeout
(()
=>
{
Alert
.
alert
(
I18n
.
t
(
'Notification'
),
res
.
data
.
message
);
Alert
.
alert
(
I18n
.
t
(
'Notification'
),
'upload fail'
);
},
500
);
},
500
);
}
}
}
else
{
}
else
{
...
...
src/apis/helpers.js
View file @
c3631d0b
import
KEY
from
'../assets/AsynStorage'
;
import
KEY
from
'../assets/AsynStorage'
;
import
axios
from
'axios'
;
import
axios
from
'axios'
;
import
AsyncStorage
from
'@react-native-community/async-storage'
;
import
AsyncStorage
from
'@react-native-community/async-storage'
;
axios
.
defaults
.
timeout
=
10000
;
axios
.
defaults
.
timeout
=
10000
;
export
async
function
GetData
(
url
,
data
)
{
export
async
function
GetData
(
url
,
data
)
{
const
token
=
await
AsyncStorage
.
getItem
(
KEY
.
TOKEN
);
const
token
=
await
AsyncStorage
.
getItem
(
KEY
.
TOKEN
);
let
myRequest
=
{
let
myRequest
=
{
method
:
'get'
,
method
:
'get'
,
url
,
url
,
headers
:
{
headers
:
{
Accept
:
'application/json'
,
Accept
:
'application/json'
,
'Content-Type'
:
'application/json'
,
'Content-Type'
:
'application/json'
,
Authorization
:
'Bearer '
+
token
,
Authorization
:
'Bearer '
+
token
,
},
},
params
:
{
params
:
{
...
data
,
...
data
,
},
},
timeout
:
30
*
1000
,
timeout
:
30
*
1000
,
// withCredentials: true,
// withCredentials: true,
};
};
console
.
log
(
'My request'
,
myRequest
);
console
.
log
(
'My request'
,
myRequest
);
return
await
axios
(
myRequest
)
return
await
axios
(
myRequest
)
.
then
((
response
)
=>
response
)
.
then
((
response
)
=>
response
)
.
then
((
response
)
=>
response
)
.
then
((
response
)
=>
response
)
.
catch
((
error
)
=>
{
.
catch
((
error
)
=>
{
console
.
log
(
error
.
request
);
console
.
log
(
error
.
request
);
const
err
=
{
const
err
=
{
message
:
'error'
,
message
:
'error'
,
status
:
error
.
request
.
status
,
status
:
error
.
request
.
status
,
};
};
return
err
;
return
err
;
});
});
}
}
export
async
function
PostLogin
(
url
,
json
)
{
export
async
function
PostLogin
(
url
,
json
)
{
let
myRequest
=
{
let
myRequest
=
{
method
:
'post'
,
method
:
'post'
,
url
,
url
,
headers
:
{
headers
:
{
Accept
:
'application/json'
,
Accept
:
'application/json'
,
'Content-Type'
:
'application/json'
,
'Content-Type'
:
'application/json'
,
},
},
timeout
:
30
*
1000
,
timeout
:
30
*
1000
,
data
:
JSON
.
stringify
(
json
),
data
:
JSON
.
stringify
(
json
),
};
};
console
.
log
(
'post data mobile'
,
myRequest
);
console
.
log
(
'post data mobile'
,
myRequest
);
return
await
axios
(
myRequest
)
return
await
axios
(
myRequest
)
.
then
((
response
)
=>
response
)
.
then
((
response
)
=>
response
)
.
then
((
response
)
=>
response
)
.
then
((
response
)
=>
response
)
.
catch
((
error
)
=>
{
.
catch
((
error
)
=>
{
console
.
log
(
error
);
console
.
log
(
error
);
const
err
=
{
const
err
=
{
message
:
'error'
,
message
:
'error'
,
status
:
error
.
request
.
status
,
status
:
error
.
request
.
status
,
};
};
return
err
;
return
err
;
});
});
}
}
export
async
function
PostData
(
url
,
json
,
isAuth
=
true
)
{
export
async
function
PostData
(
url
,
json
,
isAuth
=
true
)
{
const
token
=
await
AsyncStorage
.
getItem
(
KEY
.
TOKEN
);
const
token
=
await
AsyncStorage
.
getItem
(
KEY
.
TOKEN
);
console
.
log
(
token
);
console
.
log
(
token
);
let
myRequest
=
{
let
myRequest
=
{
method
:
'post'
,
method
:
'post'
,
url
,
url
,
headers
:
{
headers
:
{
Accept
:
'application/json'
,
Accept
:
'application/json'
,
'Content-Type'
:
'application/json'
,
'Content-Type'
:
'application/json'
,
Authorization
:
'Bearer '
+
token
,
Authorization
:
'Bearer '
+
token
,
},
},
timeout
:
30
*
1000
,
timeout
:
30
*
1000
,
data
:
JSON
.
stringify
(
json
),
data
:
JSON
.
stringify
(
json
),
};
};
console
.
log
(
'post data mobile'
,
myRequest
);
console
.
log
(
'post data mobile'
,
myRequest
);
return
await
axios
(
myRequest
)
return
await
axios
(
myRequest
)
.
then
((
response
)
=>
response
)
.
then
((
response
)
=>
response
)
.
then
((
response
)
=>
response
)
.
then
((
response
)
=>
response
)
.
catch
((
error
)
=>
{
.
catch
((
error
)
=>
{
console
.
log
(
error
.
request
);
console
.
log
(
error
.
request
);
const
err
=
{
const
err
=
{
message
:
'error'
,
message
:
'error'
,
status
:
error
.
request
.
status
,
status
:
error
.
request
.
status
,
};
};
return
err
;
return
err
;
});
});
}
}
export
async
function
PostFormData
(
url
,
data
)
{
export
async
function
PostFormData
(
url
,
data
)
{
const
token
=
await
AsyncStorage
.
getItem
(
KEY
.
TOKEN
);
const
token
=
await
AsyncStorage
.
getItem
(
KEY
.
TOKEN
);
console
.
log
(
token
);
const
source
=
axios
.
CancelToken
.
source
();
let
myRequest
=
{
const
timeout
=
setTimeout
(()
=>
{
method
:
'post'
,
source
.
cancel
();
url
,
// Timeout Logic
headers
:
{
},
1000
);
Accept
:
'application/json'
,
console
.
log
(
token
);
'Content-Type'
:
'multipart/form-data'
,
let
myRequest
=
{
Authorization
:
'Bearer '
+
token
,
method
:
'post'
,
},
url
,
timeout
:
30
*
1000
,
headers
:
{
data
:
data
,
Accept
:
'application/json'
,
};
'Content-Type'
:
'multipart/form-data'
,
console
.
log
(
'post data mobile'
,
myRequest
.
data
);
Authorization
:
'Bearer '
+
token
,
return
await
axios
(
myRequest
)
},
.
then
((
response
)
=>
response
)
timeout
:
1000
,
.
then
((
response
)
=>
response
)
data
:
data
,
.
catch
((
error
)
=>
{
cancelToken
:
source
.
token
,
console
.
log
(
error
);
};
const
err
=
{
console
.
log
(
'post data mobile'
,
myRequest
.
data
);
message
:
'error'
,
return
await
axios
(
myRequest
)
status
:
error
.
request
.
status
,
.
then
((
response
)
=>
{
};
clearTimeout
(
timeout
);
return
err
;
return
response
;
});
})
.
then
((
response
)
=>
{
clearTimeout
(
timeout
);
return
response
;
})
.
catch
((
error
)
=>
{
clearTimeout
(
timeout
);
console
.
log
(
'errorTimeout'
,
error
);
const
err
=
{
message
:
'error'
,
status
:
error
.
request
.
status
,
};
return
err
;
});
}
}
/**
/**
...
@@ -119,27 +135,27 @@ export async function PostFormData(url, data) {
...
@@ -119,27 +135,27 @@ export async function PostFormData(url, data) {
* @param {*} isAuth is state auth
* @param {*} isAuth is state auth
*/
*/
export
async
function
PutData
(
url
,
json
,
isAuth
=
true
)
{
export
async
function
PutData
(
url
,
json
,
isAuth
=
true
)
{
const
token
=
await
AsyncStorage
.
getItem
(
KEY
.
TOKEN
);
const
token
=
await
AsyncStorage
.
getItem
(
KEY
.
TOKEN
);
let
myRequest
=
{
let
myRequest
=
{
method
:
'put'
,
method
:
'put'
,
url
,
url
,
headers
:
{
headers
:
{
Accept
:
'application/json'
,
Accept
:
'application/json'
,
'Content-Type'
:
'application/json'
,
'Content-Type'
:
'application/json'
,
Authorization
:
'Bearer '
+
token
,
Authorization
:
'Bearer '
+
token
,
},
},
data
:
JSON
.
stringify
(
json
),
data
:
JSON
.
stringify
(
json
),
};
};
console
.
log
(
'PutData'
,
myRequest
);
console
.
log
(
'PutData'
,
myRequest
);
return
await
axios
(
myRequest
)
return
await
axios
(
myRequest
)
.
then
((
response
)
=>
response
)
.
then
((
response
)
=>
response
)
.
then
((
response
)
=>
response
)
.
then
((
response
)
=>
response
)
.
catch
((
error
)
=>
{
.
catch
((
error
)
=>
{
console
.
log
(
error
.
request
);
console
.
log
(
error
.
request
);
const
err
=
{
const
err
=
{
message
:
'error'
,
message
:
'error'
,
status
:
error
.
request
.
status
,
status
:
error
.
request
.
status
,
};
};
return
err
;
return
err
;
});
});
}
}
src/components/Picker/PickerAvatart.js
View file @
c3631d0b
...
@@ -63,16 +63,24 @@ const PickerImg = (props) => {
...
@@ -63,16 +63,24 @@ const PickerImg = (props) => {
const
res
=
await
changeAvatart
(
const
res
=
await
changeAvatart
(
createFormData
(
image
,
{
uid
:
props
.
user
.
uid
,
platform
:
Platform
.
OS
}),
createFormData
(
image
,
{
uid
:
props
.
user
.
uid
,
platform
:
Platform
.
OS
}),
);
);
console
.
log
(
'upload avatar'
,
res
)
props
.
hideLoading
();
props
.
hideLoading
();
if
(
res
.
data
.
code
==
200
)
{
if
(
res
?.
status
==
200
&&
res
.
data
)
{
setTimeout
(()
=>
{
if
(
res
.
data
.
code
==
200
)
{
props
.
saveUserToRedux
(
res
.
data
.
data
);
setTimeout
(()
=>
{
Alert
.
alert
(
I18n
.
t
(
'Notification'
),
res
.
data
.
message
);
props
.
saveUserToRedux
(
res
.
data
.
data
);
},
500
);
Alert
.
alert
(
I18n
.
t
(
'Notification'
),
res
.
data
.
message
);
},
500
);
}
else
{
setImgAvatart
(
props
.
user
.
picture_url
);
setTimeout
(()
=>
{
Alert
.
alert
(
I18n
.
t
(
'Notification'
),
res
.
data
.
message
);
},
500
);
}
}
else
{
}
else
{
setImgAvatart
(
props
.
user
.
picture_url
);
setImgAvatart
(
props
.
user
.
picture_url
);
setTimeout
(()
=>
{
setTimeout
(()
=>
{
Alert
.
alert
(
I18n
.
t
(
'Notification'
),
res
.
data
.
message
);
Alert
.
alert
(
I18n
.
t
(
'Notification'
),
'upload fail'
);
},
500
);
},
500
);
}
}
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment