Commit 94b48eb5 by Giang Tran

api update user

parent ec4e9c22
......@@ -5,13 +5,6 @@
"version": "0.2.0",
"configurations": [
{
"name": "Debug iOS",
"request": "launch",
"type": "reactnative",
"cwd": "${workspaceFolder}",
"platform": "ios"
},
{
"name": "Attach to Chrome",
"port": 9222,
"request": "attach",
......
......@@ -2,12 +2,9 @@ import React, {useState} from 'react';
import {
View,
Text,
TextInput,
TouchableOpacity,
StyleSheet,
Touchable,
TouchableOpacityBase,
Dimensions,
Alert,
KeyboardAvoidingView,
ScrollView,
Platform,
......@@ -15,37 +12,58 @@ import {
Keyboard,
} from 'react-native';
import R from '../../../../assets/R';
import RadioForm, {
RadioButton,
RadioButtonInput,
RadioButtonLabel,
} from 'react-native-simple-radio-button';
import PickerDate from '../../../../components/Picker/PickerDate';
import TextMulti from '../../../../components/Input/TextMulti';
import {connect} from 'react-redux';
import {showLoading, hideLoading} from '../../../../actions/loadingAction';
import {converStringToDate} from '../../../../Config/Functions';
var radio_props = [
{label: 'Nam', value: 0},
{label: 'Nữ', value: 1},
];
const {width} = Dimensions.get('window');
import {saveUserToRedux} from '../../../../actions/users';
import TextField from '../../../../components/Input/TextField';
import PickerItem from '../../../../components/Picker/PickerItem';
import {
getFontXD,
HEIGHTXD,
WIDTHXD,
renderStatus,
checkFormatArray,
} from '../../../../Config/Functions';
import Icon from 'react-native-vector-icons/Ionicons';
import {updateInforUser} from '../../../../apis/Functions/users';
const GeneralInfor = (props) => {
const [Select, setSelect] = useState('ABC');
const [bank, setBank] = useState();
const [account, setAccount] = useState();
const [phone, setPhone] = useState(props.user.phone);
const [address, setAddress] = useState(props.user.address);
const onClick = async () => {
const titles = ['điện thoại', 'địa chỉ'];
const index = checkFormatArray([phone, address]);
if (index === true) {
props.showLoading();
const res = await updateInforUser({
uid: props.user.uid,
platform: Platform.OS,
phone,
address,
});
props.hideLoading();
if (res.data.code == 200) {
setTimeout(() => {
props.saveUserToRedux(res.data.data);
Alert.alert('Thông báo!', res.data.message);
props.navigation.popToTop();
}, 500);
} else {
setTimeout(() => {
Alert.alert('Thông báo!', res.data.message);
}, 500);
}
} else {
Alert.alert('Thông báo!', 'Vui lòng điền ' + titles[index]);
}
};
const renderMale = () => {
if (props.user.gender == 1) return 'Nữ';
return 'Nam';
};
return (
<KeyboardAvoidingView
behavior={Platform.Os === 'ios' ? 'padding' : 'height'}
......@@ -54,68 +72,65 @@ const GeneralInfor = (props) => {
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
<ScrollView style={{flex: 1}} showsVerticalScrollIndicator={false}>
<View style={styles.container}>
<TextField
value={props.user.fullname}
editable={false}
title={'Họ và tên'}
onChangeText={(val) => console.log(val)}
/>
<TextField
title={'Điện thoại'}
editable={false}
value={props.user.phone}
onChangeText={(val) => console.log(val)}
/>
<TextField
editable={false}
title={'Email'}
value={props.user.email}
onChangeText={(val) => console.log(val)}
/>
{/*
<TextInput
style={styles.customTxt}
onChangeText={(val) => console.log(val)}
placeholder="0000"
/> */}
<Text style={styles.txtTitle}>Gii tính</Text>
<RadioForm
radio_props={radio_props}
labelStyle={{fontSize: getFontXD(42)}}
formHorizontal={true}
style={styles.row}
initial={0}
onPress={(value) => {
setAccount({value: value});
}}
/>
<View style={styles.status}>
<Text style={styles.txtTitle}>Trng thái</Text>
{renderStatus(props.user.status)}
<View style={styles.wrapItem}>
<View style={styles.wrapLeft}>
<Text style={styles.txtTitle}>H và tên</Text>
</View>
<View style={styles.wrapRight}>
<Text style={styles.txtTitle}>{props.user.fullname}</Text>
</View>
</View>
<View style={styles.wrapItem}>
<View style={styles.wrapLeft}>
<Text style={styles.txtTitle}>Email</Text>
</View>
<View style={styles.wrapRight}>
<Text style={styles.txtTitle}>{props.user.email}</Text>
</View>
</View>
<View style={styles.wrapItem}>
<View style={styles.wrapLeft}>
<Text style={styles.txtTitle}>Ngày sinh</Text>
</View>
<View style={styles.wrapRight}>
<Text style={styles.txtTitle}>{props.user.birthday}</Text>
</View>
</View>
<View style={styles.wrapItem}>
<View style={styles.wrapLeft}>
<Text style={styles.txtTitle}>Gii tính</Text>
</View>
<View style={styles.wrapRight}>
<Text style={styles.txtTitle}>{renderMale()}</Text>
</View>
</View>
<View style={styles.wrapItem}>
<View style={styles.wrapLeft}>
<Text style={styles.txtTitle}>Trng thái</Text>
</View>
<View style={styles.wrapRight}>
<Text style={styles.txtTitle}>
{' '}
{renderStatus(props.user.status)}
</Text>
</View>
</View>
<PickerDate
valueString={converStringToDate(props.user.birthday)}
title={'Ngày sinh'}
disabled={true}
<TextField
title={'Điện thoại'}
value={phone}
onChangeText={(val) => setPhone(val)}
/>
<TextMulti
onChangeText={(val) => consoele.log(val)}
value={props.user.address}
editable={false}
onChangeText={(val) => setAddress(val)}
value={address}
title={'Địa chỉ'}
/>
<View style={{height: 40}} />
<View style={{justifyContent: 'center', alignItems: 'center'}}>
<TouchableOpacity
onPress={() => console.log('Hello')}
style={styles.btn}>
<TouchableOpacity onPress={onClick} style={styles.btn}>
<Text style={styles.txtBtn}>Cp nht</Text>
</TouchableOpacity>
</View>
......@@ -132,6 +147,10 @@ const styles = StyleSheet.create({
paddingHorizontal: 10,
paddingVertical: 10,
},
wrapItem: {
flexDirection: 'row',
marginVertical: 5,
},
customTxt: {
height: HEIGHTXD(110),
color: 'black',
......@@ -153,6 +172,12 @@ const styles = StyleSheet.create({
marginTop: 50,
marginBottom: 20,
},
wrapLeft: {
flex: 1,
},
wrapRight: {
flex: 2,
},
status: {
flexDirection: 'row',
justifyContent: 'space-between',
......@@ -205,6 +230,8 @@ const mapStateToProps = (state) => {
user: state.userReducer,
};
};
export default connect(mapStateToProps, {showLoading, hideLoading})(
GeneralInfor,
);
export default connect(mapStateToProps, {
showLoading,
saveUserToRedux,
hideLoading,
})(GeneralInfor);
......@@ -46,3 +46,8 @@ export const getListNotification = async (body) =>
GetData(url.urlGetListNotification, body)
.then((res) => res)
.catch((err) => err);
export const updateInforUser = async (body) =>
PostData(url.urlUpdateInforUser, body)
.then((res) => res)
.catch((err) => err);
......@@ -33,4 +33,6 @@ export default {
urlGetListPacketCQG: root + 'api/v1/customers/get-list-fee-package',
urlOpenCQG: root + 'api/v1/customers/register-open-cqg',
urlUpdateInforUser: root + 'api/v1/customers/update-general-info',
};
......@@ -31,7 +31,7 @@ const FirebaseNotification = (props) => {
});
});
(async () => await messaging().registerDeviceForRemoteMessages())();
// (async () => await messaging().registerDeviceForRemoteMessages())();
messaging().onNotificationOpenedApp((remoteMessage) => {
console.log(
'Notification caused app to open from background state:',
......
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