Commit 460c8ee6 by Giang Tran

fix bug update user

parent bddc0f56
...@@ -7,13 +7,38 @@ import {getListMethod} from '../../../apis/Functions/Deposit'; ...@@ -7,13 +7,38 @@ import {getListMethod} from '../../../apis/Functions/Deposit';
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import I18n from '../../../helper/i18/i18n'; import I18n from '../../../helper/i18/i18n';
import {showAlert, TYPE} from '../../../components/DropdownAlert'; import {showAlert, TYPE} from '../../../components/DropdownAlert';
import {useNavigation} from '@react-navigation/native';
import {saveUserToRedux} from '../../../actions/users';
import {getDetailUser} from '../../../apis/Functions/users';
const MethodPayView = (props) => { const MethodPayView = (props) => {
const [data, setData] = useState([]); const [data, setData] = useState([]);
const navigation = useNavigation();
useEffect(() => { useEffect(() => {
getData(); getData();
}, []); }, []);
React.useEffect(() => {
const unsubscribe = navigation.addListener('focus', () => {
callApi();
});
// Return the function to unsubscribe from the event so it gets removed on unmount
return unsubscribe;
}, [navigation]);
const callApi = async () => {
const res = await getDetailUser({
id: props.user.uid,
platform: Platform.OS,
});
console.log(res);
if (res.data.code == 200 && res.data.data) {
props.saveUserToRedux(res.data.data);
}
};
const getData = async () => { const getData = async () => {
const res = await getListMethod({ const res = await getListMethod({
platform: Platform.OS, platform: Platform.OS,
...@@ -50,4 +75,4 @@ const mapStateToProps = (state) => { ...@@ -50,4 +75,4 @@ const mapStateToProps = (state) => {
user: state.userReducer, user: state.userReducer,
}; };
}; };
export default connect(mapStateToProps, {})(MethodPayView); export default connect(mapStateToProps, {saveUserToRedux})(MethodPayView);
...@@ -112,6 +112,7 @@ const WalletDeposit = (props) => { ...@@ -112,6 +112,7 @@ const WalletDeposit = (props) => {
<TextMulti <TextMulti
onChangeText={(val) => setNotes(val)} onChangeText={(val) => setNotes(val)}
title={I18n.t('Note')} title={I18n.t('Note')}
placeholder={I18n.t('noteWithdrawMoney')}
/> />
</View> </View>
</View> </View>
......
...@@ -209,6 +209,7 @@ const WalletWithdraw = (props) => { ...@@ -209,6 +209,7 @@ const WalletWithdraw = (props) => {
<TextMulti <TextMulti
onChangeText={(val) => setNotes(val)} onChangeText={(val) => setNotes(val)}
title={I18n.t('Note')} title={I18n.t('Note')}
placeholder={I18n.t('noteWithdrawMoney')}
/> />
</View> </View>
</View> </View>
......
...@@ -12,6 +12,8 @@ import {hideLoading, showLoading} from '../../actions/loadingAction'; ...@@ -12,6 +12,8 @@ import {hideLoading, showLoading} from '../../actions/loadingAction';
import _ from 'lodash'; import _ from 'lodash';
import {showAlert, TYPE} from '../../components/DropdownAlert/index'; import {showAlert, TYPE} from '../../components/DropdownAlert/index';
import VersionChecker from '../VersionChecker'; import VersionChecker from '../VersionChecker';
import {saveUserToRedux} from '../../actions/users';
import {getDetailUser} from '../../apis/Functions/users';
const Home = (props) => { const Home = (props) => {
const [data, setData] = useState({total_deposit: 0, total_withdraw: 0}); const [data, setData] = useState({total_deposit: 0, total_withdraw: 0});
...@@ -24,6 +26,25 @@ const Home = (props) => { ...@@ -24,6 +26,25 @@ const Home = (props) => {
const [isSortPercent, setIsSortPercent] = useState(null); const [isSortPercent, setIsSortPercent] = useState(null);
const [isSortPriceOpenClose, setIsSortPriceOpenClose] = useState(null); const [isSortPriceOpenClose, setIsSortPriceOpenClose] = useState(null);
const [isSortPriceHighLow, setIsSortPriceHighLow] = useState(null); const [isSortPriceHighLow, setIsSortPriceHighLow] = useState(null);
const [isRefresh, setRefresh] = useState(false);
const onRefresh = async () => {
setRefresh(true);
const res = await getDetailUser({
id: props.user.uid,
platform: Platform.OS,
});
console.log(res);
if (res.data.code == 200 && res.data.data) {
props.saveUserToRedux(res.data.data);
}
setRefresh(false);
};
const SORT_TYPE = { const SORT_TYPE = {
DESC: 'DESC', DESC: 'DESC',
ASC: 'ASC', ASC: 'ASC',
...@@ -192,6 +213,8 @@ const Home = (props) => { ...@@ -192,6 +213,8 @@ const Home = (props) => {
onSortByPercent={onSortByPercent} onSortByPercent={onSortByPercent}
onSortByPriceOpenClose={onSortByPriceOpenClose} onSortByPriceOpenClose={onSortByPriceOpenClose}
onSortByPriceHighLow={onSortByPriceHighLow} onSortByPriceHighLow={onSortByPriceHighLow}
isRefresh={isRefresh}
onRefresh={onRefresh}
/> />
); );
}; };
...@@ -201,4 +224,8 @@ const mapStateToProps = (state) => { ...@@ -201,4 +224,8 @@ const mapStateToProps = (state) => {
user: state.userReducer, user: state.userReducer,
}; };
}; };
export default connect(mapStateToProps, {showLoading, hideLoading})(Home); export default connect(mapStateToProps, {
showLoading,
hideLoading,
saveUserToRedux,
})(Home);
...@@ -6,6 +6,7 @@ import { ...@@ -6,6 +6,7 @@ import {
ScrollView, ScrollView,
TouchableOpacity, TouchableOpacity,
Text, Text,
RefreshControl,
} from 'react-native'; } from 'react-native';
import HeaderHome from '../../components/Header/HeaderHome'; import HeaderHome from '../../components/Header/HeaderHome';
import {getFontXD} from '../../Config/Functions'; import {getFontXD} from '../../Config/Functions';
...@@ -19,7 +20,14 @@ const HomeView = (props) => { ...@@ -19,7 +20,14 @@ const HomeView = (props) => {
source={R.images.bgHome} source={R.images.bgHome}
resizeMode={'stretch'} resizeMode={'stretch'}
style={{width: '100%', height: '100%'}}> style={{width: '100%', height: '100%'}}>
<ScrollView showsVerticalScrollIndicator={false}> <ScrollView
refreshControl={
<RefreshControl
refreshing={props.isRefresh}
onRefresh={props.onRefresh}
/>
}
showsVerticalScrollIndicator={false}>
<HeaderHome /> <HeaderHome />
{props.listImage.length > 0 ? ( {props.listImage.length > 0 ? (
<SwiperComponent listImage={props.listImage} /> <SwiperComponent listImage={props.listImage} />
......
...@@ -4,6 +4,7 @@ import {getListCalendar} from '../../../apis/Functions/NewFeed'; ...@@ -4,6 +4,7 @@ import {getListCalendar} from '../../../apis/Functions/NewFeed';
import {showAlert, TYPE} from '../../../components/DropdownAlert'; import {showAlert, TYPE} from '../../../components/DropdownAlert';
import {convertTimeApi} from '../../../Config/Functions'; import {convertTimeApi} from '../../../Config/Functions';
import I18n from '../../../helper/i18/i18n'; import I18n from '../../../helper/i18/i18n';
import AppText from '../../../components/AppText';
import Item from './item'; import Item from './item';
const NewFeed = (props) => { const NewFeed = (props) => {
...@@ -29,6 +30,7 @@ const NewFeed = (props) => { ...@@ -29,6 +30,7 @@ const NewFeed = (props) => {
end_date: convertTimeApi(lastDay), end_date: convertTimeApi(lastDay),
keyword: '', keyword: '',
}); });
if (res.data.code == 200 && res.data.data) { if (res.data.code == 200 && res.data.data) {
setData(res.data.data); setData(res.data.data);
} else { } else {
...@@ -60,7 +62,7 @@ const NewFeed = (props) => { ...@@ -60,7 +62,7 @@ const NewFeed = (props) => {
const getItemLayout = (data, index) => ({ const getItemLayout = (data, index) => ({
length: 100, length: 100,
offset: 40 * index, offset: 50 * index,
index, index,
}); });
...@@ -71,6 +73,16 @@ const NewFeed = (props) => { ...@@ -71,6 +73,16 @@ const NewFeed = (props) => {
backgroundColor: 'white', backgroundColor: 'white',
paddingTop: 10, paddingTop: 10,
}}> }}>
{data.length == 0 ? (
<View style={{justifyContent: 'center', alignItems: 'center', flex: 1}}>
<AppText
i18nKey={'NoData'}
style={{
fontSize: 18,
fontWeight: 'bold',
}}></AppText>
</View>
) : (
<FlatList <FlatList
ref={ListDayRef} ref={ListDayRef}
getItemLayout={getItemLayout} getItemLayout={getItemLayout}
...@@ -79,6 +91,7 @@ const NewFeed = (props) => { ...@@ -79,6 +91,7 @@ const NewFeed = (props) => {
keyExtractor={(item) => item.id} keyExtractor={(item) => item.id}
renderItem={({item, index}) => <Item item={item} index={index} />} renderItem={({item, index}) => <Item item={item} index={index} />}
/> />
)}
</View> </View>
); );
}; };
......
...@@ -4,7 +4,7 @@ import {HEIGHTXD, WIDTHXD, getFontXD} from '../../../Config/Functions'; ...@@ -4,7 +4,7 @@ import {HEIGHTXD, WIDTHXD, getFontXD} from '../../../Config/Functions';
import R from '../../../assets/R'; import R from '../../../assets/R';
const InputComponent = (props) => { const InputComponent = (props) => {
const {title, onChangeText, maxLength} = props; const {title, onChangeText, maxLength, placeholder} = props;
return ( return (
<View style={{marginVertical: 5}}> <View style={{marginVertical: 5}}>
...@@ -19,6 +19,7 @@ const InputComponent = (props) => { ...@@ -19,6 +19,7 @@ const InputComponent = (props) => {
<TextInput <TextInput
placeholderTextColor={R.colors.placeHolder} placeholderTextColor={R.colors.placeHolder}
maxLength={maxLength} maxLength={maxLength}
placeholder={placeholder}
autoCapitalize="none" autoCapitalize="none"
onChangeText={(val) => onChangeText(val)} onChangeText={(val) => onChangeText(val)}
style={{ style={{
......
...@@ -4,7 +4,15 @@ import {HEIGHTXD, WIDTHXD, getFontXD} from '../../Config/Functions'; ...@@ -4,7 +4,15 @@ import {HEIGHTXD, WIDTHXD, getFontXD} from '../../Config/Functions';
import R from '../../assets/R'; import R from '../../assets/R';
const TextField = (props) => { const TextField = (props) => {
const {title, onChangeText, maxLength, isNumber, value, editable} = props; const {
title,
onChangeText,
maxLength,
isNumber,
value,
editable,
placeholder,
} = props;
return ( return (
<View style={{marginVertical: 5}}> <View style={{marginVertical: 5}}>
...@@ -18,6 +26,7 @@ const TextField = (props) => { ...@@ -18,6 +26,7 @@ const TextField = (props) => {
</Text> </Text>
<TextInput <TextInput
maxLength={maxLength ? maxLength : 256} maxLength={maxLength ? maxLength : 256}
placeholder={placeholder}
placeholderTextColor={R.colors.placeHolder} placeholderTextColor={R.colors.placeHolder}
editable={editable != null ? false : true} editable={editable != null ? false : true}
autoCapitalize="none" autoCapitalize="none"
......
...@@ -4,7 +4,7 @@ import {HEIGHTXD, WIDTHXD, getFontXD} from '../../Config/Functions'; ...@@ -4,7 +4,7 @@ import {HEIGHTXD, WIDTHXD, getFontXD} from '../../Config/Functions';
import R from '../../assets/R'; import R from '../../assets/R';
const TextField = (props) => { const TextField = (props) => {
const {title, onChangeText, maxLength, value, editable} = props; const {title, onChangeText, maxLength, value, editable, placeholder} = props;
return ( return (
<View style={{marginVertical: 5}}> <View style={{marginVertical: 5}}>
...@@ -19,6 +19,7 @@ const TextField = (props) => { ...@@ -19,6 +19,7 @@ const TextField = (props) => {
<TextInput <TextInput
maxLength={maxLength} maxLength={maxLength}
textAlign={'left'} textAlign={'left'}
placeholder={placeholder}
editable={editable != null ? editable : true} editable={editable != null ? editable : true}
value={value} value={value}
onChangeText={(val) => onChangeText(val)} onChangeText={(val) => onChangeText(val)}
......
...@@ -290,4 +290,5 @@ export default { ...@@ -290,4 +290,5 @@ export default {
'The withdrawal amount must be more than 1 million dong', 'The withdrawal amount must be more than 1 million dong',
Overtime: 'Overtime OTP', Overtime: 'Overtime OTP',
LoginSessionEnd: 'Login session end, please login again', LoginSessionEnd: 'Login session end, please login again',
noteWithdrawMoney: 'Infor CQG account',
}; };
...@@ -290,4 +290,5 @@ export default { ...@@ -290,4 +290,5 @@ export default {
WarnMinReqestWithdraw: 'Số tiền rút phải lớn hơn 1 triệu đồng', WarnMinReqestWithdraw: 'Số tiền rút phải lớn hơn 1 triệu đồng',
Overtime: 'Mã OTP hết hạn sử dụng', Overtime: 'Mã OTP hết hạn sử dụng',
LoginSessionEnd: 'Hết phiên đăng nhập, vui lòng đăng nhập lại', LoginSessionEnd: 'Hết phiên đăng nhập, vui lòng đăng nhập lại',
noteWithdrawMoney: 'Thông tin tài khoản CQG',
}; };
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