Commit fccd145b by Giang Tran

connect api product

parent 76a6e782
import React, {Component, useState} from 'react'; import React, {Component, useEffect, useState} from 'react';
import { import {
View, View,
Text, Text,
...@@ -24,6 +24,9 @@ import RadioForm, { ...@@ -24,6 +24,9 @@ import RadioForm, {
RadioButtonLabel, RadioButtonLabel,
} from 'react-native-simple-radio-button'; } from 'react-native-simple-radio-button';
import {showAlert, TYPE} from '../../components/DropdownAlert';
import {getTransactionListByCategory} from '../../apis/Functions/Transaction';
var radio_props = [ var radio_props = [
{label: 'Mua', value: 'BUY'}, {label: 'Mua', value: 'BUY'},
{label: 'Bán', value: 'SALE'}, {label: 'Bán', value: 'SALE'},
...@@ -43,6 +46,8 @@ const dataType = [ ...@@ -43,6 +46,8 @@ const dataType = [
const {width} = Dimensions.get('window'); const {width} = Dimensions.get('window');
const CaculatedStopLoss = (props) => { const CaculatedStopLoss = (props) => {
const [dataProduct, setDataProduct] = useState([]);
const [product, setProduct] = useState(); const [product, setProduct] = useState();
const [type, setType] = useState('BUY'); const [type, setType] = useState('BUY');
const [lot, setLot] = useState(0); const [lot, setLot] = useState(0);
...@@ -58,6 +63,26 @@ const CaculatedStopLoss = (props) => { ...@@ -58,6 +63,26 @@ const CaculatedStopLoss = (props) => {
console.log('hello'); console.log('hello');
}; };
useEffect(() => {
getProductData();
}, []);
const getProductData = async () => {
const res = await getTransactionListByCategory({
keyword: '',
platform: Platform.OS,
page_size: 1000,
page_index: 1,
type: 'PRICE_TABLE',
category_id: -1,
});
if (res.status == 200 && res.data.code == 200) {
setDataProduct(res.data.data);
} else {
showAlert(TYPE.ERROR, I18n.t('Notification', I18n.t('Can_not_get_data')));
}
};
return ( return (
<View style={{flex: 1}}> <View style={{flex: 1}}>
<HeaderBack title={'CaculatedStopLoss'} /> <HeaderBack title={'CaculatedStopLoss'} />
...@@ -71,7 +96,7 @@ const CaculatedStopLoss = (props) => { ...@@ -71,7 +96,7 @@ const CaculatedStopLoss = (props) => {
<AppText style={styles.txtTitle} i18nKey={'Product'} /> <AppText style={styles.txtTitle} i18nKey={'Product'} />
<PickerItem <PickerItem
width={width - 20} width={width - 20}
data={dataType} data={dataProduct}
onValueChange={(value, items) => { onValueChange={(value, items) => {
setProduct(items); setProduct(items);
}} }}
......
import React, {Component, useState} from 'react'; import React, {Component, useState, useEffect} from 'react';
import { import {
View, View,
Text, Text,
...@@ -15,6 +15,8 @@ import AppText from '../../components/AppText'; ...@@ -15,6 +15,8 @@ import AppText from '../../components/AppText';
import TextField from '../../components/Input/TextField'; import TextField from '../../components/Input/TextField';
import {getFontXD, HEIGHTXD, WIDTHXD} from '../../Config/Functions'; import {getFontXD, HEIGHTXD, WIDTHXD} from '../../Config/Functions';
import R from '../../assets/R'; import R from '../../assets/R';
import {showAlert, TYPE} from '../../components/DropdownAlert';
import {getTransactionListByCategory} from '../../apis/Functions/Transaction';
const dataType = [ const dataType = [
{ {
...@@ -28,7 +30,30 @@ const dataType = [ ...@@ -28,7 +30,30 @@ const dataType = [
]; ];
const ExchangeRate = (props) => { const ExchangeRate = (props) => {
const [dataProduct, setDataProduct] = useState([]);
const [product, setProduct] = useState(); const [product, setProduct] = useState();
useEffect(() => {
getProductData();
}, []);
const getProductData = async () => {
const res = await getTransactionListByCategory({
keyword: '',
platform: Platform.OS,
page_size: 1000,
page_index: 1,
type: 'PRICE_TABLE',
category_id: -1,
});
if (res.status == 200 && res.data.code == 200) {
setDataProduct(res.data.data);
} else {
showAlert(TYPE.ERROR, I18n.t('Notification', I18n.t('Can_not_get_data')));
}
};
return ( return (
<View style={{flex: 1}}> <View style={{flex: 1}}>
<HeaderBack title={'ConvertUnit'} /> <HeaderBack title={'ConvertUnit'} />
...@@ -36,7 +61,7 @@ const ExchangeRate = (props) => { ...@@ -36,7 +61,7 @@ const ExchangeRate = (props) => {
<AppText style={styles.txtTitle} i18nKey={'Product'} /> <AppText style={styles.txtTitle} i18nKey={'Product'} />
<PickerItem <PickerItem
width={width - 20} width={width - 20}
data={dataType} data={dataProduct}
onValueChange={(value, items) => { onValueChange={(value, items) => {
setProduct(items); setProduct(items);
}} }}
......
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