Commit a791dda3 by Giang Tran

update code

parent 9710396e
...@@ -22,6 +22,7 @@ import I18n from '../../helper/i18/i18n'; ...@@ -22,6 +22,7 @@ import I18n from '../../helper/i18/i18n';
import {useNavigation} from '@react-navigation/native'; import {useNavigation} from '@react-navigation/native';
import {TABNAVIGATOR} from '../../routers/ScreenNames'; import {TABNAVIGATOR} from '../../routers/ScreenNames';
import {changeAvatart} from '../../apis/Functions/users'; import {changeAvatart} from '../../apis/Functions/users';
import {showLoading, hideLoading} from '../../actions/loadingAction';
const options = { const options = {
title: 'Select Avatar', title: 'Select Avatar',
...@@ -58,16 +59,13 @@ const PickerImg = (props) => { ...@@ -58,16 +59,13 @@ const PickerImg = (props) => {
}; };
const callApi = async (image) => { const callApi = async (image) => {
props.showLoading();
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}),
); );
props.hideLoading();
if (res.data.code == 200) { if (res.data.code == 200) {
setTimeout(() => { setTimeout(() => {
naviagtion.reset({
index: 1,
routes: [{name: TABNAVIGATOR}],
});
props.saveUserToRedux(res.data.data); props.saveUserToRedux(res.data.data);
Alert.alert(I18n.t('Notification'), res.data.message); Alert.alert(I18n.t('Notification'), res.data.message);
}, 500); }, 500);
...@@ -224,4 +222,8 @@ const mapStateToProps = (state) => { ...@@ -224,4 +222,8 @@ const mapStateToProps = (state) => {
user: state.userReducer, user: state.userReducer,
}; };
}; };
export default connect(mapStateToProps, {saveUserToRedux})(PickerImg); export default connect(mapStateToProps, {
saveUserToRedux,
showLoading,
hideLoading,
})(PickerImg);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment