Commit 460c8ee6 by Giang Tran

fix bug update user

parent bddc0f56
......@@ -7,13 +7,38 @@ import {getListMethod} from '../../../apis/Functions/Deposit';
import {connect} from 'react-redux';
import I18n from '../../../helper/i18/i18n';
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 [data, setData] = useState([]);
const navigation = useNavigation();
useEffect(() => {
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 res = await getListMethod({
platform: Platform.OS,
......@@ -50,4 +75,4 @@ const mapStateToProps = (state) => {
user: state.userReducer,
};
};
export default connect(mapStateToProps, {})(MethodPayView);
export default connect(mapStateToProps, {saveUserToRedux})(MethodPayView);
......@@ -112,6 +112,7 @@ const WalletDeposit = (props) => {
<TextMulti
onChangeText={(val) => setNotes(val)}
title={I18n.t('Note')}
placeholder={I18n.t('noteWithdrawMoney')}
/>
</View>
</View>
......
......@@ -209,6 +209,7 @@ const WalletWithdraw = (props) => {
<TextMulti
onChangeText={(val) => setNotes(val)}
title={I18n.t('Note')}
placeholder={I18n.t('noteWithdrawMoney')}
/>
</View>
</View>
......
......@@ -12,6 +12,8 @@ import {hideLoading, showLoading} from '../../actions/loadingAction';
import _ from 'lodash';
import {showAlert, TYPE} from '../../components/DropdownAlert/index';
import VersionChecker from '../VersionChecker';
import {saveUserToRedux} from '../../actions/users';
import {getDetailUser} from '../../apis/Functions/users';
const Home = (props) => {
const [data, setData] = useState({total_deposit: 0, total_withdraw: 0});
......@@ -24,6 +26,25 @@ const Home = (props) => {
const [isSortPercent, setIsSortPercent] = useState(null);
const [isSortPriceOpenClose, setIsSortPriceOpenClose] = 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 = {
DESC: 'DESC',
ASC: 'ASC',
......@@ -192,6 +213,8 @@ const Home = (props) => {
onSortByPercent={onSortByPercent}
onSortByPriceOpenClose={onSortByPriceOpenClose}
onSortByPriceHighLow={onSortByPriceHighLow}
isRefresh={isRefresh}
onRefresh={onRefresh}
/>
);
};
......@@ -201,4 +224,8 @@ const mapStateToProps = (state) => {
user: state.userReducer,
};
};
export default connect(mapStateToProps, {showLoading, hideLoading})(Home);
export default connect(mapStateToProps, {
showLoading,
hideLoading,
saveUserToRedux,
})(Home);
......@@ -6,6 +6,7 @@ import {
ScrollView,
TouchableOpacity,
Text,
RefreshControl,
} from 'react-native';
import HeaderHome from '../../components/Header/HeaderHome';
import {getFontXD} from '../../Config/Functions';
......@@ -19,7 +20,14 @@ const HomeView = (props) => {
source={R.images.bgHome}
resizeMode={'stretch'}
style={{width: '100%', height: '100%'}}>
<ScrollView showsVerticalScrollIndicator={false}>
<ScrollView
refreshControl={
<RefreshControl
refreshing={props.isRefresh}
onRefresh={props.onRefresh}
/>
}
showsVerticalScrollIndicator={false}>
<HeaderHome />
{props.listImage.length > 0 ? (
<SwiperComponent listImage={props.listImage} />
......
......@@ -4,6 +4,7 @@ import {getListCalendar} from '../../../apis/Functions/NewFeed';
import {showAlert, TYPE} from '../../../components/DropdownAlert';
import {convertTimeApi} from '../../../Config/Functions';
import I18n from '../../../helper/i18/i18n';
import AppText from '../../../components/AppText';
import Item from './item';
const NewFeed = (props) => {
......@@ -29,6 +30,7 @@ const NewFeed = (props) => {
end_date: convertTimeApi(lastDay),
keyword: '',
});
if (res.data.code == 200 && res.data.data) {
setData(res.data.data);
} else {
......@@ -60,7 +62,7 @@ const NewFeed = (props) => {
const getItemLayout = (data, index) => ({
length: 100,
offset: 40 * index,
offset: 50 * index,
index,
});
......@@ -71,6 +73,16 @@ const NewFeed = (props) => {
backgroundColor: 'white',
paddingTop: 10,
}}>
{data.length == 0 ? (
<View style={{justifyContent: 'center', alignItems: 'center', flex: 1}}>
<AppText
i18nKey={'NoData'}
style={{
fontSize: 18,
fontWeight: 'bold',
}}></AppText>
</View>
) : (
<FlatList
ref={ListDayRef}
getItemLayout={getItemLayout}
......@@ -79,6 +91,7 @@ const NewFeed = (props) => {
keyExtractor={(item) => item.id}
renderItem={({item, index}) => <Item item={item} index={index} />}
/>
)}
</View>
);
};
......
......@@ -4,7 +4,7 @@ import {HEIGHTXD, WIDTHXD, getFontXD} from '../../../Config/Functions';
import R from '../../../assets/R';
const InputComponent = (props) => {
const {title, onChangeText, maxLength} = props;
const {title, onChangeText, maxLength, placeholder} = props;
return (
<View style={{marginVertical: 5}}>
......@@ -19,6 +19,7 @@ const InputComponent = (props) => {
<TextInput
placeholderTextColor={R.colors.placeHolder}
maxLength={maxLength}
placeholder={placeholder}
autoCapitalize="none"
onChangeText={(val) => onChangeText(val)}
style={{
......
......@@ -4,7 +4,15 @@ import {HEIGHTXD, WIDTHXD, getFontXD} from '../../Config/Functions';
import R from '../../assets/R';
const TextField = (props) => {
const {title, onChangeText, maxLength, isNumber, value, editable} = props;
const {
title,
onChangeText,
maxLength,
isNumber,
value,
editable,
placeholder,
} = props;
return (
<View style={{marginVertical: 5}}>
......@@ -18,6 +26,7 @@ const TextField = (props) => {
</Text>
<TextInput
maxLength={maxLength ? maxLength : 256}
placeholder={placeholder}
placeholderTextColor={R.colors.placeHolder}
editable={editable != null ? false : true}
autoCapitalize="none"
......
......@@ -4,7 +4,7 @@ import {HEIGHTXD, WIDTHXD, getFontXD} from '../../Config/Functions';
import R from '../../assets/R';
const TextField = (props) => {
const {title, onChangeText, maxLength, value, editable} = props;
const {title, onChangeText, maxLength, value, editable, placeholder} = props;
return (
<View style={{marginVertical: 5}}>
......@@ -19,6 +19,7 @@ const TextField = (props) => {
<TextInput
maxLength={maxLength}
textAlign={'left'}
placeholder={placeholder}
editable={editable != null ? editable : true}
value={value}
onChangeText={(val) => onChangeText(val)}
......
......@@ -290,4 +290,5 @@ export default {
'The withdrawal amount must be more than 1 million dong',
Overtime: 'Overtime OTP',
LoginSessionEnd: 'Login session end, please login again',
noteWithdrawMoney: 'Infor CQG account',
};
......@@ -290,4 +290,5 @@ export default {
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',
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