Commit 9d789f65 by Nguyễn Thị Thúy

Merge branch 'phase2_tool' into 'dev_phase2'

complete escrow calculator

See merge request !13
parents 1a31e058 ff0a6cfa
import React, {useEffect, useRef} from 'react'; import React, {useEffect, useRef} from 'react';
import { import {
View, View,
Text,
ImageBackground,
StyleSheet,
StatusBar,
SafeAreaView,
} from 'react-native'; } from 'react-native';
import {connect} from 'react-redux'; import {connect} from 'react-redux';
...@@ -16,7 +11,6 @@ import {enableScreens} from 'react-native-screens'; ...@@ -16,7 +11,6 @@ import {enableScreens} from 'react-native-screens';
import NoInternetComponent from './components/NoInternet'; import NoInternetComponent from './components/NoInternet';
import DropdownAlert from 'react-native-dropdownalert'; import DropdownAlert from 'react-native-dropdownalert';
import DeviceInfo from 'react-native-device-info'; import DeviceInfo from 'react-native-device-info';
import VersionChecker from './Screens/VersionChecker';
import R from './assets/R'; import R from './assets/R';
import {WIDTHXD, HEIGHTXD} from './Config/Functions'; import {WIDTHXD, HEIGHTXD} from './Config/Functions';
import DropdownManager from './components/DropdownAlert/DropdownManager'; import DropdownManager from './components/DropdownAlert/DropdownManager';
...@@ -34,20 +28,14 @@ const RootView = (props) => { ...@@ -34,20 +28,14 @@ const RootView = (props) => {
const dropDownAlertRef = useRef(null); const dropDownAlertRef = useRef(null);
const dropDownAlertLongTimeRef = useRef(null); const dropDownAlertLongTimeRef = useRef(null);
const checkVersion = (props) => {
const verCurrent = DeviceInfo.getVersion();
console.log('version current', verCurrent);
};
return ( return (
<> <>
<View style={{flex: 1}}> <View style={{flex: 1}}>
<Modal isVisible={props.loadingModal.isVisible}> <Modal isVisible={props.loadingModal.isVisible}>
<SkypeIndicator color={'white'} /> <SkypeIndicator color={'white'}/>
</Modal> </Modal>
<StackNavigation /> <StackNavigation/>
</View> </View>
{/*<VersionChecker/>*/}
<DropdownAlert <DropdownAlert
inactiveStatusBarBackgroundColor={R.colors.main} inactiveStatusBarBackgroundColor={R.colors.main}
activeStatusBarBackgroundColor={R.colors.main} activeStatusBarBackgroundColor={R.colors.main}
...@@ -86,8 +74,7 @@ const RootView = (props) => { ...@@ -86,8 +74,7 @@ const RootView = (props) => {
paddingHorizontal: WIDTHXD(20), paddingHorizontal: WIDTHXD(20),
}} }}
/> />
<NoInternetComponent/>
<NoInternetComponent />
</> </>
); );
}; };
......
...@@ -11,6 +11,7 @@ import {getListCategoryProduct} from '../../apis/Functions/Transaction'; ...@@ -11,6 +11,7 @@ import {getListCategoryProduct} from '../../apis/Functions/Transaction';
import {hideLoading, showLoading} from '../../actions/loadingAction'; import {hideLoading, showLoading} from '../../actions/loadingAction';
import _ from 'lodash'; import _ from 'lodash';
import {showAlert, TYPE} from '../../components/DropdownAlert/index'; import {showAlert, TYPE} from '../../components/DropdownAlert/index';
import VersionChecker from '../VersionChecker';
const Home = (props) => { const Home = (props) => {
const [data, setData] = useState({total_deposit: 0, total_withdraw: 0}); const [data, setData] = useState({total_deposit: 0, total_withdraw: 0});
...@@ -111,7 +112,9 @@ const Home = (props) => { ...@@ -111,7 +112,9 @@ const Home = (props) => {
const onSortByName = () => { const onSortByName = () => {
let type = 'ASC'; let type = 'ASC';
if (!isSortName || isSortName == SORT_TYPE.ASC) type = SORT_TYPE.DESC; if (!isSortName || isSortName == SORT_TYPE.ASC) {
type = SORT_TYPE.DESC;
}
let newData = let newData =
type == SORT_TYPE.ASC type == SORT_TYPE.ASC
? [...dataPriceFilter].sort((a, b) => (a.name > b.name ? 1 : -1)) ? [...dataPriceFilter].sort((a, b) => (a.name > b.name ? 1 : -1))
...@@ -124,7 +127,9 @@ const Home = (props) => { ...@@ -124,7 +127,9 @@ const Home = (props) => {
}; };
const onSortByPercent = () => { const onSortByPercent = () => {
let type = 'ASC'; let type = 'ASC';
if (!isSortPercent || isSortPercent == SORT_TYPE.ASC) type = SORT_TYPE.DESC; if (!isSortPercent || isSortPercent == SORT_TYPE.ASC) {
type = SORT_TYPE.DESC;
}
let newData = let newData =
type == SORT_TYPE.ASC type == SORT_TYPE.ASC
? [...dataPriceFilter].sort((a, b) => (a.change > b.change ? 1 : -1)) ? [...dataPriceFilter].sort((a, b) => (a.change > b.change ? 1 : -1))
...@@ -137,8 +142,9 @@ const Home = (props) => { ...@@ -137,8 +142,9 @@ const Home = (props) => {
}; };
const onSortByPriceOpenClose = () => { const onSortByPriceOpenClose = () => {
let type = 'ASC'; let type = 'ASC';
if (!isSortPriceOpenClose || isSortPriceOpenClose == SORT_TYPE.ASC) if (!isSortPriceOpenClose || isSortPriceOpenClose == SORT_TYPE.ASC) {
type = SORT_TYPE.DESC; type = SORT_TYPE.DESC;
}
let newData = let newData =
type == SORT_TYPE.ASC type == SORT_TYPE.ASC
? [...dataPriceFilter].sort((a, b) => ? [...dataPriceFilter].sort((a, b) =>
...@@ -155,8 +161,9 @@ const Home = (props) => { ...@@ -155,8 +161,9 @@ const Home = (props) => {
}; };
const onSortByPriceHighLow = () => { const onSortByPriceHighLow = () => {
let type = 'ASC'; let type = 'ASC';
if (!isSortPriceHighLow || isSortPriceHighLow == SORT_TYPE.ASC) if (!isSortPriceHighLow || isSortPriceHighLow == SORT_TYPE.ASC) {
type = SORT_TYPE.DESC; type = SORT_TYPE.DESC;
}
let newData = let newData =
type == SORT_TYPE.ASC type == SORT_TYPE.ASC
? [...dataPriceFilter].sort((a, b) => ? [...dataPriceFilter].sort((a, b) =>
...@@ -173,6 +180,7 @@ const Home = (props) => { ...@@ -173,6 +180,7 @@ const Home = (props) => {
}; };
return ( return (
<>
<HomeView <HomeView
data={data} data={data}
dataPrice={dataPriceFilter} dataPrice={dataPriceFilter}
...@@ -185,6 +193,8 @@ const Home = (props) => { ...@@ -185,6 +193,8 @@ const Home = (props) => {
onSortByPriceOpenClose={onSortByPriceOpenClose} onSortByPriceOpenClose={onSortByPriceOpenClose}
onSortByPriceHighLow={onSortByPriceHighLow} onSortByPriceHighLow={onSortByPriceHighLow}
/> />
<VersionChecker/>
</>
); );
}; };
......
...@@ -36,7 +36,7 @@ const CalculatorProfitLoss = (props) => { ...@@ -36,7 +36,7 @@ const CalculatorProfitLoss = (props) => {
if (res.status == 200 && res.data.code == 200) { if (res.status == 200 && res.data.code == 200) {
setDataProduct(res.data.data); setDataProduct(res.data.data);
} else { } else {
showAlert(TYPE.ERROR, I18n.t('Notification', I18n.t('Can_not_get_data'))); showAlert(TYPE.ERROR, I18n.t('Notification'), I18n.t('Can_not_get_data'));
} }
}; };
......
...@@ -37,7 +37,7 @@ const ItemCalculator = (props) => { ...@@ -37,7 +37,7 @@ const ItemCalculator = (props) => {
}); });
setExpanded(!expanded); setExpanded(!expanded);
}; };
console.log(props.item.transaction_type); console.log(props.item);
return ( return (
<View <View
...@@ -78,8 +78,8 @@ const ItemCalculator = (props) => { ...@@ -78,8 +78,8 @@ const ItemCalculator = (props) => {
content={I18n.t(props.item.transaction_type)} content={I18n.t(props.item.transaction_type)}
color={ color={
props.item.transaction_type == 'SELL_OUT' props.item.transaction_type == 'SELL_OUT'
? R.colors.green ? R.colors.red2
: R.colors.red2 : R.colors.green
} }
/> />
<TextField <TextField
......
...@@ -12,11 +12,12 @@ const EscrowCalculator = (props) => { ...@@ -12,11 +12,12 @@ const EscrowCalculator = (props) => {
lotNumber: null, lotNumber: null,
firstEscrow: 0, firstEscrow: 0,
}]); }]);
const [firstEscrow, setFirstEscrow] = useState(null); const [firstEscrow, setFirstEscrow] = useState(0);
const [firstEscrowTotal, setFirstEscrowTotal] = useState(0); const [firstEscrowTotal, setFirstEscrowTotal] = useState(0);
const [message, setMessage] = useState('');
useEffect(() => { useEffect(() => {
getProductData() getProductData();
}, []) }, []);
const getProductData = async () => { const getProductData = async () => {
const res = await getTransactionListByCategory({ const res = await getTransactionListByCategory({
...@@ -27,31 +28,56 @@ const EscrowCalculator = (props) => { ...@@ -27,31 +28,56 @@ const EscrowCalculator = (props) => {
type: 'PRICE_TABLE', type: 'PRICE_TABLE',
category_id: -1, category_id: -1,
}); });
console.log('res', res);
if (res.status == 200 && res.data.code == 200) { if (res.status == 200 && res.data.code == 200) {
setDataProduct(res.data.data); setDataProduct(res.data.data);
} else { } else {
showAlert(TYPE.ERROR, I18n.t('Notification', I18n.t('Can_not_get_data'))) showAlert(TYPE.ERROR, I18n.t('Notification'), I18n.t('Can_not_get_data'));
} }
}; };
const onCalculator = () => { const onCalculator = () => {
if(firstEscrowTotal === '' || firstEscrowTotal == 0) {
showAlert(TYPE.WARN, I18n.t('Notification'), I18n.t('EnterContractInfo'));
return
}
if(firstEscrow === '' || firstEscrow == 0) {
showAlert(TYPE.WARN, I18n.t('Notification'), I18n.t('EnterFirstEscrow'));
return
}
if (parseFloat(firstEscrowTotal) <= parseFloat(firstEscrow)) {
setMessage(I18n.t('YouCanTransaction'));
} else {
setMessage(I18n.t('YouCanNotTransaction'));
}
}; };
const onDelete = () => { const onDelete = () => {
setListInput([{
product: null,
lotNumber: null,
firstEscrow: 0,
}])
setFirstEscrow(0)
setFirstEscrowTotal(0)
setMessage('')
}; };
const setItemInput = (item, index) => { const setItemInput = (item, index) => {
let data = [...listInput] let data = [...listInput];
data[index] = item data[index] = item;
setListInput(data) setListInput(data);
let firstEscrowTotalTmp = 0 let firstEscrowTotalTmp = 0;
data.map((item) => { data.map((item) => {
if(item.firstEscrow) firstEscrowTotalTmp = firstEscrowTotalTmp + item.firstEscrow if (item.firstEscrow) {
}) firstEscrowTotalTmp = firstEscrowTotalTmp + item.firstEscrow;
setFirstEscrowTotal(firstEscrowTotalTmp)
} }
});
setFirstEscrowTotal(firstEscrowTotalTmp);
};
const onAdd = () => { const onAdd = () => {
let data = [...listInput]; let data = [...listInput];
data.push({ data.push({
...@@ -73,6 +99,7 @@ const EscrowCalculator = (props) => { ...@@ -73,6 +99,7 @@ const EscrowCalculator = (props) => {
firstEscrowTotal={firstEscrowTotal} firstEscrowTotal={firstEscrowTotal}
setItemInput={setItemInput} setItemInput={setItemInput}
setFirstEscrow={setFirstEscrow} setFirstEscrow={setFirstEscrow}
message={message}
/> />
); );
}; };
......
...@@ -35,11 +35,12 @@ const EscrowCalculatorView = (props) => { ...@@ -35,11 +35,12 @@ const EscrowCalculatorView = (props) => {
dataProduct={props.dataProduct} dataProduct={props.dataProduct}
setProduct={(product) => { setProduct={(product) => {
item.product = product; item.product = product;
item.firstEscrow = parseFloat(item.lotNumber) * product.escrow;
props.setItemInput(item, index); props.setItemInput(item, index);
}} }}
setLotNumber={(lotNumber) => { setLotNumber={(lotNumber) => {
item.lotNumber = lotNumber.split('.').join(''); item.lotNumber = lotNumber.split('.').join('');
item.firstEscrow = parseFloat(item.lotNumber) * 12312; item.firstEscrow = item.product ? parseFloat(item.lotNumber) * item.product.escrow : 0;
props.setItemInput(item, index); props.setItemInput(item, index);
}} }}
/> />
...@@ -73,10 +74,7 @@ const EscrowCalculatorView = (props) => { ...@@ -73,10 +74,7 @@ const EscrowCalculatorView = (props) => {
titleStyle={{marginTop: HEIGHTXD(20), fontSize: getFontXD(39)}} titleStyle={{marginTop: HEIGHTXD(20), fontSize: getFontXD(39)}}
inputStyle={{backgroundColor: R.colors.gray7}} inputStyle={{backgroundColor: R.colors.gray7}}
/> />
<Text style={styles.textMessage}> <Text style={styles.textMessage}>{props.message}</Text>
Bn có th giao dch các hp đồng k trên vi mc ký qu kh dung
hin ti
</Text>
</View> </View>
<View <View
......
src/assets/images/iconUpgrade.png

4.2 KB | W: | H:

src/assets/images/iconUpgrade.png

2.25 KB | W: | H:

src/assets/images/iconUpgrade.png
src/assets/images/iconUpgrade.png
src/assets/images/iconUpgrade.png
src/assets/images/iconUpgrade.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -257,8 +257,6 @@ export default { ...@@ -257,8 +257,6 @@ export default {
'(estimated according to the current state processing rate of MXV)', '(estimated according to the current state processing rate of MXV)',
Caculate: 'Caculate', Caculate: 'Caculate',
ConversionUnit: 'Conversion unit', ConversionUnit: 'Conversion unit',
Delete: 'Delete',
UnitsQuotedFloor: 'Units quoted in the floor', UnitsQuotedFloor: 'Units quoted in the floor',
ConversionPrice: 'Conversion price', ConversionPrice: 'Conversion price',
ConvertUSD: 'Convert USD/Ton', ConvertUSD: 'Convert USD/Ton',
...@@ -274,6 +272,11 @@ export default { ...@@ -274,6 +272,11 @@ export default {
ProfitLoss: 'Profit/Loss', ProfitLoss: 'Profit/Loss',
BUY_IN: 'Buy in', BUY_IN: 'Buy in',
SELL_OUT: 'Sell out', SELL_OUT: 'Sell out',
YouCanNotTransaction: 'You can not trade the above contracts with the current available escrow',
YouCanTransaction: 'You can trade the above contracts with the current available escrow',
EnterContractInfo: 'Enter contract information',
EnterFirstEscrow: 'Enter first escrow',
CloseAccount: 'Close account', CloseAccount: 'Close account',
UpdatePacket: 'Update packet', UpdatePacket: 'Update packet',
Count: 'Count', Count: 'Count',
......
...@@ -251,7 +251,6 @@ export default { ...@@ -251,7 +251,6 @@ export default {
noteStopLoss: 'Ước tính theo tỷ lệ xử lý trạng thái hiện tại của MXV', noteStopLoss: 'Ước tính theo tỷ lệ xử lý trạng thái hiện tại của MXV',
Caculate: 'Tính', Caculate: 'Tính',
ConversionUnit: 'Đơn vị quy đổi', ConversionUnit: 'Đơn vị quy đổi',
Delete: 'Xoá',
UnitsQuotedFloor: 'Đơn vị yết giá trên sàn', UnitsQuotedFloor: 'Đơn vị yết giá trên sàn',
ConversionPrice: 'Giá quy đổi', ConversionPrice: 'Giá quy đổi',
ConvertUSD: 'Quy đổi USD/Tấn', ConvertUSD: 'Quy đổi USD/Tấn',
...@@ -269,6 +268,11 @@ export default { ...@@ -269,6 +268,11 @@ export default {
SELL_OUT: 'Bán ra', SELL_OUT: 'Bán ra',
EscrowCalculator: 'Tính ký quỹ', EscrowCalculator: 'Tính ký quỹ',
FirstEscrowTotal: 'Ký quỹ khả dụng', FirstEscrowTotal: 'Ký quỹ khả dụng',
YouCanNotTransaction: 'Bạn không thể giao dịch các hợp đồng kể trên với mức ký quỹ khả dụng hiện tại',
YouCanTransaction: 'Bạn có thể giao dịch các hợp đồng kể trên với mức ký quỹ khả dụng hiện tại',
EnterContractInfo: 'Nhập thông tin hợp đồng',
EnterFirstEscrow: 'Nhập ký quỹ ban đầu',
CloseAccount: 'Đóng tài khoản', CloseAccount: 'Đóng tài khoản',
UpdatePacket: 'Cập nhật gói cước', UpdatePacket: 'Cập nhật gói cước',
Count: 'Số lượng', Count: 'Số lượng',
......
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