Commit da99951b by Nguyễn Thị Thúy

integrate api:

- category list
- price table list
parent e4849df6
...@@ -31,7 +31,7 @@ const RootView = (props) => { ...@@ -31,7 +31,7 @@ const RootView = (props) => {
<StackNavigation /> <StackNavigation />
</View> </View>
<VersionChecker/> {/*<VersionChecker/>*/}
<NoInternetComponent /> <NoInternetComponent />
</> </>
); );
......
...@@ -17,27 +17,25 @@ import R from '../../../assets/R'; ...@@ -17,27 +17,25 @@ import R from '../../../assets/R';
import Block from '../../../components/Block'; import Block from '../../../components/Block';
const Item = (props) => { const Item = (props) => {
const {item} = props; const {item, isEndItem} = props;
return ( return (
<View style={styles.container}> <View style={[styles.container, isEndItem && {marginBottom: HEIGHTXD(100)}]}>
<TouchableOpacity onPress={() => props.onPress(item)}> <TouchableOpacity onPress={() => props.onPress(item)}>
<Block flex={1} row> <Block flex={1} row>
<View style={styles.wrapDate}>
<Image source={R.images.iconRecharge} style={styles.imgIcon} /> <Image source={R.images.iconRecharge} style={styles.imgIcon} />
</View> <Block padding={[0, WIDTHXD(40)]} space={'between'} flex={1}>
<Block padding={[5, 10]} space={'between'} flex={1}>
<View <View
style={{ style={{
flex: 1, flex: 1,
flexDirection: 'row', flexDirection: 'row',
justifyContent: 'space-between', justifyContent: 'space-between',
}}> }}>
<Text numberOfLines={2} style={styles.txtBlack}> <Text numberOfLines={2} style={[styles.txtBlack, {flexWrap: 'wrap', flex: 1}]} numberOfLines={1} ellipsizeMode='tail'>
Ngô CBOT {item.name}
</Text> </Text>
<Text style={styles.txtMoney}>{toPriceVnd(300000)}</Text> <Text style={styles.txtMoney}>{toPriceVnd(item.fee)}</Text>
</View> </View>
<Text style={styles.txt}>ZCE</Text> <Text style={styles.txt}>{item.code}</Text>
</Block> </Block>
</Block> </Block>
</TouchableOpacity> </TouchableOpacity>
...@@ -49,8 +47,7 @@ export default Item; ...@@ -49,8 +47,7 @@ export default Item;
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { container: {
marginTop: 10, paddingVertical: HEIGHTXD(40),
paddingVertical: 10,
shadowColor: '#000', shadowColor: '#000',
shadowOffset: { shadowOffset: {
width: 0, width: 0,
...@@ -59,10 +56,10 @@ const styles = StyleSheet.create({ ...@@ -59,10 +56,10 @@ const styles = StyleSheet.create({
shadowOpacity: 0.25, shadowOpacity: 0.25,
shadowRadius: 3.84, shadowRadius: 3.84,
elevation: 5, elevation: 5,
marginHorizontal: 10,
backgroundColor: R.colors.white, backgroundColor: R.colors.white,
marginBottom: 10,
borderRadius: HEIGHTXD(30), borderRadius: HEIGHTXD(30),
marginVertical: HEIGHTXD(15),
marginHorizontal: WIDTHXD(30)
}, },
wrapLeft: { wrapLeft: {
...@@ -70,19 +67,14 @@ const styles = StyleSheet.create({ ...@@ -70,19 +67,14 @@ const styles = StyleSheet.create({
borderTopLeftRadius: HEIGHTXD(30), borderTopLeftRadius: HEIGHTXD(30),
borderBottomStartRadius: HEIGHTXD(30), borderBottomStartRadius: HEIGHTXD(30),
}, },
wrapDate: {
justifyContent: 'center',
paddingHorizontal: 10,
},
txtTitle: { txtTitle: {
fontSize: getFontXD(42), fontSize: getFontXD(42),
color: R.colors.black, color: R.colors.black,
fontWeight: 'bold', fontWeight: 'bold',
}, },
txt: { txt: {
fontSize: getFontXD(39), fontSize: getFontXD(36),
color: '#929292', color: 'black',
fontStyle: 'italic',
}, },
rowBet: { rowBet: {
flexDirection: 'row', flexDirection: 'row',
...@@ -90,14 +82,14 @@ const styles = StyleSheet.create({ ...@@ -90,14 +82,14 @@ const styles = StyleSheet.create({
alignItems: 'center', alignItems: 'center',
}, },
txtBlack: { txtBlack: {
fontSize: getFontXD(42), fontSize: getFontXD(50),
color: 'black', color: 'black',
fontWeight: 'bold',
}, },
imgIcon: { imgIcon: {
width: WIDTHXD(178), width: WIDTHXD(150),
height: HEIGHTXD(178), height: HEIGHTXD(150),
resizeMode: 'contain', resizeMode: 'contain',
marginLeft: WIDTHXD(35)
}, },
txtMoney: { txtMoney: {
fontSize: getFontXD(42), fontSize: getFontXD(42),
......
import React, {useState, useEffect} from 'react'; import React, {useState, useEffect} from 'react';
import {getListNotification} from '../../../apis/Functions/users'; import {getListCategoryProduct, getTransactionListByCategory} from '../../../apis/Functions/Transaction';
import PriceListView from './PriceListView'; import PriceListView from './PriceListView';
import I18n from '../../../helper/i18/i18n'; import I18n from '../../../helper/i18/i18n';
import {Alert, Platform} from 'react-native';
const PriceList = (props) => { const PriceList = (props) => {
const [selected, setSelected] = useState(''); const [selected, setSelected] = useState('');
const [page, setPage] = useState(1); const [page, setPage] = useState(1);
const [data, setData] = useState([]); const [data, setData] = useState([]);
const [tottalPage, setTotalPage] = useState(1); const [tottalPage, setTotalPage] = useState(1);
const [isRefresh, setisRefresh] = useState(false); const [isRefresh, setIsRefresh] = useState(false);
const [fillter, setFillters] = useState('ALL'); const [filters, setFilters] = useState([]);
const [filterId, setFilterId] = useState(-1);
useEffect(() => {
getCategoryData();
}, []);
useEffect(() => {
setData([])
getData();
}, [filterId]);
useEffect(() => { const getCategoryData = async () => {
getData(); // setIsRefresh(true);
}, [fillter]); const res = await getListCategoryProduct({
keyword: '',
platform: Platform.OS,
page_size: 20,
page_index: 1,
type: 'PRODUCT',
});
if ((res.data.code = 200 && res.data.data)) {
let data = [];
data.push({id: -1, name: 'All'});
setFilters(data.concat([...res.data.data]));
} else {
Alert.alert(I18n.t('Notification'), res.data.message);
}
};
const getData = async () => { const onRefresh = () => {
setisRefresh(true); setPage(1);
setPage(1); getData();
const res = await getListNotification({ };
keyword: '',
platform: Platform.OS,
page_size: 10,
page_index: 1,
type: fillter,
});
setisRefresh(false);
if ((res.data.code = 200 && res.data.data)) {
setData(res.data.data);
setTotalPage(res.data.meta.pages);
} else {
Alert.alert(I18n.t('Notification'), res.data.message);
}
};
const onRefresh = () => { const getData = async () => {
getData(); setIsRefresh(true);
}; setPage(1);
const res = await getTransactionListByCategory({
keyword: '',
platform: Platform.OS,
page_size: 10,
page_index: 1,
category_id: filterId,
});
setIsRefresh(false);
console.log('getData', res);
if ((res.data.code = 200 && res.data.data)) {
setData(res.data.data);
setTotalPage(res.data.meta.pages);
} else {
Alert.alert(I18n.t('Notification'), res.data.message);
}
};
const onLoadMore = () => { const onLoadMore = () => {
console.log(tottalPage); console.log(tottalPage);
if (page < tottalPage) getDataLoadMore(); if (page < tottalPage) {
}; getDataLoadMore();
}
};
const getDataLoadMore = async () => { const getDataLoadMore = async () => {
setisRefresh(true); setIsRefresh(true);
const res = await getListNotification({ const res = await getTransactionListByCategory({
keyword: '', keyword: '',
platform: Platform.OS, platform: Platform.OS,
page_size: 10, page_size: 10,
page_index: 1, page_index: page + 1,
type: fillter, category_id: filterId,
}); });
setPage(page + 1); setPage(page + 1);
if (res.data.code == 200) { if (res.data.code == 200) {
setData(data.concat(res.data.data)); setData(data.concat(res.data.data));
} }
setisRefresh(false); setIsRefresh(false);
}; };
return ( return (
<PriceListView <PriceListView
onRefresh={onRefresh} onRefresh={onRefresh}
isRefresh={isRefresh} isRefresh={isRefresh}
onLoadMore={onLoadMore} onLoadMore={onLoadMore}
setFillters={setFillters} setFilterId={setFilterId}
fillter={fillter} filterId={filterId}
data={data} filters={filters}
/> data={data}
); />
);
}; };
export default PriceList; export default PriceList;
import React, {useState} from 'react'; import React, {useState} from 'react';
import { import {
View, View,
Text, Text,
FlatList, FlatList,
StyleSheet, StyleSheet,
TouchableOpacity, TouchableOpacity,
ScrollView, ScrollView,
} from 'react-native'; } from 'react-native';
import HeaderDrawer from '../../../components/Header/HeaderDrawer'; import HeaderDrawer from '../../../components/Header/HeaderDrawer';
import Item from './Item'; import Item from './Item';
import {getFontXD} from '../../../Config/Functions'; import {getFontXD, HEIGHTXD} from '../../../Config/Functions';
import AppText from '../../../components/AppText'; import AppText from '../../../components/AppText';
import {PRODUCTDETAIL} from '../../../routers/ScreenNames'; import {PRODUCTDETAIL} from '../../../routers/ScreenNames';
import {useNavigation} from '@react-navigation/native'; import {useNavigation} from '@react-navigation/native';
const Fillters = [ const Fillters = [
{ {
id: '1', id: '1',
name: 'All', name: 'All',
value: 'ALL', value: 'ALL',
}, },
{ {
id: '2', id: '2',
name: 'Deposit', name: 'Deposit',
value: 'DEPOSIT', value: 'DEPOSIT',
}, },
{ {
id: '3', id: '3',
name: 'Withdraw', name: 'Withdraw',
value: 'WITHDRAW', value: 'WITHDRAW',
}, },
{ {
id: '4', id: '4',
name: 'Transfer', name: 'Transfer',
value: 'TRANSFER', value: 'TRANSFER',
}, },
]; ];
const NotificaitonView = (props) => { const PriceListView = (props) => {
const {onRefresh, isRefresh, onLoadMore, setFillters, fillter, data} = props; const {onRefresh, isRefresh, onLoadMore, setFilterId, filters, data, filterId} = props;
const navigate = useNavigation(); const navigate = useNavigation();
return (
<View style={{flex: 1}}>
<View style={styles.headerContainer}>
<ScrollView horizontal showsHorizontalScrollIndicator={false}>
{filters.map((e) => (
<TouchableOpacity
key={e.id}
onPress={() => setFilterId(e.id)}
style={[
styles.itemFillter,
filterId == e.id ? {borderColor: '#1473E6'} : null,
]}>
<Text
style={[
styles.txtFillter,
filterId == e.id ? {color: '#1473E6'} : {},
]}>{e.name}</Text>
</TouchableOpacity>
))}
</ScrollView>
</View>
return ( {data.length == 0 && !isRefresh? (
<View style={{flex: 1}}> <View style={{justifyContent: 'center', alignItems: 'center', flex: 1}}>
<View style={styles.headerContainer}> <AppText
<ScrollView horizontal showsHorizontalScrollIndicator={false}> i18nKey={'NoData'}
{Fillters.map((e) => ( style={{
<TouchableOpacity fontSize: 18,
key={e.value} fontWeight: 'bold',
onPress={() => setFillters(e.value)} }}></AppText>
style={[ </View>
styles.itemFillter, ) : (
fillter == e.value ? {borderColor: '#1473E6'} : null, <FlatList
]}> style={{paddingVertical: HEIGHTXD(15)}}
<AppText keyExtractor={(item) => item.id}
i18nKey={e.name} data={data}
style={[ refreshing={isRefresh}
styles.txtFillter, onRefresh={onRefresh}
fillter == e.value ? {color: '#1473E6'} : {}, onEndReachedThreshold={0.01}
]}></AppText> onEndReached={(info) => {
</TouchableOpacity> onLoadMore();
))} }}
</ScrollView> renderItem={({item, index}) => <Item item={item}
</View> isEndItem={index == data.length -1}
onPress={(item) => navigate.navigate(PRODUCTDETAIL)}/>}
{data.length == 0 ? ( />
<View style={{justifyContent: 'center', alignItems: 'center', flex: 1}}> )}
<AppText
i18nKey={'NoData'}
style={{
fontSize: 18,
fontWeight: 'bold',
}}></AppText>
</View> </View>
) : ( );
<FlatList
keyExtractor={(item) => item.id}
data={data}
refreshing={isRefresh}
onRefresh={onRefresh}
onEndReachedThreshold={0.01}
onEndReached={(info) => {
onLoadMore();
}}
renderItem={({item}) => <Item item={item}
onPress={(item) => navigate.navigate(PRODUCTDETAIL)}/>}
/>
)}
</View>
);
}; };
const styles = StyleSheet.create({ const styles = StyleSheet.create({
headerContainer: { headerContainer: {
paddingVertical: 10, paddingVertical: 10,
backgroundColor: 'white', backgroundColor: 'white',
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', alignItems: 'center',
paddingHorizontal: 10, paddingHorizontal: 10,
}, },
itemFillter: { itemFillter: {
borderRadius: 10, borderRadius: 10,
paddingVertical: 5, paddingVertical: 5,
paddingHorizontal: 10, paddingHorizontal: 10,
borderWidth: 1, borderWidth: 1,
borderColor: '#929292', borderColor: '#929292',
justifyContent: 'center', justifyContent: 'center',
alignItems: 'center', alignItems: 'center',
marginRight: 10, marginRight: 10,
}, },
txtFillter: { txtFillter: {
fontSize: getFontXD(36), fontSize: getFontXD(36),
color: '#929292', color: '#929292',
fontWeight: 'bold', fontWeight: 'bold',
}, },
txtTitle: { txtTitle: {
fontSize: getFontXD(46), fontSize: getFontXD(46),
fontWeight: 'bold', fontWeight: 'bold',
}, },
}); });
export default NotificaitonView; export default PriceListView;
import {GetData} from '../helpers';
import url from '../url';
export const getListCategoryProduct = async (body) =>
GetData(url.urlGetCategoryNew, body)
.then((res) => res)
.catch((err) => err);
export const getTransactionListByCategory = async (body) =>
GetData(url.urlGetTransactionListByCategory, body)
.then((res) => res)
.catch((err) => err);
...@@ -38,4 +38,7 @@ export default { ...@@ -38,4 +38,7 @@ export default {
urlUpdateLanguage: root + 'api/v1/customers/update-language', urlUpdateLanguage: root + 'api/v1/customers/update-language',
urlGetNewestVersionInfo: root + 'api/v1/settings/version', urlGetNewestVersionInfo: root + 'api/v1/settings/version',
//Transaction
urlGetTransactionListByCategory: `${root}api/v1/transactions/price-table`,
}; };
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