Commit fccd145b by Giang Tran

connect api product

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