Commit 9710396e by Giang Tran

update avatart

parent e00ac231
......@@ -20,7 +20,7 @@ import {connect} from 'react-redux';
import {saveUserToRedux} from '../../actions/users';
import I18n from '../../helper/i18/i18n';
import {useNavigation} from '@react-navigation/native';
import {TABNAVIGATOR} from '../../routers/ScreenNames';
import {changeAvatart} from '../../apis/Functions/users';
const options = {
......@@ -35,15 +35,14 @@ const options = {
const PickerImg = (props) => {
const naviagtion = useNavigation();
const [isModalVisible, setModalVisible] = useState(false);
const [imgAvatart, setImgAvatart] = useState(props.user.picture_url);
// const [imgAvatart, setImgAvatart] = useState(props.user.picture_url);
console.log(props.user);
useEffect(() => {
setTimeout(() => {
console.log('Affter', props.user.picture_url);
setImgAvatart(props.user.picture_url);
}, 500);
}, [props.user]);
// useEffect(() => {
// setTimeout(() => {
// console.log('Affter', props.user.picture_url);
// setImgAvatart(props.user.picture_url);
// }, 500);
// }, [props.user]);
const createFormData = (photo, body) => {
const data = new FormData();
......@@ -65,6 +64,10 @@ const PickerImg = (props) => {
if (res.data.code == 200) {
setTimeout(() => {
naviagtion.reset({
index: 1,
routes: [{name: TABNAVIGATOR}],
});
props.saveUserToRedux(res.data.data);
Alert.alert(I18n.t('Notification'), res.data.message);
}, 500);
......@@ -103,7 +106,10 @@ const PickerImg = (props) => {
return (
<TouchableOpacity onPress={() => setModalVisible(true)}>
<View style={styles.containerImg}>
<Image source={{uri: imgAvatart}} style={styles.imgAvatar} />
<Image
source={{uri: props.user.picture_url}}
style={styles.imgAvatar}
/>
<View style={styles.iconPicker}>
<Image
style={{width: 20, height: 20}}
......
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