Commit b0c4f993 by Giang Tran

update exchange rate

parent 89a27f91
......@@ -2,59 +2,60 @@ import React from 'react';
import {StyleSheet, Text, TouchableOpacity, View} from 'react-native';
import I18n from '../../../helper/i18/i18n';
import PickerItem from '../../../components/Picker/PickerItem';
import {getFontXD, HEIGHTXD, toPriceVnd, WIDTHXD} from '../../../Config/Functions';
import {
getFontXD,
HEIGHTXD,
toPriceVnd,
WIDTHXD,
} from '../../../Config/Functions';
import R from '../../../assets/R';
import TextMoney from '../../../components/Input/InputMoney';
import Icon from 'react-native-vector-icons/Entypo';
const ItemEscrowCalculator = (props) => {
return (
<View style={styles.viewInput}>
<Text
style={styles.textTitle}>
{I18n.t('Product')}
</Text>
<PickerItem
data={props.dataProduct}
onValueChange={(value, item) => {
props.setProduct(item);
}}
iconSize={WIDTHXD(40)}
iconColor={R.colors.black}
/>
return (
<View style={styles.viewInput}>
<Text style={styles.textTitle}>{I18n.t('Product')}</Text>
<PickerItem
data={props.dataProduct}
onValueChange={(value, item) => {
props.setProduct(item);
}}
iconSize={WIDTHXD(40)}
iconColor={R.colors.black}
/>
<TextMoney
onChangeText={(val) => {
props.setLotNumber(val);
}}
title={I18n.t('LotTransactionNumber')}
value={toPriceVnd(props.item.lotNumber)}
titleStyle={{marginTop: HEIGHTXD(20), fontSize: getFontXD(39)}}
/>
<TextMoney
onChangeText={(val) => {
}}
title={I18n.t('FirstEscrow')}
value={props.item.firstEscrow}
titleStyle={{ontSize: getFontXD(39)}}
editable={false}
inputStyle={{backgroundColor: R.colors.gray7}}
/>
</View>
);
<TextMoney
onChangeText={(val) => {
props.setLotNumber(val);
}}
title={I18n.t('LotTransactionNumber')}
value={toPriceVnd(props.item.lotNumber)}
titleStyle={{marginTop: HEIGHTXD(20), fontSize: getFontXD(39)}}
/>
<TextMoney
onChangeText={(val) => {}}
title={I18n.t('FirstEscrow')}
value={props.item.firstEscrow}
titleStyle={{ontSize: getFontXD(39)}}
editable={false}
inputStyle={{backgroundColor: R.colors.gray7}}
/>
</View>
);
};
const styles = StyleSheet.create({
viewInput: {
marginHorizontal: WIDTHXD(36),
marginBottom: WIDTHXD(30),
borderWidth: 0.3,
borderColor: '#707070',
paddingHorizontal: WIDTHXD(24),
paddingVertical: WIDTHXD(24),
},
textTitle: {
fontSize: getFontXD(39),
color: R.colors.color777,
},
})
viewInput: {
marginHorizontal: WIDTHXD(36),
marginBottom: WIDTHXD(30),
borderWidth: 0.3,
borderColor: '#707070',
paddingHorizontal: WIDTHXD(24),
paddingVertical: WIDTHXD(24),
},
textTitle: {
fontSize: getFontXD(39),
color: R.colors.color777,
},
});
export default ItemEscrowCalculator;
......@@ -13,62 +13,111 @@ import PickerItem from '../../components/Picker/PickerItem';
import I18n from '../../helper/i18/i18n';
import AppText from '../../components/AppText';
import TextField from '../../components/Input/TextField';
import {getFontXD, HEIGHTXD, WIDTHXD} from '../../Config/Functions';
import {getFontXD, HEIGHTXD, toPriceVnd, WIDTHXD} from '../../Config/Functions';
import R from '../../assets/R';
import {showAlert, TYPE} from '../../components/DropdownAlert';
import {getTransactionListByCategory} from '../../apis/Functions/Transaction';
const dataType = [
const DATA = [
{
id: 1,
name: 'Đậu tương',
value: 0.36744,
},
{
id: 2,
name: 'Khô đậu tương',
value: 1.1023,
},
{
id: 3,
name: 'Dầu đậu tương',
value: 22.0462,
},
{
id: 4,
name: 'Ngô',
value: 0.39368,
},
{
id: 5,
name: 'Lúa mỳ',
value: 0.36744,
},
{
id: 6,
name: 'Cà phê arabica',
value: 22.0462,
},
{
value: '0',
name: 'KG',
id: 7,
name: 'Cà phê Robusta',
value: 1,
},
{
id: 8,
name: 'Ca cao',
value: 1,
},
{
id: 9,
name: 'Bông',
value: 22.0462,
},
{
id: 10,
name: 'Đường',
value: 22.0462,
},
{
value: '1',
name: 'Pound',
id: 11,
name: 'Cao su',
value: 9.4,
},
];
const ExchangeRate = (props) => {
const [dataProduct, setDataProduct] = useState([]);
const [product, setProduct] = useState();
const [priceExchange, setPriceExchange] = useState();
const [usdTan, setUsdTan] = useState();
useEffect(() => {
getProductData();
}, []);
caculator();
}, [product, priceExchange]);
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')));
}
const caculator = () => {
if (product && priceExchange) {
const total = priceExchange * product.value;
setUsdTan(total + '');
} else if (!priceExchange) setUsdTan('');
};
return (
<View style={{flex: 1}}>
<HeaderBack title={'ConvertUnit'} />
<HeaderBack title={'ExchangeRate'} />
<View style={{flex: 1, paddingTop: 10, paddingHorizontal: 10}}>
<AppText style={styles.txtTitle} i18nKey={'Product'} />
<PickerItem
width={width - 20}
data={dataProduct}
data={DATA}
onValueChange={(value, items) => {
setProduct(items);
}}
/>
<TextField title={I18n.t('UnitsQuotedFloor')} />
<TextField title={I18n.t('ConversionPrice')} />
<TextField title={I18n.t('ConvertUSD')} />
<TextField
value={'US cent/ giạ'}
editable={true}
title={I18n.t('UnitsQuotedFloor')}
/>
<TextField
onChangeText={(val) => setPriceExchange(val)}
title={I18n.t('ConversionPrice')}
/>
<TextField
value={usdTan}
editable={true}
title={I18n.t('ConvertUSD')}
/>
<View style={styles.footer}>
<TouchableOpacity style={styles.btnContainer}>
<AppText style={styles.txtBtn} i18nKey={'Delete'} />
......
......@@ -144,12 +144,12 @@ const menus = [
icon: R.images.toolProfitLoss,
screen: CACULATEDPROFITLOSS,
},
{
id: '93',
title: 'CaculatedStopLoss',
icon: R.images.toolStopLoss,
screen: CACULATEDSTOPLOSS,
},
// {
// id: '93',
// title: 'CaculatedStopLoss',
// icon: R.images.toolStopLoss,
// screen: CACULATEDSTOPLOSS,
// },
{
id: '94',
title: 'ConvertUnit',
......
......@@ -19,30 +19,33 @@ const TextField = (props) => {
<TextInput
maxLength={maxLength ? maxLength : 256}
placeholderTextColor={R.colors.placeHolder}
editable={editable != null ? editable : true}
editable={editable != null ? false : true}
autoCapitalize="none"
value={value}
keyboardType={isNumber ? 'number-pad' : 'default'}
onChangeText={(val) => onChangeText(val)}
style={{
height: HEIGHTXD(109),
color: 'black',
borderRadius: 7,
borderWidth: 0.7,
borderColor: '#DBDBDB',
fontSize: getFontXD(42),
paddingVertical: 5,
paddingHorizontal: 10,
backgroundColor: 'white',
shadowColor: '#AFA9A9',
shadowOffset: {
width: 0,
height: 1,
style={[
{
height: HEIGHTXD(109),
color: 'black',
borderRadius: 7,
borderWidth: 0.7,
borderColor: '#DBDBDB',
fontSize: getFontXD(42),
paddingVertical: 5,
paddingHorizontal: 10,
shadowColor: '#AFA9A9',
shadowOffset: {
width: 0,
height: 1,
},
shadowOpacity: 0.25,
shadowRadius: 1.84,
elevation: 1,
},
shadowOpacity: 0.25,
shadowRadius: 1.84,
elevation: 1,
}}
editable ? {backgroundColor: '#DBDBDB'} : {backgroundColor: 'white'},
]}
/>
</View>
);
......
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