Commit 3cbaf332 by Giang Tran

update code

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