1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import React, {useState} from 'react';
import {
View,
Text,
Image,
TouchableOpacity,
StyleSheet,
Alert,
KeyboardAvoidingView,
ScrollView,
Platform,
TouchableWithoutFeedback,
Keyboard,
} from 'react-native';
import R from '../../../assets/R';
import {connect} from 'react-redux';
import TextField from '../../../components/Input/TextField';
import TextMulti from '../../../components/Input/TextMulti';
import PickerDate from '../../../components/Picker/PickerDate';
import PickerImg from '../../../components/Picker/PickerImg';
import I18n from '../../../helper/i18/i18n';
import {checkFormatArray, convertTime} from '../../../Config/Functions';
import {showAlert, TYPE} from '../../../components/DropdownAlert';
const GeneralInfor = (props) => {
const [lastName, setLastName] = useState(props.user.l_name);
const [firstName, setFirstName] = useState(props.user.f_name);
const [phone, setPhone] = useState(props.user.phone);
const [address, setAdress] = useState(props.user.address);
const [birth, setBirth] = useState(new Date(props.user.birthday));
console.log('User', props.user);
const onNextPress = () => {
const titles = [
I18n.t('FirstLastName').toLowerCase(),
I18n.t('Name').toLowerCase(),
I18n.t('PhoneNumber').toLowerCase(),
I18n.t('Address').toLowerCase(),
];
const index = checkFormatArray([lastName, firstName, phone, address]);
if (index === true) {
props.navigation.navigate('Profile', {
l_name: lastName,
f_name: firstName,
mobile: phone,
birthday: convertTime(birth),
address,
});
} else {
showAlert(
TYPE.WARN,
I18n.t('Notification'),
I18n.t('Please_fill_in') + titles[index],
);
}
};
return (
<KeyboardAvoidingView
behavior={Platform.Os === 'ios' ? 'padding' : 'height'}
style={{flex: 1}}
keyboardVerticalOffset={-50}>
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
<ScrollView showsVerticalScrollIndicator={false}>
<View style={{flex: 1, paddingHorizontal: 10, paddingTop: 10}}>
<View style={{flexDirection: 'row'}}>
<View style={{flex: 1}}>
<TextField
value={lastName}
title={I18n.t('FirstLastName')}
onChangeText={(val) => setLastName(val)}
/>
</View>
<View style={{width: 20}} />
<View style={{flex: 1}}>
<TextField
value={firstName}
title={I18n.t('Name')}
onChangeText={(val) => setFirstName(val)}
/>
</View>
</View>
<TextField
value={phone}
isNumber={true}
title={I18n.t('PhoneNumber')}
onChangeText={(val) => setPhone(val)}
/>
<PickerDate
value={birth}
onValueChange={(val) => {
setBirth(val);
}}
title={I18n.t('Birth')}
/>
<TextMulti
value={address}
title={I18n.t('Address')}
onChangeText={(val) => setAdress(val)}
/>
<TouchableOpacity onPress={onNextPress} style={styles.btnNext}>
<Image
style={{width: 30, height: 30}}
source={R.images.iconRight1}
/>
</TouchableOpacity>
<View style={{height: 100}} />
</View>
</ScrollView>
</TouchableWithoutFeedback>
</KeyboardAvoidingView>
);
};
const styles = StyleSheet.create({
btnNext: {
borderRadius: 30,
backgroundColor: '#1473E6',
width: 50,
height: 50,
justifyContent: 'center',
alignItems: 'center',
marginTop: 20,
alignSelf: 'flex-end',
elevation: 2,
shadowColor: '#000',
shadowOffset: {
width: 0,
height: 1,
},
shadowOpacity: 0.15,
shadowRadius: 1.84,
},
});
const mapStateToProps = (state) => {
return {
user: state.userReducer,
};
};
export default connect(mapStateToProps, {})(GeneralInfor);