Commit ff0a6cfa by Nguyễn Thị Thúy

merge dev phase2

parents 151a84a2 1a31e058
......@@ -56,6 +56,7 @@ const PacketCQG = (props) => {
props.hideLoading();
if (res.data.code == 200) {
props.saveUserToRedux(res.data.data);
navigate.goBack();
showAlert(TYPE.SUCCESS, I18n.t('Notification'), res.data.message);
} else {
showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
......@@ -116,6 +117,7 @@ const PacketCQG = (props) => {
};
const getData = async () => {
const res = await getListPacketCQG({});
console.log(res.data.data.fee.data);
if ((res.data.code = 200 && res.data.data)) {
setListData(res.data.data.fee.data);
......
import React from 'react';
import {View, Text, TouchableOpacity, Image, StyleSheet} from 'react-native';
import R from '../../../../assets/R';
import {getFontXD} from '../../../../Config/Functions';
import {getFontXD, HEIGHTXD, WIDTHXD} from '../../../../Config/Functions';
import {connect} from 'react-redux';
import AppText from '../../../../components/AppText';
import I18n from '../../../../helper/i18/i18n';
......@@ -9,6 +9,9 @@ import {useNavigation} from '@react-navigation/native';
import {PACKETCQG} from '../../../../routers/ScreenNames';
const Profile = (props) => {
const onClickCLose = () => {
console.log('Close click');
};
const navigation = useNavigation();
return (
<View style={styles.container}>
......@@ -30,6 +33,23 @@ const Profile = (props) => {
style={styles.txtTitle}></AppText>
<Text style={styles.txtBig}>{props.user.cqg_account}</Text>
</View>
<View
style={{
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
marginTop: 50,
}}>
<TouchableOpacity
onPress={() => navigation.navigate(PACKETCQG)}
style={styles.btnLeft}>
<AppText i18nKey={'UpdatePacket'} style={styles.txtBtn}></AppText>
</TouchableOpacity>
<TouchableOpacity onPress={onClickCLose} style={styles.btnRight}>
<AppText i18nKey={'CloseAccount'} style={styles.txtBtn}></AppText>
</TouchableOpacity>
</View>
</View>
) : (
<View style={{justifyContent: 'center', alignItems: 'center', flex: 1}}>
......@@ -91,8 +111,9 @@ const styles = StyleSheet.create({
fontSize: getFontXD(46),
},
txtBtn: {
fontSize: getFontXD(52),
fontSize: getFontXD(42),
color: R.colors.white,
fontWeight: '600',
},
containerBtn: {
paddingVertical: 10,
......@@ -101,6 +122,22 @@ const styles = StyleSheet.create({
borderRadius: 5,
marginTop: 30,
},
btnLeft: {
backgroundColor: R.colors.main,
width: WIDTHXD(460),
alignItems: 'center',
justifyContent: 'center',
height: HEIGHTXD(109),
borderRadius: 5,
},
btnRight: {
backgroundColor: '#E3434F',
width: WIDTHXD(460),
alignItems: 'center',
justifyContent: 'center',
height: HEIGHTXD(109),
borderRadius: 5,
},
});
const mapStateToProps = (state) => {
......
......@@ -88,11 +88,15 @@ const ItemCalculator = (props) => {
/>
<TextField
title={`${I18n.t('ProfitLoss')} (USD)`}
content={toPriceVnd(props.item.profit.USD)}
content={
props.item.profit.USD ? toPriceVnd(props.item.profit.USD) : '0'
}
/>
<TextField
title={`${I18n.t('ProfitLoss')} (VNĐ)`}
content={toPriceVnd(props.item.profit.VND)}
content={
props.item.profit.VND ? toPriceVnd(props.item.profit.VND) : '0'
}
/>
</View>
) : null}
......
......@@ -14,6 +14,7 @@ import AppText from '../../components/AppText';
import TextField from '../../components/Input/TextField';
import {getFontXD, HEIGHTXD, WIDTHXD} from '../../Config/Functions';
import R from '../../assets/R';
import Icon from 'react-native-vector-icons/FontAwesome';
const dataType = [
{
......@@ -31,6 +32,7 @@ const ConvertUnit = (props) => {
const [typeTwo, setTypeTwo] = useState();
const [valueOne, setValueOne] = useState();
const [valueTwo, setValueTwo] = useState();
const [result, setResult] = useState();
const onClick = () => {
console.log('Heloo', typeOne, typeTwo, valueOne, valueTwo);
......@@ -40,43 +42,43 @@ const ConvertUnit = (props) => {
<View style={{flex: 1}}>
<HeaderBack title={'ConvertUnit'} />
<View style={{flex: 1, paddingTop: 20, paddingHorizontal: 20}}>
<AppText style={styles.txtTitle} i18nKey={'ConversionUnit'} />
<AppText style={styles.txtTitle} i18nKey={'Count'} />
<View style={styles.Item}>
<View style={styles.wrap}>
<PickerItem
width={WIDTHXD(431)}
data={dataType}
onValueChange={(value, items) => {
setTypeOne(items);
}}
/>
<TextInput
onChangeText={(val) => setValueOne(val)}
keyboardType={'number-pad'}
style={styles.wrapInput}
maxLength={12}
/>
</View>
<Text style={styles.txtNote}>1KG = 2 Pount</Text>
</View>
<View style={styles.Item}>
<View style={styles.wrap}>
<PickerItem
width={WIDTHXD(431)}
width={WIDTHXD(400)}
data={dataType}
onValueChange={(value, items) => {
setTypeTwo(items);
}}
/>
<TextInput
onChangeText={(val) => setValueTwo(val)}
keyboardType={'number-pad'}
style={styles.wrapInput}
<TouchableOpacity>
<Icon name={'exchange'} size={30} color={R.colors.black} />
</TouchableOpacity>
<PickerItem
width={WIDTHXD(400)}
data={dataType}
onValueChange={(value, items) => {
setTypeOne(items);
}}
/>
</View>
<Text style={styles.txtNote}>1 Pount = 0.5 KG</Text>
</View>
<Text style={styles.txtResult}>Kết qu: {result}</Text>
<View style={styles.footer}>
<TouchableOpacity onPress={onClick} style={styles.btnContainer}>
<AppText style={styles.txtBtn} i18nKey={'Caculate'} />
......@@ -91,7 +93,7 @@ const styles = StyleSheet.create({
txtTitle: {
fontSize: getFontXD(42),
color: R.colors.color777,
marginBottom: 15,
marginBottom: 5,
},
note: {
fontSize: getFontXD(36),
......@@ -108,7 +110,7 @@ const styles = StyleSheet.create({
footer: {
alignItems: 'center',
justifyContent: 'center',
marginTop: 20,
marginTop: 40,
},
btnContainer: {
width: WIDTHXD(428),
......@@ -124,7 +126,7 @@ const styles = StyleSheet.create({
fontWeight: '600',
},
wrapInput: {
width: WIDTHXD(431),
width: '100%',
backgroundColor: R.colors.white,
height: HEIGHTXD(109),
fontSize: getFontXD(42),
......@@ -152,5 +154,12 @@ const styles = StyleSheet.create({
textAlign: 'right',
marginTop: 10,
},
txtResult: {
fontSize: getFontXD(52),
color: R.colors.black,
fontWeight: '600',
textAlign: 'center',
marginTop: 20,
},
});
export default ConvertUnit;
......@@ -16,78 +16,42 @@ import TextField from '../../components/Input/TextField';
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 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,
},
{
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,
},
{
id: 11,
name: 'Cao su',
value: 9.4,
},
];
import {getListExchangeRate} from '../../apis/Functions/Transaction';
import {showLoading, hideLoading} from '../../actions/loadingAction';
import {connect} from 'react-redux';
const ExchangeRate = (props) => {
const [product, setProduct] = useState();
const [priceExchange, setPriceExchange] = useState();
const [usdTan, setUsdTan] = useState();
const [dataProduct, setDataProduct] = useState([]);
useEffect(() => {
getProductData();
}, []);
const getProductData = async () => {
props.showLoading();
const res = await getListExchangeRate({
platform: Platform.OS,
page_size: 1000,
page_index: 1,
});
props.hideLoading();
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')));
}
};
useEffect(() => {
caculator();
}, [product, priceExchange]);
const caculator = () => {
if (product && priceExchange) {
const total = priceExchange * product.value;
const total = priceExchange * product.exchange_rate;
setUsdTan(total + '');
} else if (!priceExchange) setUsdTan('');
};
......@@ -99,7 +63,7 @@ const ExchangeRate = (props) => {
<AppText style={styles.txtTitle} i18nKey={'Product'} />
<PickerItem
width={width - 20}
data={DATA}
data={dataProduct}
onValueChange={(value, items) => {
setProduct(items);
}}
......@@ -110,6 +74,8 @@ const ExchangeRate = (props) => {
title={I18n.t('UnitsQuotedFloor')}
/>
<TextField
isNumber={true}
maxLength={12}
onChangeText={(val) => setPriceExchange(val)}
title={I18n.t('ConversionPrice')}
/>
......@@ -194,4 +160,12 @@ const styles = StyleSheet.create({
marginTop: 10,
},
});
export default ExchangeRate;
const mapStateToProps = (state) => {
return {
user: state.userReducer,
};
};
export default connect(mapStateToProps, {showLoading, hideLoading})(
ExchangeRate,
);
......@@ -21,3 +21,8 @@ export const getProfitLost = async (body) =>
PostData(url.urlProfitLost, body)
.then((res) => res)
.catch((err) => err);
export const getListExchangeRate = async (body) =>
GetData(url.urlGetListExchangeRate, body)
.then((res) => res)
.catch((err) => err);
......@@ -55,4 +55,6 @@ export default {
urlSendRequest: root + 'api/v1/customers/send-request',
urlProfitLost: root + 'api/v1/customers/calculate-profit',
urlGetListExchangeRate: root + 'api/v1/customers/get-list-exchange-rate',
};
......@@ -277,4 +277,7 @@ export default {
EnterContractInfo: 'Enter contract information',
EnterFirstEscrow: 'Enter first escrow',
CloseAccount: 'Close account',
UpdatePacket: 'Update packet',
Count: 'Count',
};
......@@ -92,7 +92,7 @@ export default {
Photo_library: 'Thư viện ảnh',
Take_photo: 'Chụp ảnh',
EnableCQG: 'Có tài khoản CQG',
EnableCQG: 'Kích hoạt',
Request_Open_Account_CQG: 'Yêu cầu mở TK CQG',
Waiting_for_Progress: 'Chờ xử lý',
Free: 'Miễn phí',
......@@ -273,4 +273,7 @@ export default {
EnterContractInfo: 'Nhập thông tin hợp đồng',
EnterFirstEscrow: 'Nhập ký quỹ ban đầu',
CloseAccount: 'Đóng tài khoản',
UpdatePacket: 'Cập nhật gói cước',
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