Commit 6a8e5bdb authored by dungtnguyen's avatar dungtnguyen

change user info

parent 49289102
{
"version": 3,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.anawork_mobile",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 1,
"versionName": "1.0",
"outputFile": "app-release.apk"
}
],
"elementType": "File",
"baselineProfiles": [
{
"minApi": 28,
"maxApi": 30,
"baselineProfiles": [
"baselineProfiles/1/app-release.dm"
]
},
{
"minApi": 31,
"maxApi": 2147483647,
"baselineProfiles": [
"baselineProfiles/0/app-release.dm"
]
}
],
"minSdkVersionForDexing": 23
}
\ No newline at end of file
...@@ -14,7 +14,7 @@ const authAPI = { ...@@ -14,7 +14,7 @@ const authAPI = {
`authenticate/authenticate?username=${username}&password=${password}`, `authenticate/authenticate?username=${username}&password=${password}`,
), ),
requestLogout: ({token}) => axiosClient.post('authenticate/logout', {token}), requestLogout: () => axiosClient.post('authenticate/logout'),
requestGetMyInfo: () => axiosClient.get('authenticate/getMyInfo'), requestGetMyInfo: () => axiosClient.get('authenticate/getMyInfo'),
requestGetCompanyLogo: () => axiosClient.get('companyInfo'), requestGetCompanyLogo: () => axiosClient.get('companyInfo'),
......
import axiosClient from '../axios'; import axiosClient from '../network/axios';
export default { export default {
requestGetLeavesDay: ({filter, sort, page, pageSize}) => requestGetLeavesDay: ({filter, sort, page, pageSize}) =>
axiosClient.get( axiosClient.get(
......
import axiosClient from '../network/axios';
export default {
requestChangeUserInfo: ({id, body}) => axiosClient.put(`users/${id}`, body),
};
...@@ -2,7 +2,10 @@ const storageKey = { ...@@ -2,7 +2,10 @@ const storageKey = {
AUTH: 'auth', AUTH: 'auth',
LANGUAGE: 'language', LANGUAGE: 'language',
}; };
const profileField = {
PERSONAL_INFO: 'Personal Information',
DETAIL_INFO: 'Detail Information',
};
export default { export default {
apiEndpoint: 'https://gateway.dev.meu-solutions.com/staginganawork/api/', apiEndpoint: 'https://gateway.dev.meu-solutions.com/staginganawork/api/',
//apiEndpoint: 'https://gateway.dev.meu-solutions.com/techport/api/', //apiEndpoint: 'https://gateway.dev.meu-solutions.com/techport/api/',
...@@ -11,4 +14,5 @@ export default { ...@@ -11,4 +14,5 @@ export default {
ONE_SIGNAL_KEY: '6f4f8bd1-9b43-4067-8175-c0052140e891', ONE_SIGNAL_KEY: '6f4f8bd1-9b43-4067-8175-c0052140e891',
axiosTimeout: 10000, axiosTimeout: 10000,
storageKey, storageKey,
profileField,
}; };
...@@ -52,6 +52,19 @@ export const getCompanyInfo = createAsyncThunk( ...@@ -52,6 +52,19 @@ export const getCompanyInfo = createAsyncThunk(
}); });
}, },
); );
export const logout = createAsyncThunk(
'auth/logout',
async (data, thunkAPI) => {
return serviceRequest({
dispatch: thunkAPI.dispatch,
serviceMethod: authAPI.requestLogout,
payload: data,
options: {
skipLoader: false,
},
});
},
);
const authSlice = createSlice({ const authSlice = createSlice({
name: 'auth', name: 'auth',
initialState: initialState, initialState: initialState,
...@@ -71,6 +84,12 @@ const authSlice = createSlice({ ...@@ -71,6 +84,12 @@ const authSlice = createSlice({
state.userInfo = user; state.userInfo = user;
} }
}); });
builder.addCase(logout.fulfilled, (state, action) => {
const {success} = Utils.getValues(action, 'payload', false);
if (success) {
Utils.removeData(config.storageKey.AUTH);
}
});
}, },
}); });
......
/* eslint-disable prettier/prettier */
import React, {useState} from 'react'; import React, {useState} from 'react';
import RootNavigation from '../../../navigation/RootNavigation'; import RootNavigation from '../../../navigation/RootNavigation';
import LoginScreen from './LoginScreen'; import LoginScreen from './LoginScreen';
...@@ -7,11 +6,10 @@ import {useTranslation} from 'react-i18next'; ...@@ -7,11 +6,10 @@ import {useTranslation} from 'react-i18next';
import OneSignal from 'react-native-onesignal'; import OneSignal from 'react-native-onesignal';
import {useDispatch, useSelector} from 'react-redux'; import {useDispatch, useSelector} from 'react-redux';
import {loaderSelector} from '../../../app/selectors'; import {loaderSelector} from '../../../app/selectors';
import {getMyInfo} from '../../../store/actions/CommonAction';
import Utils from '../../../utils'; import Utils from '../../../utils';
import {APP_NAVIGATE_SCREEN} from '../../../utils/constant'; import {APP_NAVIGATE_SCREEN} from '../../../utils/constant';
import {ToastMessage} from '../../../utils/MessageUtil'; import {ToastMessage} from '../../../utils/MessageUtil';
import {authenticate} from '../authSlice'; import {authenticate, getMyInfo} from '../authSlice';
const LoginContainer = props => { const LoginContainer = props => {
// console.log("props: ", props) // console.log("props: ", props)
const dispatch = useDispatch(); const dispatch = useDispatch();
...@@ -66,6 +64,7 @@ const LoginContainer = props => { ...@@ -66,6 +64,7 @@ const LoginContainer = props => {
}), }),
).then(response => { ).then(response => {
const {success} = Utils.getValues(response, 'payload', false); const {success} = Utils.getValues(response, 'payload', false);
dispatch(getMyInfo());
if (success) { if (success) {
ToastMessage({ ToastMessage({
title: 'Hệ thống', title: 'Hệ thống',
......
...@@ -380,6 +380,11 @@ const ConfirmDateContainer = props => { ...@@ -380,6 +380,11 @@ const ConfirmDateContainer = props => {
}; };
const handleSubmitConfirmWorkingDayRequest = () => { const handleSubmitConfirmWorkingDayRequest = () => {
if (directManagersList?.length === 0) { if (directManagersList?.length === 0) {
ToastMessage({
title: 'Hệ thống',
message: 'Bạn đã là cấp trên không thể gửi yêu cầu !!!',
type: 'error',
});
return false; return false;
} }
const isSelectedManager = directManagersList.filter(item => item.isChecked); const isSelectedManager = directManagersList.filter(item => item.isChecked);
......
...@@ -334,6 +334,12 @@ const OnLeaveContainer = props => { ...@@ -334,6 +334,12 @@ const OnLeaveContainer = props => {
}; };
const handleSubmitLeaveRequest = () => { const handleSubmitLeaveRequest = () => {
if (directManagersList?.length === 0) { if (directManagersList?.length === 0) {
ToastMessage({
title: 'Hệ thống',
message: 'Bạn đã là cấp trên không thể gửi yêu cầu !!!',
type: 'info',
timeVisible: 5000,
});
return false; return false;
} }
const isSelectedManager = directManagersList.filter(item => item.isChecked); const isSelectedManager = directManagersList.filter(item => item.isChecked);
......
...@@ -2,7 +2,7 @@ import {createAsyncThunk, createSlice} from '@reduxjs/toolkit'; ...@@ -2,7 +2,7 @@ import {createAsyncThunk, createSlice} from '@reduxjs/toolkit';
import serviceRequest from '../../app/serviceRequest'; import serviceRequest from '../../app/serviceRequest';
import onLeaveApi from '../../network/api/onLeaveApi'; import onLeaveApi from '../../api/onLeaveApi';
import Utils from '../../utils'; import Utils from '../../utils';
const initialHome = { const initialHome = {
......
...@@ -428,9 +428,9 @@ export const leavesModalStyles = StyleSheet.create({ ...@@ -428,9 +428,9 @@ export const leavesModalStyles = StyleSheet.create({
shadowOpacity: 0.25, shadowOpacity: 0.25,
shadowRadius: 4, shadowRadius: 4,
elevation: 5, elevation: 5,
marginTop: 80, marginTop: 100,
height: windowHeight,
width: '100%', width: '100%',
height: windowHeight,
}, },
button: { button: {
......
This diff is collapsed.
...@@ -2,86 +2,24 @@ export default function profilePropsProvider(props) { ...@@ -2,86 +2,24 @@ export default function profilePropsProvider(props) {
const { const {
userInfo, userInfo,
isEditField, isEditField,
btnAvailable,
infoUser,
avatar, avatar,
visibleMenu, visibleMenu,
isSlideShow,
dateTimePicker,
contactUser,
showAlert,
modalVisible,
userInputContact,
setAvatar,
setInfoUser,
navigateMain,
setEditField,
setBtnAvailable,
onSaveInfo,
onDeniedAvatar, onDeniedAvatar,
onConfirmAvatar, onConfirmAvatar,
showMenu, showMenu,
openGallery, openGallery,
showFullScreen,
hideFullScreen,
hideMenu, hideMenu,
hideDateTimePicker,
setDateTimePicker,
onSubmitChangeContactUser,
setContactUser,
onChangeDropDownContactUser,
onChangeInputContactUser,
onPressDeleteItem,
onPressAddItem,
onConfirmDeleteAlert,
onCancelAlert,
setUserInputContact,
onSubmitCreateNew,
setModalVisible,
navigateToLogout, navigateToLogout,
onChangeCoverAvatar, onChangeCoverAvatar,
onEditUserInfo,
editUserInfo,
onSubmitChangeInfo,
} = props; } = props;
return { return {
userInfo, userInfo,
isEditField,
btnAvailable,
infoUser,
avatar,
visibleMenu,
isSlideShow,
dateTimePicker,
contactUser,
showAlert,
modalVisible,
userInputContact,
setAvatar,
setInfoUser,
navigateMain,
setEditField,
setBtnAvailable,
onSaveInfo,
onDeniedAvatar,
onConfirmAvatar,
showMenu,
openGallery,
showFullScreen,
hideFullScreen,
hideMenu,
hideDateTimePicker,
setDateTimePicker,
onSubmitChangeContactUser,
setContactUser,
onChangeDropDownContactUser,
onChangeInputContactUser,
onPressDeleteItem,
onPressAddItem,
onConfirmDeleteAlert,
onCancelAlert,
setUserInputContact,
onSubmitCreateNew,
setModalVisible,
navigateToLogout, navigateToLogout,
onChangeCoverAvatar, onEditUserInfo,
editUserInfo,
introduceUserProps: { introduceUserProps: {
userInfo, userInfo,
isEditField, isEditField,
...@@ -94,5 +32,6 @@ export default function profilePropsProvider(props) { ...@@ -94,5 +32,6 @@ export default function profilePropsProvider(props) {
openGallery, openGallery,
onChangeCoverAvatar, onChangeCoverAvatar,
}, },
onSubmitChangeInfo,
}; };
} }
import {createAsyncThunk, createSlice} from '@reduxjs/toolkit';
import serviceRequest from '../../app/serviceRequest';
import Utils from '../../utils';
import profileAPI from '../../api/profileAPI';
const initialState = {};
export const changeUserInfo = createAsyncThunk(
'profile/changeUserInfo',
async (data, thunkAPI) => {
return serviceRequest({
dispatch: thunkAPI.dispatch,
serviceMethod: profileAPI.requestChangeUserInfo,
payload: data,
options: {
skipLoader: false,
},
});
},
);
const profileSlice = createSlice({
name: 'profile',
initialState: initialState,
reducers: {},
extraReducers: builder => {
builder.addCase(changeUserInfo.fulfilled, (state, action) => {
const {success} = Utils.getValues(action, 'payload', false);
});
},
});
const {reducer} = profileSlice;
export default reducer;
import Moment from 'moment';
import React from 'react'; import React from 'react';
import { import {SafeAreaView, ScrollView, View} from 'react-native';
Animated,
Image,
ImageBackground,
Modal,
SafeAreaView,
ScrollView,
TextInput,
TouchableOpacity,
View,
} from 'react-native';
import Alert from 'react-native-awesome-alerts';
import {GestureHandlerRootView, Swipeable} from 'react-native-gesture-handler';
import {Menu, MenuItem} from 'react-native-material-menu';
import DateTimePickerModal from 'react-native-modal-datetime-picker';
import SelectDropdown from 'react-native-select-dropdown';
import Swiper from 'react-native-swiper';
import AppText from '../../../components/AppText';
import ButtonComponent from '../../../components/ButtonComponent'; import ButtonComponent from '../../../components/ButtonComponent';
import TextInputComponent from '../../../components/TextInputComponent'; import {IMAGES} from '../../../values/images';
import {
IMAGES,
IcNotificationList,
IconProfile,
IconSocial,
} from '../../../values/images';
import {default as string, default as strings} from '../../../values/string';
import styles from '../style'; import styles from '../style';
import colors from '../../../values/colors'; import DetailInformation from './components/DetailInformation';
import config from '../../../config';
import IntroduceUser from './components/IntroduceUser';
import GeneralInformation from './components/GeneralInformation'; import GeneralInformation from './components/GeneralInformation';
import IntroduceUser from './components/IntroduceUser';
import PersonalInformation from './components/PersonalInformation'; import PersonalInformation from './components/PersonalInformation';
import DetailInformation from './components/DetailInformation';
const Socials = [
'FACEBOOK',
'EMAIL',
'SKYPE',
'LINKEDIN',
'TWITTER',
'INSTAGRAM',
'WHATSAPP',
'VIPER',
'SNAPCHAT',
'TELEGRAM',
'APPLE',
'YOUTUBE',
'PINTEREST',
];
const gender = ['Nam', 'Nữ'];
const ProfileMainView = ({ const ProfileMainView = ({
userInfo, userInfo,
contactUser,
btnAvailable,
isEditField,
navigateMain,
setEditField,
setBtnAvailable,
infoUser,
setInfoUser,
onSaveInfo,
avatar = [],
onDeniedAvatar,
onConfirmAvatar,
showMenu,
hideMenu,
visibleMenu,
openGallery,
isSlideShow,
showFullScreen,
hideFullScreen,
dateTimePicker,
hideDateTimePicker,
setDateTimePicker,
showAlert,
onSubmitChangeContactUser,
onChangeDropDownContactUser,
onChangeInputContactUser,
onPressDeleteItem,
onPressAddItem,
onCancelAlert,
modalVisible,
setModalVisible,
setUserInputContact,
userInputContact,
onSubmitCreateNew,
onConfirmDeleteAlert,
navigateToLogout, navigateToLogout,
onChangeCoverAvatar,
introduceUserProps, introduceUserProps,
onEditUserInfo,
editUserInfo,
onSubmitChangeInfo,
}) => { }) => {
return ( return (
<SafeAreaView style={styles.container}> <SafeAreaView style={styles.container}>
...@@ -100,9 +24,19 @@ const ProfileMainView = ({ ...@@ -100,9 +24,19 @@ const ProfileMainView = ({
{/* General information */} {/* General information */}
<GeneralInformation userInfo={userInfo} /> <GeneralInformation userInfo={userInfo} />
{/* personal information */} {/* personal information */}
<PersonalInformation userInfo={userInfo} /> <PersonalInformation
userInfo={userInfo}
onEditUserInfo={onEditUserInfo}
editUserInfo={editUserInfo}
handleSubmitChangeInfo={onSubmitChangeInfo}
/>
{/* detail information */} {/* detail information */}
<DetailInformation userInfo={userInfo} /> <DetailInformation
userInfo={userInfo}
onEditUserInfo={onEditUserInfo}
editUserInfo={editUserInfo}
handleSubmitChangeInfo={onSubmitChangeInfo}
/>
{/* Logout Btn */} {/* Logout Btn */}
<View <View
style={{ style={{
...@@ -118,96 +52,6 @@ const ProfileMainView = ({ ...@@ -118,96 +52,6 @@ const ProfileMainView = ({
onPress={navigateToLogout} onPress={navigateToLogout}
/> />
</View> </View>
{/* <View style={styles.centeredView}>
<Modal
animationType="slide"
transparent={true}
visible={modalVisible}
onRequestClose={() => {
Alert.alert('Modal has been closed.');
setModalVisible(!modalVisible);
}}>
<View style={styles.centeredView}>
<View style={styles.modalView}>
<View style={{flexDirection: 'row'}}>
<View style={{flex: 1}}>
<SelectDropdown
data={Socials}
dropdownIconPosition={'right'}
defaultButtonText={'Loại liên hệ'}
buttonStyle={styles.dropdown1BtnStyle}
onSelect={(selectedItem, item_index) =>
setUserInputContact(prev => ({
...prev,
type: selectedItem,
}))
}
dropdownStyle={styles.dropdown1DropdownStyle}
rowStyle={styles.dropdown1RowStyle}
rowTextStyle={styles.dropdown1RowTxtStyle}
buttonTextStyle={styles.dropdown1BtnTxtStyle}
renderDropdownIcon={isOpened => {
return (
<Image
source={
isOpened ? IMAGES.IcUpArrow : IMAGES.IcDownArrow
}
style={{width: 20, height: 20}}
/>
);
}}
/>
{userInputContact.type.length <= 0 && (
<AppText style={{fontSize: 12, color: 'red'}}>
{' '}
Vui lòng chọn liên hệ
</AppText>
)}
</View>
<View style={{flex: 1}}>
<TextInput
style={{borderBottomWidth: 0.2}}
placeholder={'Nhập F'}
keyboardType={'email-address'}
autoCapitalize="none"
value={userInputContact.text}
onChangeText={text =>
setUserInputContact(prev => ({
...prev,
text: text,
}))
}
/>
{userInputContact.text.length <= 0 && (
<AppText style={{fontSize: 12, color: 'red'}}>
{' '}
Vui lòng nhập liên hệ
</AppText>
)}
</View>
</View>
<View style={{flexDirection: 'row', marginTop: 20}}>
<ButtonComponent
text={'Đóng'}
textStyle={styles.textStyle}
style={[
styles.button,
styles.buttonClose,
{marginRight: 15},
]}
onPress={() => setModalVisible(!modalVisible)}
/>
<ButtonComponent
text={'Thêm mới'}
textStyle={styles.textStyle}
style={[styles.button, styles.buttonClose]}
onPress={onSubmitCreateNew}
/>
</View>
</View>
</View>
</Modal>
</View> */}
</ScrollView> </ScrollView>
</SafeAreaView> </SafeAreaView>
); );
......
...@@ -6,9 +6,14 @@ import string from '../../../../values/string'; ...@@ -6,9 +6,14 @@ import string from '../../../../values/string';
import styles from '../../style'; import styles from '../../style';
import commonStyles from '../../../../styles/commonStyles'; import commonStyles from '../../../../styles/commonStyles';
import moment from 'moment'; import moment from 'moment';
import config from '../../../../config';
import {Formik} from 'formik';
import TextInputComponent from '../../../../components/TextInputComponent';
import ButtonComponent from '../../../../components/ButtonComponent';
import colors from '../../../../values/colors';
const DetailInformation = React.memo( const DetailInformation = React.memo(
({userInfo}) => { ({userInfo, editUserInfo, onEditUserInfo, handleSubmitChangeInfo}) => {
const personalInfo = [ const personalInfo = [
{ {
name: 'Số CMND', name: 'Số CMND',
...@@ -74,7 +79,7 @@ const DetailInformation = React.memo( ...@@ -74,7 +79,7 @@ const DetailInformation = React.memo(
name: 'Địa chỉ liên hệ', name: 'Địa chỉ liên hệ',
value: userInfo?.address || '', value: userInfo?.address || '',
icon: IMAGES.IcLocationGray, icon: IMAGES.IcLocationGray,
width: '50%', width: '100%',
}, },
{ {
name: 'Địa chỉ thường trú', name: 'Địa chỉ thường trú',
...@@ -90,13 +95,21 @@ const DetailInformation = React.memo( ...@@ -90,13 +95,21 @@ const DetailInformation = React.memo(
{string.PERSONAL_INFORMATION} {string.PERSONAL_INFORMATION}
</AppText> </AppText>
<View> <View>
<TouchableOpacity> {!editUserInfo?.detailInfo ? (
<TouchableOpacity
onPress={() => onEditUserInfo(config.profileField.DETAIL_INFO)}>
<Image source={IMAGES.IcEdit} style={{height: 30, width: 30}} /> <Image source={IMAGES.IcEdit} style={{height: 30, width: 30}} />
</TouchableOpacity> </TouchableOpacity>
) : (
<TouchableOpacity onPress={() => onEditUserInfo()}>
<Image source={IMAGES.IcReject} />
</TouchableOpacity>
)}
</View> </View>
</View> </View>
<View style={[commonStyles.row, {flexWrap: 'wrap'}]}> <View style={[commonStyles.row, {flexWrap: 'wrap'}]}>
{personalInfo.map(item => ( {!editUserInfo?.detailInfo ? (
personalInfo.map(item => (
<View <View
key={item.name} key={item.name}
style={[styles.infoView, {width: item.width}]}> style={[styles.infoView, {width: item.width}]}>
...@@ -106,14 +119,69 @@ const DetailInformation = React.memo( ...@@ -106,14 +119,69 @@ const DetailInformation = React.memo(
<AppText isSubText>{item?.value}</AppText> <AppText isSubText>{item?.value}</AppText>
</View> </View>
</View> </View>
))} ))
) : (
<Formik
initialValues={{
id_card_number: userInfo?.id_card_number || '',
id_card_issue_date: userInfo?.id_card_issue_date || '',
id_card_issue_palce: userInfo?.id_card_issue_palce || '',
birthday: userInfo?.birthday ? 'Nam' : 'Nữ',
domicile: userInfo?.domicile || '',
birthplace: userInfo?.birthplace || '',
religion: userInfo?.religion || '',
ethnic: userInfo?.ethnic || '',
personal_tax_code: userInfo?.personal_tax_code || '',
nationality: userInfo?.personal_tax_code || '',
address: userInfo?.address || '',
permanent_address: userInfo?.permanent_address || '',
}}
onSubmit={values => handleSubmitChangeInfo(values)}>
{({handleChange, handleBlur, handleSubmit, values}) => (
<View style={[commonStyles.row, {flexWrap: 'wrap'}]}>
{personalInfo.map((item, index) => {
return (
<View
key={item.name}
style={{
width: item.width,
paddingHorizontal: 5,
}}>
<TextInputComponent
value={Object.values(values)[index]}
label={item.name}
placeholder={`Vui lòng nhập ${item.name} của bạn`}
styleAreaInput={{
backgroundColor: colors.white,
width: '100%',
}}
autoCompleteType={'postal-address'}
keyboardType={'email'}
onChangeText={handleChange(
Object.keys(values)[index],
)}
/>
</View>
);
})}
<ButtonComponent
style={[styles.btnSubmit]}
text={'Đồng ý'}
textStyle={{color: colors.white}}
onPress={handleSubmit}
/>
</View>
)}
</Formik>
)}
</View> </View>
</View> </View>
); );
}, },
function (prevProps, nextProps) { // function (prevProps, nextProps) {
return prevProps.userInfo === nextProps.userInfo; // return prevProps.userInfo === nextProps.userInfo;
}, // },
); );
export default memo(DetailInformation); export default memo(DetailInformation);
import {Formik} from 'formik';
import React, {memo} from 'react'; import React, {memo} from 'react';
import {Image, TouchableOpacity, View} from 'react-native'; import {Image, TouchableOpacity, View} from 'react-native';
import AppText from '../../../../components/AppText'; import AppText from '../../../../components/AppText';
import ButtonComponent from '../../../../components/ButtonComponent';
import TextInputComponent from '../../../../components/TextInputComponent';
import config from '../../../../config';
import commonStyles from '../../../../styles/commonStyles';
import {IMAGES} from '../../../../values/images'; import {IMAGES} from '../../../../values/images';
import string from '../../../../values/string'; import string from '../../../../values/string';
import styles from '../../style'; import styles from '../../style';
import commonStyles from '../../../../styles/commonStyles'; import colors from '../../../../values/colors';
const PersonalInformation = React.memo( const PersonalInformation = React.memo(
({userInfo}) => { ({userInfo, onEditUserInfo, editUserInfo, handleSubmitChangeInfo}) => {
const personalInfo = [ const personalInfo = [
{ {
name: 'Họ', name: 'Họ',
...@@ -53,13 +58,23 @@ const PersonalInformation = React.memo( ...@@ -53,13 +58,23 @@ const PersonalInformation = React.memo(
{string.PERSONAL_INFORMATION} {string.PERSONAL_INFORMATION}
</AppText> </AppText>
<View> <View>
<TouchableOpacity> {!editUserInfo?.personalInfo ? (
<TouchableOpacity
onPress={() =>
onEditUserInfo(config.profileField.PERSONAL_INFO)
}>
<Image source={IMAGES.IcEdit} style={{height: 30, width: 30}} /> <Image source={IMAGES.IcEdit} style={{height: 30, width: 30}} />
</TouchableOpacity> </TouchableOpacity>
) : (
<TouchableOpacity onPress={() => onEditUserInfo()}>
<Image source={IMAGES.IcReject} />
</TouchableOpacity>
)}
</View> </View>
</View> </View>
<View style={[commonStyles.row, {flexWrap: 'wrap'}]}> <View style={[commonStyles.row, {flexWrap: 'wrap'}]}>
{personalInfo.map(item => ( {!editUserInfo?.personalInfo ? (
personalInfo.map(item => (
<View <View
key={item.name} key={item.name}
style={[styles.infoView, {width: item.width}]}> style={[styles.infoView, {width: item.width}]}>
...@@ -69,14 +84,68 @@ const PersonalInformation = React.memo( ...@@ -69,14 +84,68 @@ const PersonalInformation = React.memo(
<AppText isSubText>{item?.value}</AppText> <AppText isSubText>{item?.value}</AppText>
</View> </View>
</View> </View>
))} ))
) : (
<Formik
initialValues={{
first_name: userInfo?.first_name || '',
middle_name: userInfo?.middle_name || '',
last_name: userInfo?.last_name || '',
gender: userInfo?.gender ? 'Nam' : 'Nữ',
cell_phone: userInfo?.cell_phone || '',
}}
onSubmit={values => handleSubmitChangeInfo(values)}>
{({handleChange, handleBlur, handleSubmit, values}) => (
<View style={[commonStyles.row, {flexWrap: 'wrap'}]}>
{personalInfo.map((item, index) => {
if (index === personalInfo.length - 1) {
return null;
}
return (
<View
key={item.name}
style={{
width: item.width,
paddingHorizontal: 5,
}}>
<TextInputComponent
value={Object.values(values)[index]}
label={item.name}
placeholder={`Vui lòng nhập ${item.name} của bạn`}
styleAreaInput={{
backgroundColor: colors.white,
width: '100%',
}}
autoCompleteType={'postal-address'}
keyboardType={'email'}
onChangeText={handleChange(
Object.keys(values)[index],
)}
/>
</View>
);
})}
<ButtonComponent
style={[styles.btnSubmit]}
text={'Đồng ý'}
textStyle={{color: colors.white}}
onPress={handleSubmit}
/>
</View>
)}
</Formik>
)}
</View> </View>
</View> </View>
); );
}, },
function (prevProps, nextProps) { // function (prevProps, nextProps) {
return prevProps.userInfo === nextProps.userInfo; // return (
}, // prevProps.userInfo === nextProps.userInfo ||
// prevProps.editUserInfo === nextProps.editUserInfo ||
// prevProps.onEditUserInfo() === nextProps.onEditUserInfo()
// );
// },
); );
export default memo(PersonalInformation); export default memo(PersonalInformation);
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