Commit 94b48eb5 by Giang Tran

api update user

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