Commit 3cbaf332 by Giang Tran

update code

parent 127b4bc6
...@@ -31,12 +31,12 @@ const AccountVerificationView = (props) => { ...@@ -31,12 +31,12 @@ const AccountVerificationView = (props) => {
}}> }}>
<Tab.Screen <Tab.Screen
name="GeneralInfor" name="GeneralInfor"
component={props.user.status == 2 ? GeneralInfor : GeneralView} component={props.user.status == 1 ? GeneralInfor : GeneralView}
options={{tabBarLabel: 'Thông tin chung'}} options={{tabBarLabel: 'Thông tin chung'}}
/> />
<Tab.Screen <Tab.Screen
name="Profile" name="Profile"
component={props.user.status == 2 ? Profile : ProfileView} component={props.user.status == 1 ? Profile : ProfileView}
options={{tabBarLabel: 'Hồ sơ'}} options={{tabBarLabel: 'Hồ sơ'}}
/> />
</Tab.Navigator> </Tab.Navigator>
......
...@@ -10,6 +10,8 @@ import { ...@@ -10,6 +10,8 @@ import {
ScrollView, ScrollView,
Platform, Platform,
Dimensions, Dimensions,
TouchableWithoutFeedback,
Keyboard,
} from 'react-native'; } from 'react-native';
import Button from '../../../components/Button'; import Button from '../../../components/Button';
import PickerImgUni from '../../../components/Picker/PickerImgUni'; import PickerImgUni from '../../../components/Picker/PickerImgUni';
...@@ -207,10 +209,10 @@ const Profile = (props) => { ...@@ -207,10 +209,10 @@ const Profile = (props) => {
/> />
</View> </View>
</View> </View>
<View style={styles.btnSend}>
<Button title={'Xác minh'} onClick={onPress} />
</View>
</ScrollView> </ScrollView>
<View style={styles.btnSend}>
<Button title={'Xác minh'} onClick={onPress} />
</View>
</TouchableWithoutFeedback> </TouchableWithoutFeedback>
</KeyboardAvoidingView> </KeyboardAvoidingView>
); );
...@@ -219,7 +221,7 @@ const Profile = (props) => { ...@@ -219,7 +221,7 @@ const Profile = (props) => {
const styles = StyleSheet.create({ const styles = StyleSheet.create({
btnSend: { btnSend: {
width: '100%', width: '100%',
marginBottom: 10, marginVertical: 30,
}, },
btnNext: { btnNext: {
borderRadius: 30, borderRadius: 30,
......
import React from 'react'; import React, {useState, useEffect} from 'react';
import {Alert} from 'react-native';
import HistoryView from './HistoryView'; import HistoryView from './HistoryView';
import {getListTransaction} from '../../../apis/Functions/Widthdraw';
const History = (props) => { const History = (props) => {
return <HistoryView />; const [selected, setSelected] = useState('');
const [page, setPage] = useState(1);
const [data, setData] = useState([]);
const [tottalPage, setTotalPage] = useState(1);
const [isRefresh, setisRefresh] = useState(false);
const [fillters, setFillters] = useState([]);
useEffect(() => {
getData();
}, []);
// useEffect(() => {
// getData();
// }, [selected]);
const getData = async () => {
setisRefresh(true);
setPage(1);
const res = await getListTransaction({
keyword: '',
type: 'ALL',
platform: Platform.OS,
page_size: 10,
page_index: 1,
start_date: '',
end_date: '',
});
console.log(res);
setisRefresh(false);
if ((res.data.code = 200 && res.data.data)) {
setData(res.data.data);
setTotalPage(res.data.meta.pages);
} else {
Alert.alert('Thông báo!', res.data.message);
}
};
const onRefresh = () => {
getData();
};
const onLoadMore = () => {
console.log(tottalPage);
// if (page < tottalPage) getDataLoadMore();
};
const getDataLoadMore = async () => {
setisRefresh(true);
const res = await getListNew({
keyword: '',
category_id: selected,
platform: Platform.OS,
page_size: 10,
page_index: page + 1,
});
setPage(page + 1);
if (res.data.code == 200) {
setData(data.concat(res.data.data));
}
setisRefresh(false);
};
return (
<HistoryView
onLoadMore={onLoadMore}
isRefresh={isRefresh}
onRefresh={onRefresh}
data={data}
/>
);
}; };
export default History; export default History;
import React, {useState} from 'react'; import React, {useState} from 'react';
import {View, Text, FlatList, TouchableOpacity, StyleSheet} from 'react-native'; import {View, Text, FlatList, TouchableOpacity, StyleSheet} from 'react-native';
import HeaderSB from '../../../components/Header/HeaderSB'; import HeaderBack from '../../../components/Header/HeaderBack';
import Item from './Item'; import Item from './Item';
import {getFontXD} from '../../../Config/Functions'; import {getFontXD} from '../../../Config/Functions';
const Fillters = [ const Fillters = [
...@@ -27,50 +27,65 @@ const Fillters = [ ...@@ -27,50 +27,65 @@ const Fillters = [
}, },
]; ];
const data = [ // const data = [
{ // {
id: '1', // id: '1',
money: 10000000, // money: 10000000,
content: 'Hoạt động: Nạp tiền', // content: 'Hoạt động: Nạp tiền',
status: 1, // status: 1,
date: '20/02/2021', // date: '20/02/2021',
}, // },
{ // {
id: '2', // id: '2',
money: 2000000, // money: 2000000,
content: 'Hoạt động: Nạp tiền', // content: 'Hoạt động: Nạp tiền',
status: 1, // status: 1,
date: '20/02/2021', // date: '20/02/2021',
}, // },
{ // {
id: '3', // id: '3',
day: '20', // day: '20',
money: 3000000, // money: 3000000,
content: 'Hoạt động: Nạp tiền', // content: 'Hoạt động: Nạp tiền',
status: 1, // status: 1,
date: '20/02/2021', // date: '20/02/2021',
}, // },
{ // {
id: '4', // id: '4',
money: 4000000, // money: 4000000,
content: 'Hoạt động: Rút tiền', // content: 'Hoạt động: Rút tiền',
status: 2, // status: 2,
date: '20/02/2021', // date: '20/02/2021',
}, // },
{ // {
id: '5', // id: '5',
money: 9000000, // money: 9000000,
content: 'Hoạt động: Nạp tiền', // content: 'Hoạt động: Nạp tiền',
status: 1, // status: 1,
date: '20/02/2021', // date: '20/02/2021',
}, // },
]; // {
// id: '6',
// money: 4000000,
// content: 'Hoạt động: Rút tiền',
// status: 2,
// date: '20/02/2021',
// },
// {
// id: '7',
// money: 9000000,
// content: 'Hoạt động: Nạp tiền',
// status: 1,
// date: '20/02/2021',
// },
// ];
const HistoryView = (props) => { const HistoryView = (props) => {
const {isRefresh, onRefresh, onLoadMore, data} = props;
const [selected, setSelected] = useState('1'); const [selected, setSelected] = useState('1');
return ( return (
<View style={{flex: 1}}> <View style={{flex: 1}}>
<HeaderSB title={'LỊCH SỬ'} /> <HeaderBack isWhite={true} title={'LỊCH SỬ'} />
<View style={{flex: 1}}> <View style={{flex: 1}}>
<View style={styles.headerContainer}> <View style={styles.headerContainer}>
<FlatList <FlatList
...@@ -97,6 +112,13 @@ const HistoryView = (props) => { ...@@ -97,6 +112,13 @@ const HistoryView = (props) => {
/> />
</View> </View>
<FlatList <FlatList
style={{flex: 1}}
refreshing={isRefresh}
onRefresh={onRefresh}
onEndReachedThreshold={0.01}
onEndReached={(info) => {
onLoadMore();
}}
keyExtractor={(item) => item.id} keyExtractor={(item) => item.id}
data={data} data={data}
renderItem={({item}) => <Item item={item} />} renderItem={({item}) => <Item item={item} />}
......
...@@ -90,7 +90,7 @@ const styles = StyleSheet.create({ ...@@ -90,7 +90,7 @@ const styles = StyleSheet.create({
elevation: 5, elevation: 5,
marginHorizontal: 10, marginHorizontal: 10,
backgroundColor: R.colors.white, backgroundColor: R.colors.white,
marginTop: 10, marginVertical: 5,
borderRadius: HEIGHTXD(30), borderRadius: HEIGHTXD(30),
}, },
wrapRight: { wrapRight: {
......
...@@ -7,6 +7,9 @@ import { ...@@ -7,6 +7,9 @@ import {
TouchableOpacity, TouchableOpacity,
Platform, Platform,
Alert, Alert,
TouchableWithoutFeedback,
Keyboard,
KeyboardAvoidingView,
} from 'react-native'; } from 'react-native';
import R from '../../../assets/R'; import R from '../../../assets/R';
import HeaderBack from '../../../components/Header/HeaderBack'; import HeaderBack from '../../../components/Header/HeaderBack';
...@@ -25,6 +28,8 @@ import RadioForm from 'react-native-simple-radio-button'; ...@@ -25,6 +28,8 @@ import RadioForm from 'react-native-simple-radio-button';
import {widthDraw, getListWidthDraw} from '../../../apis/Functions/Widthdraw'; import {widthDraw, getListWidthDraw} from '../../../apis/Functions/Widthdraw';
import {useNavigation} from '@react-navigation/native'; import {useNavigation} from '@react-navigation/native';
import {showLoading, hideLoading} from '../../../actions/loadingAction'; import {showLoading, hideLoading} from '../../../actions/loadingAction';
import {confirmAlert} from '../../../components/Aleart';
import {ADDMETHODPAY} from '../../../routers/ScreenNames';
var radio_props = [ var radio_props = [
{label: 'Từ ví', value: 'WALLET'}, {label: 'Từ ví', value: 'WALLET'},
...@@ -42,19 +47,29 @@ const WalletWithdraw = (props) => { ...@@ -42,19 +47,29 @@ const WalletWithdraw = (props) => {
const navigate = useNavigation(); const navigate = useNavigation();
useEffect(() => { useEffect(() => {
getData(); const unsubscribe = navigate.addListener('focus', () => {
}, []); getData();
});
return unsubscribe;
}, [navigate]);
const getData = async () => { const getData = async () => {
const res = await getListWidthDraw({ const res = await getListWidthDraw({
platform: Platform.OS, platform: Platform.OS,
}); });
if (res.data.code == 200 && res.data.data) { if (res.data.code == 200 && res.data.data) {
console.log(res.data.data); if (res.data.data.length == 0) {
const newList = res.data.data.map((e) => { confirmAlert(
return {...e, value: e.id, name: e.method}; 'Bạn chưa có phương thức thanh toán.Đi đến cài đặt phương thức thanh toán?',
}); () => navigate.navigate(ADDMETHODPAY),
setData(newList); );
} else {
const newList = res.data.data.map((e) => {
return {...e, value: e.id, name: e.method};
});
setData(newList);
}
} else { } else {
alert('Không lấy được danh sách phương thức!'); alert('Không lấy được danh sách phương thức!');
} }
...@@ -94,10 +109,15 @@ const WalletWithdraw = (props) => { ...@@ -94,10 +109,15 @@ const WalletWithdraw = (props) => {
}; };
return ( return (
<View style={{flex: 1}}> <KeyboardAvoidingView
<HeaderBack title={'Rút tiền'} /> behavior={Platform.Os === 'ios' ? 'padding' : 'height'}
<View style={styles.container}> style={{flex: 1}}
{/* <View style={styles.wrapTop}> keyboardVerticalOffset={-50}>
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
<View style={{flex: 1}}>
<HeaderBack title={'Rút tiền'} />
<View style={styles.container}>
{/* <View style={styles.wrapTop}>
<View style={styles.itemTop}> <View style={styles.itemTop}>
<Text style={styles.txtTitle}>Ví</Text> <Text style={styles.txtTitle}>Ví</Text>
<Text style={styles.txtMoney}>{toPriceVnd(1000000)}</Text> <Text style={styles.txtMoney}>{toPriceVnd(1000000)}</Text>
...@@ -109,53 +129,57 @@ const WalletWithdraw = (props) => { ...@@ -109,53 +129,57 @@ const WalletWithdraw = (props) => {
<Text style={styles.txtMoney}>{toPriceVnd(1000000)}</Text> <Text style={styles.txtMoney}>{toPriceVnd(1000000)}</Text>
</View> </View>
</View> */} </View> */}
<View style={styles.wrapBody}> <View style={styles.wrapBody}>
<Text <Text
style={{ style={{
fontSize: getFontXD(42), fontSize: getFontXD(42),
color: R.colors.color777, color: R.colors.color777,
}}> }}>
Tài khon ngun Tài khon ngun
</Text> </Text>
{/* <View style={styles.row}> */} {/* <View style={styles.row}> */}
<RadioForm <RadioForm
radio_props={radio_props} radio_props={radio_props}
labelStyle={{fontSize: getFontXD(42)}} labelStyle={{fontSize: getFontXD(42)}}
formHorizontal={true} formHorizontal={true}
style={styles.row} style={styles.row}
initial={0} initial={0}
onPress={(value) => { onPress={(value) => {
setSrc(value); setSrc(value);
}} }}
/> />
{/* </View> */} {/* </View> */}
<Text <Text
style={{ style={{
fontSize: getFontXD(42), fontSize: getFontXD(42),
color: R.colors.color777, color: R.colors.color777,
}}> }}>
Chn tài khon hưởng th Chn tài khon hưởng th
</Text> </Text>
<PickerItem <PickerItem
width={width - 20} width={width - 20}
data={data} data={data}
onValueChange={(value, items) => { onValueChange={(value, items) => {
setType(items); setType(items);
}} }}
/> />
<TextField
<TextField onChangeText={(val) => setAmount(val)}
onChangeText={(val) => setAmount(val)} title={'Số tiền'}
title={'Số tiền'} isNumber={true}
isNumber={true} />
/> <TextMulti
<TextMulti onChangeText={(val) => setNotes(val)} title={'Ghi chú'} /> onChangeText={(val) => setNotes(val)}
title={'Ghi chú'}
/>
</View>
</View>
<TouchableOpacity onPress={onPressWithdraw} style={styles.btnSend}>
<Text style={styles.txtSend}>Rút tin</Text>
</TouchableOpacity>
</View> </View>
</View> </TouchableWithoutFeedback>
<TouchableOpacity onPress={onPressWithdraw} style={styles.btnSend}> </KeyboardAvoidingView>
<Text style={styles.txtSend}>Rút tin</Text>
</TouchableOpacity>
</View>
); );
}; };
......
...@@ -10,7 +10,8 @@ const Home = (props) => { ...@@ -10,7 +10,8 @@ const Home = (props) => {
useEffect(() => { useEffect(() => {
getData(); getData();
}, []); }, []);
console.log();
props.user;
const getData = async () => { const getData = async () => {
const res = await getTransaction({}); const res = await getTransaction({});
if (res.data.code == 200 && res.data.data) { if (res.data.code == 200 && res.data.data) {
......
import React, {Component, useState, useEffect} from 'react'; import React, {Component, useState, useEffect, useRef} from 'react';
import {View, Text, Platform, FlatList} from 'react-native'; import {View, Text, Platform, FlatList} from 'react-native';
import {getListCalendar} from '../../../apis/Functions/NewFeed'; import {getListCalendar} from '../../../apis/Functions/NewFeed';
import {convertTimeApi} from '../../../Config/Functions'; import {convertTimeApi} from '../../../Config/Functions';
...@@ -6,10 +6,14 @@ import {convertTimeApi} from '../../../Config/Functions'; ...@@ -6,10 +6,14 @@ import {convertTimeApi} from '../../../Config/Functions';
import Item from './item'; import Item from './item';
const NewFeed = (props) => { const NewFeed = (props) => {
const [data, setData] = useState([]); const [data, setData] = useState([]);
const ListDayRef = useRef(null);
useEffect(() => { useEffect(() => {
getData(); getData();
}, []); }, []);
useEffect(() => {
scrollToCurrent();
}, [data]);
const getData = async () => { const getData = async () => {
var date = new Date(), var date = new Date(),
...@@ -30,6 +34,34 @@ const NewFeed = (props) => { ...@@ -30,6 +34,34 @@ const NewFeed = (props) => {
} }
}; };
const scrollToCurrent = () => {
const date = new Date();
let index = 0;
const today = convertTimeApi(date);
if (data.length > 0) {
for (var i = 0; i < data.length; i++) {
if (data[i].start_date.substring(0, 10) == today) {
index = i;
break;
}
}
setTimeout(() => {
ListDayRef.current.scrollToIndex({
animated: true,
index: index,
});
}, 200);
}
};
const getItemLayout = (data, index) => ({
length: 100,
offset: 80 * index,
index,
});
return ( return (
<View <View
style={{ style={{
...@@ -40,6 +72,8 @@ const NewFeed = (props) => { ...@@ -40,6 +72,8 @@ const NewFeed = (props) => {
paddingTop: 10, paddingTop: 10,
}}> }}>
<FlatList <FlatList
ref={ListDayRef}
getItemLayout={getItemLayout}
data={data} data={data}
showsVerticalScrollIndicator={false} showsVerticalScrollIndicator={false}
keyExtractor={(item) => item.id} keyExtractor={(item) => item.id}
......
import React, {Component} from 'react'; import React, {Component} from 'react';
import {View, Text, StyleSheet, TouchableOpacity} from 'react-native'; import {View, Text, StyleSheet} from 'react-native';
import R from '../../../assets/R'; import R from '../../../assets/R';
import Block from '../../../components/Block'; import Block from '../../../components/Block';
import {getFontXD} from '../../../Config/Functions'; import {getFontXD} from '../../../Config/Functions';
...@@ -7,9 +7,7 @@ import {convertDate} from '../../../Config/Functions'; ...@@ -7,9 +7,7 @@ import {convertDate} from '../../../Config/Functions';
const Item = (props) => { const Item = (props) => {
const {title, date, time, start_date} = props.item; const {title, date, time, start_date} = props.item;
return ( return (
<TouchableOpacity <View style={styles.container}>
onPress={() => console.log('hello')}
style={styles.container}>
<View style={styles.left}> <View style={styles.left}>
<View style={styles.dot} /> <View style={styles.dot} />
</View> </View>
...@@ -20,7 +18,7 @@ const Item = (props) => { ...@@ -20,7 +18,7 @@ const Item = (props) => {
</View> </View>
<Text style={styles.txtTitle}>{title}</Text> <Text style={styles.txtTitle}>{title}</Text>
</View> </View>
</TouchableOpacity> </View>
); );
}; };
......
...@@ -16,7 +16,7 @@ const NewFeed = (props) => { ...@@ -16,7 +16,7 @@ const NewFeed = (props) => {
<View style={{flex: 1}}> <View style={{flex: 1}}>
<HeaderDrawer title={'Tin tức'} isWhite={true} /> <HeaderDrawer title={'Tin tức'} isWhite={true} />
<View style={{flex: 1, backgroundColor: 'white'}}> <View style={{flex: 1, backgroundColor: 'white'}}>
<Tab.Navigator {/* <Tab.Navigator
initialRouteName="GeneralInfor" initialRouteName="GeneralInfor"
swipeEnabled={false} swipeEnabled={false}
tabBarOptions={{ tabBarOptions={{
...@@ -52,6 +52,7 @@ const NewFeed = (props) => { ...@@ -52,6 +52,7 @@ const NewFeed = (props) => {
options={{tabBarLabel: 'Biểu đồ'}} options={{tabBarLabel: 'Biểu đồ'}}
/> />
</Tab.Navigator> </Tab.Navigator>
*/}
</View> </View>
</View> </View>
); );
......
...@@ -29,3 +29,8 @@ export const updateMethodBank = async (body) => ...@@ -29,3 +29,8 @@ export const updateMethodBank = async (body) =>
PostData(url.urlUpdateMethodBank, body) PostData(url.urlUpdateMethodBank, body)
.then((res) => res) .then((res) => res)
.catch((err) => err); .catch((err) => err);
export const getListTransaction = async (body) =>
GetData(url.urlGetListHistory, body)
.then((res) => res)
.catch((err) => err);
...@@ -24,4 +24,7 @@ export default { ...@@ -24,4 +24,7 @@ export default {
//Home //Home
urlGetTransaction: root + 'api/v1/customers/statistic-transaction', urlGetTransaction: root + 'api/v1/customers/statistic-transaction',
//History
urlGetListHistory: root + 'api/v1/customers/get-list-transaction-history',
}; };
import {Alert} from 'react-native';
export const NotificationAlert = (string) => {
Alert.alert('Thông báo', string);
};
export const confirmAlert = (title, callback) => {
Alert.alert(
'Thông báo',
title,
[
{
text: 'Hủy',
style: 'cancel',
},
{
text: 'Đồng ý',
onPress: () => {
callback();
},
},
],
{cancelable: false},
);
};
//@ts-ignore
import { Alert } from 'react-native';
const AlertMessage = (message: string, title?: string, onPressOk?: any, cancel?: boolean) => {
Alert.alert(
title || '',
message,
cancel
? [
{
text: 'Đồng ý',
onPress: () => {
if (typeof onPressOk === 'function') {
onPressOk();
}
},
style: 'default',
},
]
: [
{
text:"Từ chối",
onPress: () => {
if (typeof onPressOk === 'function') {
onPressOk();
}
},
},
],
{ cancelable: false },
);
};
export default AlertMessage;
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