Commit ff0a6cfa by Nguyễn Thị Thúy

merge dev phase2

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