Commit e4406dde by Giang Tran

linking web phone

parent 1a31e058
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
<array> <array>
<string>dcv.investcustomer.vn</string> <string>dcv.investcustomer.vn</string>
</array> </array>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>en</string> <string>en</string>
<key>CFBundleDisplayName</key> <key>CFBundleDisplayName</key>
...@@ -42,6 +44,8 @@ ...@@ -42,6 +44,8 @@
<key>LSApplicationQueriesSchemes</key> <key>LSApplicationQueriesSchemes</key>
<array> <array>
<string>itms-apps</string> <string>itms-apps</string>
<string>tel</string>
<string>telprompt</string>
</array> </array>
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>
<true/> <true/>
......
...@@ -5,15 +5,43 @@ import { ...@@ -5,15 +5,43 @@ import {
Alert, Alert,
Text, Text,
PermissionsAndroid, PermissionsAndroid,
Linking,
} from 'react-native'; } from 'react-native';
import moment from 'moment'; import moment from 'moment';
import _ from 'lodash'; import _ from 'lodash';
import I18n from '../helper/i18/i18n'; import I18n from '../helper/i18/i18n';
import AppText from '../components/AppText'; import AppText from '../components/AppText';
import AsyncStorage from '@react-native-community/async-storage';
import {DETAILNEW, TABNAVIGATOR} from '../routers/ScreenNames'; import {DETAILNEW, TABNAVIGATOR, AUTHEN} from '../routers/ScreenNames';
import R from '../assets/R'; import R from '../assets/R';
export const logout = (navigation) => {
AsyncStorage.clear();
navigation.reset({
index: 1,
routes: [{name: AUTHEN}],
});
};
export const callNumber = (phone) => {
console.log('callNumber ----> ', phone);
let phoneNumber = phone;
if (Platform.OS !== 'android') {
phoneNumber = `telprompt:${phone}`;
} else {
phoneNumber = `tel:${phone}`;
}
Linking.canOpenURL(phoneNumber)
.then((supported) => {
if (!supported) {
Alert.alert('Phone number is not available');
} else {
return Linking.openURL(phoneNumber);
}
})
.catch((err) => console.log(err));
};
export const convertScreen = (name) => { export const convertScreen = (name) => {
switch (name) { switch (name) {
case 'CUSTOMER_NEWS': case 'CUSTOMER_NEWS':
......
...@@ -26,6 +26,19 @@ const FeePro = (props) => { ...@@ -26,6 +26,19 @@ const FeePro = (props) => {
setListItem(newList); setListItem(newList);
}, [props.data]); }, [props.data]);
useEffect(() => {
const newList = data.map((e) => {
console.log(props.listRegister);
if (props.listRegister.includes(e.id)) {
return {...e, selected: true};
} else {
return {...e, selected: false};
}
});
setListItem(newList);
}, [props.listRegister]);
const onSelected = (selected) => { const onSelected = (selected) => {
if (selected.id == 10) { if (selected.id == 10) {
const newList = listItem.map((e) => { const newList = listItem.map((e) => {
......
...@@ -9,6 +9,9 @@ const Footer = (props) => { ...@@ -9,6 +9,9 @@ const Footer = (props) => {
return ( return (
<View style={{flex: 1, paddingHorizontal: 10, marginTop: 10}}> <View style={{flex: 1, paddingHorizontal: 10, marginTop: 10}}>
<View style={{flexDirection: 'row', marginVertical: 5}}> <View style={{flexDirection: 'row', marginVertical: 5}}>
<Text style={styles.txtTitle}>
{I18n.t('Provisional')}:{toPriceVnd(props.price)}
</Text>
<AppText i18nKey={'Open_account_demo'} style={styles.txtTitle} /> <AppText i18nKey={'Open_account_demo'} style={styles.txtTitle} />
<TouchableOpacity <TouchableOpacity
onPress={() => onPress={() =>
...@@ -17,9 +20,6 @@ const Footer = (props) => { ...@@ -17,9 +20,6 @@ const Footer = (props) => {
<AppText i18nKey={'Here'} style={styles.txtLink} /> <AppText i18nKey={'Here'} style={styles.txtLink} />
</TouchableOpacity> </TouchableOpacity>
</View> </View>
<Text style={styles.txtTitle}>
{I18n.t('Provisional')}:{toPriceVnd(props.price)}
</Text>
<View <View
style={{ style={{
justifyContent: 'center', justifyContent: 'center',
......
...@@ -8,7 +8,11 @@ import ContainerTop from './ContainerTop'; ...@@ -8,7 +8,11 @@ import ContainerTop from './ContainerTop';
import WrapNomarl from './WrapNomarl'; import WrapNomarl from './WrapNomarl';
import Footer from './Footer'; import Footer from './Footer';
import FeePro from './FeePro'; import FeePro from './FeePro';
import {getListPacketCQG, openCQG} from '../../../apis/Functions/packetCQG'; import {
getListPacketCQG,
openCQG,
updateCQG,
} from '../../../apis/Functions/packetCQG';
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {showLoading, hideLoading} from '../../../actions/loadingAction'; import {showLoading, hideLoading} from '../../../actions/loadingAction';
import {useNavigation} from '@react-navigation/native'; import {useNavigation} from '@react-navigation/native';
...@@ -24,6 +28,8 @@ const PacketCQG = (props) => { ...@@ -24,6 +28,8 @@ const PacketCQG = (props) => {
const [feePro, setFeePro] = useState({data: [], title: ''}); const [feePro, setFeePro] = useState({data: [], title: ''});
const [totalMD, setTotalMD] = useState(0); const [totalMD, setTotalMD] = useState(0);
const [totalTB, setTotalTB] = useState(0); const [totalTB, setTotalTB] = useState(0);
const [isUpdate, setIsUpdate] = useState(false);
const [listRegister, setListRegister] = useState([]);
const navigate = useNavigation(); const navigate = useNavigation();
...@@ -50,9 +56,14 @@ const PacketCQG = (props) => { ...@@ -50,9 +56,14 @@ const PacketCQG = (props) => {
const onClick = async () => { const onClick = async () => {
const newList = listData.map((e) => e.id); const newList = listData.map((e) => e.id);
let res;
props.showLoading(); props.showLoading();
const res = await openCQG({packages: newList}); if (isUpdate) {
res = await updateCQG({packages: newList});
} else {
res = await openCQG({packages: newList});
}
props.hideLoading(); props.hideLoading();
if (res.data.code == 200) { if (res.data.code == 200) {
props.saveUserToRedux(res.data.data); props.saveUserToRedux(res.data.data);
...@@ -117,14 +128,23 @@ const PacketCQG = (props) => { ...@@ -117,14 +128,23 @@ 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);
setFee(res.data.data.fee); setFee(res.data.data.fee);
setFeeConnect(res.data.data.fee_connect); setFeeConnect(res.data.data.fee_connect);
setFeeNonPro(res.data.data.fee_pro); setFeeNonPro(res.data.data.fee_pro);
setFeePro(res.data.data.fee_non_pro); setFeePro(res.data.data.fee_non_pro);
if (res.data.package_register.length > 0) {
setListData(res.data.package_register);
const temp = res.data.package_register.filter(
(e) => e.id != 1 && e.id != 2,
);
const listId = temp.map((e) => e.id);
setListRegister(listId);
setIsUpdate(true);
} else {
setListData(res.data.data.fee.data);
}
} else { } else {
showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message); showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
} }
...@@ -142,11 +162,13 @@ const PacketCQG = (props) => { ...@@ -142,11 +162,13 @@ const PacketCQG = (props) => {
onRemovePacket={onRemovePacket} onRemovePacket={onRemovePacket}
onChoosePacket={onChoosePacket} onChoosePacket={onChoosePacket}
data={feeConnect} data={feeConnect}
listRegister={listRegister}
/> />
<WrapNomarl <WrapNomarl
onRemovePacket={onRemovePacket} onRemovePacket={onRemovePacket}
onChoosePacket={onChoosePacket} onChoosePacket={onChoosePacket}
data={feeNonPro} data={feeNonPro}
listRegister={listRegister}
/> />
<FeePro <FeePro
...@@ -157,6 +179,7 @@ const PacketCQG = (props) => { ...@@ -157,6 +179,7 @@ const PacketCQG = (props) => {
onRemoveAllMD={onRemoveAllMD} onRemoveAllMD={onRemoveAllMD}
onRemoveAllTB={onRemoveAllTB} onRemoveAllTB={onRemoveAllTB}
data={feePro} data={feePro}
listRegister={listRegister}
/> />
<Footer onClick={onClick} price={price} /> <Footer onClick={onClick} price={price} />
......
...@@ -19,6 +19,21 @@ const ContainerTop = (props) => { ...@@ -19,6 +19,21 @@ const ContainerTop = (props) => {
setListItem(newList); setListItem(newList);
}, [props.data]); }, [props.data]);
useEffect(() => {
const newList = data.map((e) => {
console.log(props.listRegister);
if (props.listRegister.includes(e.id)) {
console.log('Chay vao day', e.id);
return {...e, selected: true};
} else {
console.log('Chay xuong duoi', e.id);
return {...e, selected: false};
}
});
setListItem(newList);
}, [props.listRegister]);
const onSelected = (selected) => { const onSelected = (selected) => {
const newList = listItem.map((e) => { const newList = listItem.map((e) => {
if (e.id != selected.id) return e; if (e.id != selected.id) return e;
......
...@@ -81,17 +81,25 @@ const Login = (props) => { ...@@ -81,17 +81,25 @@ const Login = (props) => {
}); });
props.hideLoading(); props.hideLoading();
if (res.data.code == 200 && res.data.data) { if (res.data) {
const jsonValue = JSON.stringify({email, pass}); if (res.data.code == 200 && res.data.data) {
AsyncStorage.setItem(KEY.TOKEN, res.data.data.token); const jsonValue = JSON.stringify({email, pass});
AsyncStorage.setItem(KEY.ACCOUNT, jsonValue); AsyncStorage.setItem(KEY.TOKEN, res.data.data.token);
props.saveUserToRedux(res.data.data); AsyncStorage.setItem(KEY.ACCOUNT, jsonValue);
navigate.reset({ props.saveUserToRedux(res.data.data);
index: 1, navigate.reset({
routes: [{name: TABNAVIGATOR}], index: 1,
}); routes: [{name: TABNAVIGATOR}],
});
} else {
showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
}
} else { } else {
showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message); showAlert(
TYPE.ERROR,
I18n.t('Notification'),
I18n.t('Systemmaintenance'),
);
} }
} else { } else {
showAlert( showAlert(
......
...@@ -23,6 +23,8 @@ const Home = (props) => { ...@@ -23,6 +23,8 @@ const Home = (props) => {
const [isSortPercent, setIsSortPercent] = useState(null); const [isSortPercent, setIsSortPercent] = useState(null);
const [isSortPriceOpenClose, setIsSortPriceOpenClose] = useState(null); const [isSortPriceOpenClose, setIsSortPriceOpenClose] = useState(null);
const [isSortPriceHighLow, setIsSortPriceHighLow] = useState(null); const [isSortPriceHighLow, setIsSortPriceHighLow] = useState(null);
console.log(props.user);
const SORT_TYPE = { const SORT_TYPE = {
DESC: 'DESC', DESC: 'DESC',
ASC: 'ASC', ASC: 'ASC',
......
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, HEIGHTXD, WIDTHXD} from '../../../../Config/Functions'; import {
getFontXD,
HEIGHTXD,
WIDTHXD,
logout,
} 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';
import {useNavigation} from '@react-navigation/native'; import {useNavigation} from '@react-navigation/native';
import {PACKETCQG} from '../../../../routers/ScreenNames'; import {PACKETCQG} from '../../../../routers/ScreenNames';
import {closeCQG} from '../../../../apis/Functions/packetCQG';
import {showLoading, hideLoading} from '../../../../actions/loadingAction';
import {showAlert, TYPE} from '../../../../components/DropdownAlert';
const Profile = (props) => { const Profile = (props) => {
const onClickCLose = () => {
console.log('Close click');
};
const navigation = useNavigation(); const navigation = useNavigation();
const onClickCLose = async () => {
props.showLoading();
const res = await closeCQG();
props.hideLoading();
if (res.data.code == 200) {
showAlert(TYPE.SUCCESS, I18n.t('Notification'), res.data.message);
} else if (res.data.code == 401) {
logout(navigation);
showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
} else {
showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
}
};
return ( return (
<View style={styles.container}> <View style={styles.container}>
{props.user.status == 6 ? ( {props.user.status == 6 ? (
...@@ -145,4 +165,4 @@ const mapStateToProps = (state) => { ...@@ -145,4 +165,4 @@ const mapStateToProps = (state) => {
user: state.userReducer, user: state.userReducer,
}; };
}; };
export default connect(mapStateToProps, {})(Profile); export default connect(mapStateToProps, {showLoading, hideLoading})(Profile);
import React, {useState, useEffect} from 'react'; import React, {useState, useEffect} from 'react';
import {View, Text, StyleSheet, Platform} from 'react-native'; import {
View,
Text,
StyleSheet,
Platform,
Linking,
TouchableOpacity,
} from 'react-native';
import R from '../../assets/R'; import R from '../../assets/R';
import AppText from '../../components/AppText'; import AppText from '../../components/AppText';
import TextMulti from '../../components/Input/TextMulti'; import TextMulti from '../../components/Input/TextMulti';
import I18n from '../../helper/i18/i18n'; import I18n from '../../helper/i18/i18n';
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import HeaderBack from '../../components/Header/HeaderBack'; import HeaderBack from '../../components/Header/HeaderBack';
import {getFontXD, HEIGHTXD, WIDTHXD} from '../../Config/Functions'; import {getFontXD, HEIGHTXD, WIDTHXD, callNumber} from '../../Config/Functions';
import {TouchableOpacity} from 'react-native-gesture-handler';
import {showLoading, hideLoading} from '../../actions/loadingAction'; import {showLoading, hideLoading} from '../../actions/loadingAction';
import {showAlert, TYPE} from '../../components/DropdownAlert'; import {showAlert, TYPE} from '../../components/DropdownAlert';
import {sendRequest} from '../../apis/Functions/General'; import {sendRequest} from '../../apis/Functions/General';
...@@ -28,6 +34,7 @@ const ServiceCustomerView = (props) => { ...@@ -28,6 +34,7 @@ const ServiceCustomerView = (props) => {
showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message); showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
} }
}; };
console.log(props.user.company_info);
const { const {
name, name,
...@@ -39,6 +46,7 @@ const ServiceCustomerView = (props) => { ...@@ -39,6 +46,7 @@ const ServiceCustomerView = (props) => {
office_sat_time, office_sat_time,
office_sun_time, office_sun_time,
address, address,
hotline_call,
} = props.user.company_info; } = props.user.company_info;
return ( return (
...@@ -60,13 +68,21 @@ const ServiceCustomerView = (props) => { ...@@ -60,13 +68,21 @@ const ServiceCustomerView = (props) => {
<Text style={styles.title}>Email:</Text> <Text style={styles.title}>Email:</Text>
<Text style={styles.txtContent}> {email}</Text> <Text style={styles.txtContent}> {email}</Text>
</View> </View>
<View style={styles.row}> <TouchableOpacity
<Text style={styles.title}>Website: </Text> onPress={async () => {
<Text style={styles.txtContent}>{website}</Text> const supported = await Linking.canOpenURL(website);
</View> if (supported) Linking.openURL(website);
}}>
<View style={styles.row}>
<Text style={styles.title}>Website: </Text>
<Text style={styles.txtLink}>{website}</Text>
</View>
</TouchableOpacity>
<AppText i18nKey={'HotLine'} style={styles.title} /> <AppText i18nKey={'HotLine'} style={styles.title} />
<Text style={styles.txtContent}>{hotline}</Text> <TouchableOpacity onPress={() => callNumber(hotline_call)}>
<Text style={styles.txtContent}>{hotline}</Text>
</TouchableOpacity>
<AppText i18nKey={'WorkingTime'} style={styles.title} /> <AppText i18nKey={'WorkingTime'} style={styles.title} />
<View style={{flexDirection: 'row'}}> <View style={{flexDirection: 'row'}}>
...@@ -122,6 +138,12 @@ const styles = StyleSheet.create({ ...@@ -122,6 +138,12 @@ const styles = StyleSheet.create({
fontSize: getFontXD(42), fontSize: getFontXD(42),
marginTop: 5, marginTop: 5,
}, },
txtLink: {
fontSize: getFontXD(42),
marginTop: 5,
textDecorationLine: 'underline',
color: R.colors.main,
},
row: { row: {
flexDirection: 'row', flexDirection: 'row',
}, },
......
...@@ -11,3 +11,13 @@ export const openCQG = async (body) => ...@@ -11,3 +11,13 @@ export const openCQG = async (body) =>
PostData(url.urlOpenCQG, body) PostData(url.urlOpenCQG, body)
.then((res) => res) .then((res) => res)
.catch((err) => err); .catch((err) => err);
export const closeCQG = async (body) =>
PostData(url.urlCloseCQG, body)
.then((res) => res)
.catch((err) => err);
export const updateCQG = async (body) =>
PostData(url.urlUpdateCQG, body)
.then((res) => res)
.catch((err) => err);
export const root = 'http://api.dcvinvest.com/'; export const root = 'http://services.dcvinvest.com/';
export default { export default {
urllogin: root + 'api/auth/customer-login', urllogin: root + 'api/auth/customer-login',
urlRegistor: root + 'api/auth/customer-register', urlRegistor: root + 'api/auth/customer-register',
...@@ -57,4 +57,6 @@ export default { ...@@ -57,4 +57,6 @@ export default {
urlProfitLost: root + 'api/v1/customers/calculate-profit', urlProfitLost: root + 'api/v1/customers/calculate-profit',
urlGetListExchangeRate: root + 'api/v1/customers/get-list-exchange-rate', urlGetListExchangeRate: root + 'api/v1/customers/get-list-exchange-rate',
urlCloseCQG: root + 'api/v1/customers/cancel-open-cqg',
urlUpdateCQG: root + 'api/v1/customers/update-open-cqg',
}; };
...@@ -8,7 +8,7 @@ import { ...@@ -8,7 +8,7 @@ import {
ScrollView, ScrollView,
} from 'react-native'; } from 'react-native';
import R from '../../assets/R'; import R from '../../assets/R';
import {HEIGHTXD, getFontXD, WIDTHXD} from '../../Config/Functions'; import {HEIGHTXD, getFontXD, WIDTHXD, logout} from '../../Config/Functions';
import Icon from 'react-native-vector-icons/MaterialIcons'; import Icon from 'react-native-vector-icons/MaterialIcons';
import AsyncStorage from '@react-native-community/async-storage'; import AsyncStorage from '@react-native-community/async-storage';
import DeviceInfo from 'react-native-device-info'; import DeviceInfo from 'react-native-device-info';
...@@ -298,12 +298,8 @@ const Drawer = (props) => { ...@@ -298,12 +298,8 @@ const Drawer = (props) => {
<TouchableOpacity <TouchableOpacity
onPress={() => { onPress={() => {
AsyncStorage.clear(); logout(navigate);
props.toggleModal(); props.toggleModal();
navigate.reset({
index: 1,
routes: [{name: AUTHEN}],
});
}} }}
style={styles.footer}> style={styles.footer}>
<Icon name={'logout'} size={25} color={'#F81515'} /> <Icon name={'logout'} size={25} color={'#F81515'} />
......
...@@ -61,7 +61,7 @@ const renderWallet = (status, current_money, current_cqg_money, contract) => { ...@@ -61,7 +61,7 @@ const renderWallet = (status, current_money, current_cqg_money, contract) => {
</TouchableOpacity> </TouchableOpacity>
</View> </View>
); );
if (status == 6) if (status == 6 || status == 7)
return ( return (
<View style={{flex: 1, flexDirection: 'row'}}> <View style={{flex: 1, flexDirection: 'row'}}>
<View style={styles.containerWallet}> <View style={styles.containerWallet}>
...@@ -100,12 +100,12 @@ const renderWallet = (status, current_money, current_cqg_money, contract) => { ...@@ -100,12 +100,12 @@ const renderWallet = (status, current_money, current_cqg_money, contract) => {
<View style={{width: 1, backgroundColor: '#EDEDF1', height: '100%'}} /> <View style={{width: 1, backgroundColor: '#EDEDF1', height: '100%'}} />
<View style={styles.containerWallet}> <View style={styles.containerWallet}>
<AppText <AppText
i18nKey={'WaitOpenCQG'} i18nKey={status == 5 ? 'WaitOpenCQG' : 'WaitUpdateCQG'}
style={[styles.txtWhite, {color: '#FFB721'}]}></AppText> style={[styles.txtWhite, {color: '#FFB721'}]}></AppText>
</View> </View>
</View> </View>
); );
if (status == 3) if (status == 3 || status == 8)
return ( return (
<View style={{flex: 1, flexDirection: 'row'}}> <View style={{flex: 1, flexDirection: 'row'}}>
<View style={styles.containerWallet}> <View style={styles.containerWallet}>
......
...@@ -277,4 +277,6 @@ export default { ...@@ -277,4 +277,6 @@ export default {
CloseAccount: 'Close account', CloseAccount: 'Close account',
UpdatePacket: 'Update packet', UpdatePacket: 'Update packet',
Count: 'Count', Count: 'Count',
Systemmaintenance: 'The system is maintenance',
WaitUpdateCQG: 'Waiting Update CQG',
}; };
...@@ -102,7 +102,7 @@ export default { ...@@ -102,7 +102,7 @@ export default {
Open_account: 'Mở tài khoản', Open_account: 'Mở tài khoản',
Provisional: 'Tạm tính', Provisional: 'Tạm tính',
Here: 'Tại đây', Here: 'Tại đây',
Open_account_demo: 'Bạn có thể mở tài khoản thử', Open_account_demo: 'Hoặc bạn có thể mở tài khoản thử',
Features_develop: 'Không có dữ liệu!', Features_develop: 'Không có dữ liệu!',
Email: 'Email', Email: 'Email',
Password: 'Mật khẩu', Password: 'Mật khẩu',
...@@ -272,4 +272,6 @@ export default { ...@@ -272,4 +272,6 @@ export default {
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',
Systemmaintenance: 'Hệ thống đang bảo trì',
WaitUpdateCQG: 'Chờ cập nhật CQG',
}; };
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