Commit 9710396e by Giang Tran

update avatart

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