Commit ac70cfc7 by Giang Tran

update dropdown alert

parent 08710027
...@@ -132,8 +132,8 @@ android { ...@@ -132,8 +132,8 @@ android {
applicationId "com.dcv.invest" applicationId "com.dcv.invest"
minSdkVersion rootProject.ext.minSdkVersion minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 2 versionCode 4
versionName "1.2" versionName "1.3"
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
} }
splits { splits {
......
import React, {useEffect} from 'react'; import React, {useEffect, useRef} from 'react';
import { import {
View, View,
Text, Text,
...@@ -14,15 +14,25 @@ import Modal from 'react-native-modal'; ...@@ -14,15 +14,25 @@ import Modal from 'react-native-modal';
import {SkypeIndicator} from 'react-native-indicators'; import {SkypeIndicator} from 'react-native-indicators';
import {enableScreens} from 'react-native-screens'; import {enableScreens} from 'react-native-screens';
import NoInternetComponent from './components/NoInternet'; import NoInternetComponent from './components/NoInternet';
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 VersionChecker from './Screens/VersionChecker';
import DropDown from './components/DropDown'; import R from './assets/R';
import {WIDTHXD, HEIGHTXD} from './Config/Functions';
import DropdownManager from './components/DropdownAlert/DropdownManager';
enableScreens(); enableScreens();
const RootView = (props) => { const RootView = (props) => {
useEffect(() => {}, []); useEffect(() => {
DropdownManager.register(
dropDownAlertRef.current,
dropDownAlertLongTimeRef.current,
);
}, []);
const dropDownAlertRef = useRef(null);
const dropDownAlertLongTimeRef = useRef(null);
const checkVersion = (props) => { const checkVersion = (props) => {
const verCurrent = DeviceInfo.getVersion(); const verCurrent = DeviceInfo.getVersion();
...@@ -38,7 +48,44 @@ const RootView = (props) => { ...@@ -38,7 +48,44 @@ const RootView = (props) => {
<StackNavigation /> <StackNavigation />
</View> </View>
{/*<VersionChecker/>*/} {/*<VersionChecker/>*/}
{/* <DropDown /> */} <DropdownAlert
inactiveStatusBarBackgroundColor={R.colors.main}
activeStatusBarBackgroundColor={R.colors.main}
warnImageSrc={R.images.iconWarn}
successImageSrc={R.images.iconSuccess}
errorImageSrc={R.images.iconError}
titleStyle={{color: '#fff'}}
messageStyle={{color: '#fff'}}
closeInterval={1000}
ref={dropDownAlertRef}
warnColor={R.colors.orange400}
defaultContainer={{
borderBottomRightRadius: WIDTHXD(30),
borderBottomLeftRadius: WIDTHXD(30),
paddingTop: HEIGHTXD(30),
paddingVertical: HEIGHTXD(30),
paddingHorizontal: WIDTHXD(20),
}}
/>
<DropdownAlert
inactiveStatusBarBackgroundColor={R.colors.colorMain}
activeStatusBarBackgroundColor={R.colors.colorMain}
warnImageSrc={R.images.iconWarn}
successImageSrc={R.images.iconSuccess}
errorImageSrc={R.images.iconError}
titleStyle={{color: '#fff'}}
messageStyle={{color: '#fff'}}
closeInterval={600000}
ref={dropDownAlertLongTimeRef}
warnColor={R.colors.orange400}
defaultContainer={{
borderBottomRightRadius: WIDTHXD(30),
borderBottomLeftRadius: WIDTHXD(30),
paddingTop: HEIGHTXD(30),
paddingVertical: HEIGHTXD(30),
paddingHorizontal: WIDTHXD(20),
}}
/>
<NoInternetComponent /> <NoInternetComponent />
</> </>
......
...@@ -15,7 +15,7 @@ import {useNavigation} from '@react-navigation/native'; ...@@ -15,7 +15,7 @@ import {useNavigation} from '@react-navigation/native';
import {saveUserToRedux} from '../../../actions/users'; import {saveUserToRedux} from '../../../actions/users';
import AppText from '../../../components/AppText'; import AppText from '../../../components/AppText';
import I18n from '../../../helper/i18/i18n'; import I18n from '../../../helper/i18/i18n';
import {showAlert, TYPE} from '../../../components/DropdownAlert/index';
const PacketCQG = (props) => { const PacketCQG = (props) => {
const [listData, setListData] = useState([]); const [listData, setListData] = useState([]);
const [fee, setFee] = useState({data: [], title: ''}); const [fee, setFee] = useState({data: [], title: ''});
...@@ -56,14 +56,9 @@ const PacketCQG = (props) => { ...@@ -56,14 +56,9 @@ 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);
setTimeout(() => { showAlert(TYPE.SUCCESS, I18n.t('Notification'), res.data.message);
Alert.alert(I18n.t('Notification'), res.data.message);
navigate.goBack();
}, 500);
} else { } else {
setTimeout(() => { showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
Alert.alert(I18n.t('Notification'), res.data.message);
}, 500);
} }
}; };
...@@ -129,7 +124,7 @@ const PacketCQG = (props) => { ...@@ -129,7 +124,7 @@ const PacketCQG = (props) => {
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);
} else { } else {
Alert.alert(I18n.t('Notification'), res.data.message); showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
} }
}; };
......
...@@ -25,6 +25,7 @@ import {connect} from 'react-redux'; ...@@ -25,6 +25,7 @@ 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';
import I18n from '../../../helper/i18/i18n'; import I18n from '../../../helper/i18/i18n';
import {showAlert, TYPE} from '../../../components/DropdownAlert';
const {width} = Dimensions.get('window'); const {width} = Dimensions.get('window');
const dataType = [ const dataType = [
...@@ -43,8 +44,6 @@ const BankInfor = (props) => { ...@@ -43,8 +44,6 @@ const BankInfor = (props) => {
const [bank_no, setBackNo] = useState(''); const [bank_no, setBackNo] = useState('');
const [account_no, setAccountNo] = useState(''); const [account_no, setAccountNo] = useState('');
console.log(props.route.params.body);
const createFormData = (identity_after, identity_before, sign_img, body) => { const createFormData = (identity_after, identity_before, sign_img, body) => {
const data = new FormData(); const data = new FormData();
...@@ -105,19 +104,17 @@ const BankInfor = (props) => { ...@@ -105,19 +104,17 @@ const BankInfor = (props) => {
props.hideLoading(); props.hideLoading();
if (res.data.code == 200) { if (res.data.code == 200) {
setTimeout(() => { showAlert(TYPE.SUCCESS, I18n.t('Notification'), res.data.message);
Alert.alert(I18n.t('Notification'), res.data.message);
}, 500);
setBackNo(''); setBackNo('');
setAccountNo(''); setAccountNo('');
setAccType(''); setAccType('');
} else { } else {
setTimeout(() => { showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
Alert.alert(I18n.t('Notification'), res.data.message);
}, 500);
} }
} else { } else {
Alert.alert( showAlert(
TYPE.WARN,
I18n.t('Notification'), I18n.t('Notification'),
I18n.t('Please_fill_in') + titles[index], I18n.t('Please_fill_in') + titles[index],
); );
......
...@@ -22,6 +22,7 @@ import PickerImg from '../../../components/Picker/PickerImg'; ...@@ -22,6 +22,7 @@ import PickerImg from '../../../components/Picker/PickerImg';
import I18n from '../../../helper/i18/i18n'; import I18n from '../../../helper/i18/i18n';
import {checkFormatArray, convertTime} from '../../../Config/Functions'; import {checkFormatArray, convertTime} from '../../../Config/Functions';
import {showAlert, TYPE} from '../../../components/DropdownAlert';
const GeneralInfor = (props) => { const GeneralInfor = (props) => {
const [lastName, setLastName] = useState(props.user.l_name); const [lastName, setLastName] = useState(props.user.l_name);
...@@ -49,7 +50,8 @@ const GeneralInfor = (props) => { ...@@ -49,7 +50,8 @@ const GeneralInfor = (props) => {
address, address,
}); });
} else { } else {
Alert.alert( showAlert(
TYPE.WARN,
I18n.t('Notification'), I18n.t('Notification'),
I18n.t('Please_fill_in') + titles[index], I18n.t('Please_fill_in') + titles[index],
); );
......
...@@ -30,6 +30,7 @@ import PickerItem from '../../../components/Picker/PickerItem'; ...@@ -30,6 +30,7 @@ import PickerItem from '../../../components/Picker/PickerItem';
import {saveUserToRedux} from '../../../actions/users'; import {saveUserToRedux} from '../../../actions/users';
import I18n from '../../../helper/i18/i18n'; import I18n from '../../../helper/i18/i18n';
import {uploadImage} from '../../../apis/Functions/Upload'; import {uploadImage} from '../../../apis/Functions/Upload';
import {TYPE} from '../../../components/DropdownAlert';
const {width} = Dimensions.get('window'); const {width} = Dimensions.get('window');
...@@ -139,25 +140,28 @@ const Profile = (props) => { ...@@ -139,25 +140,28 @@ const Profile = (props) => {
props.hideLoading(); props.hideLoading();
if (res?.status == 200 && res.data) { if (res?.status == 200 && res.data) {
if (res.data.code == 200) { if (res.data.code == 200) {
setTimeout(() => { showAlert(
props.saveUserToRedux(res.data.data); TYPE.SUCCESS,
Alert.alert(I18n.t('Notification'), res.data.message); I18n.t('Notification'),
props.navigation.popToTop(); res.data.message,
}, 500); );
props.saveUserToRedux(res.data.data);
props.navigation.popToTop();
} else { } else {
props.hideLoading(); props.hideLoading();
setTimeout(() => { showAlert(
Alert.alert(I18n.t('Notification'), res.data.message); TYPE.ERROR,
}, 500); I18n.t('Notification'),
res.data.message,
);
} }
} else { } else {
props.hideLoading(); props.hideLoading();
setTimeout(() => { showAlert(
Alert.alert( TYPE.ERROR,
I18n.t('Notification'), I18n.t('Notification'),
I18n.t('UploadImageFail'), I18n.t('UploadImageFail'),
); );
}, 500);
} }
} }
} }
...@@ -165,7 +169,8 @@ const Profile = (props) => { ...@@ -165,7 +169,8 @@ const Profile = (props) => {
); );
} else { } else {
props.hideLoading(); props.hideLoading();
Alert.alert( showAlert(
TYPE.ERROR,
I18n.t('Notification'), I18n.t('Notification'),
I18n.t('Please_fill_in') + titles[index], I18n.t('Please_fill_in') + titles[index],
); );
......
...@@ -6,6 +6,7 @@ import Item from './Item'; ...@@ -6,6 +6,7 @@ import Item from './Item';
import {getListMethod} from '../../../apis/Functions/Deposit'; import {getListMethod} from '../../../apis/Functions/Deposit';
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import I18n from '../../../helper/i18/i18n'; import I18n from '../../../helper/i18/i18n';
import {showAlert, TYPE} from '../../../components/DropdownAlert';
const MethodPayView = (props) => { const MethodPayView = (props) => {
const [data, setData] = useState([]); const [data, setData] = useState([]);
...@@ -20,7 +21,7 @@ const MethodPayView = (props) => { ...@@ -20,7 +21,7 @@ const MethodPayView = (props) => {
if (res.data.code == 200 && res.data.data) { if (res.data.code == 200 && res.data.data) {
setData(res.data.data); setData(res.data.data);
} else { } else {
Alert.alert(I18n.t('Notification'), I18n.t('')); showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
} }
}; };
......
...@@ -3,6 +3,7 @@ import {Alert} from 'react-native'; ...@@ -3,6 +3,7 @@ import {Alert} from 'react-native';
import HistoryView from './HistoryView'; import HistoryView from './HistoryView';
import {getListTransaction} from '../../../apis/Functions/Widthdraw'; import {getListTransaction} from '../../../apis/Functions/Widthdraw';
import I18n from '../../../helper/i18/i18n'; import I18n from '../../../helper/i18/i18n';
import {showAlert, TYPE} from '../../../components/DropdownAlert';
const History = (props) => { const History = (props) => {
const [selected, setSelected] = useState('ALL'); const [selected, setSelected] = useState('ALL');
...@@ -37,9 +38,8 @@ const History = (props) => { ...@@ -37,9 +38,8 @@ const History = (props) => {
if ((res.data.code = 200 && res.data.data)) { if ((res.data.code = 200 && res.data.data)) {
setData(res.data.data); setData(res.data.data);
setTotalPage(res.data.meta.pages); setTotalPage(res.data.meta.pages);
console.log(res.data.data);
} else { } else {
Alert.alert(I18n.t('Notification'), res.data.message); showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
} }
}; };
......
...@@ -26,6 +26,7 @@ import {widthDraw, getListWidthDraw} from '../../../apis/Functions/Widthdraw'; ...@@ -26,6 +26,7 @@ import {widthDraw, getListWidthDraw} from '../../../apis/Functions/Widthdraw';
import {showLoading, hideLoading} from '../../../actions/loadingAction'; import {showLoading, hideLoading} from '../../../actions/loadingAction';
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {TABNAVIGATOR} from '../../../routers/ScreenNames'; import {TABNAVIGATOR} from '../../../routers/ScreenNames';
import {showAlert, TYPE} from '../../../components/DropdownAlert';
const CELL_COUNT = 4; const CELL_COUNT = 4;
...@@ -43,9 +44,9 @@ const ConfirmOTP = (propsa) => { ...@@ -43,9 +44,9 @@ const ConfirmOTP = (propsa) => {
const confirm = async () => { const confirm = async () => {
if (!value) { if (!value) {
Alert.alert(I18n.t('Notification'), I18n.t('EnterOTPRequest')); showAlert(TYPE.WARN, I18n.t('Notification'), I18n.t('EnterOTPRequest'));
} else if (value.length != 4) { } else if (value.length != 4) {
Alert.alert(I18n.t('Notification'), I18n.t('OTPInvalid')); showAlert(TYPE.WARN, I18n.t('Notification'), I18n.t('OTPInvalid'));
} else { } else {
propsa.showLoading(); propsa.showLoading();
...@@ -81,18 +82,15 @@ const ConfirmOTP = (propsa) => { ...@@ -81,18 +82,15 @@ const ConfirmOTP = (propsa) => {
propsa.hideLoading(); propsa.hideLoading();
if (res.data.code == 200) { if (res.data.code == 200) {
setTimeout(() => { setTimeout(() => {
Alert.alert(I18n.t('Notification'), res.data.message); showAlert(TYPE.SUCCESS, I18n.t('Notification'), res.data.message);
navigate.navigate(TABNAVIGATOR); navigate.navigate(TABNAVIGATOR);
}, 500); }, 500);
} else { } else {
setTimeout(() => { showAlert(TYPE.SUCCESS, I18n.t('Notification'), res.data.message);
Alert.alert(I18n.t('Notification'), res.data.message);
}, 500);
} }
} else { } else {
setTimeout(() => { showAlert(TYPE.SUCCESS, I18n.t('Notification'), res.data.message);
Alert.alert(I18n.t('Notification'), res.data.message);
}, 500);
} }
propsa.hideLoading(); propsa.hideLoading();
......
...@@ -5,6 +5,7 @@ import Item from './Item'; ...@@ -5,6 +5,7 @@ import Item from './Item';
import {getListTransaction} from '../../../../apis/Functions/Widthdraw'; import {getListTransaction} from '../../../../apis/Functions/Widthdraw';
import AppText from '../../../../components/AppText'; import AppText from '../../../../components/AppText';
import I18n from '../../../../helper/i18/i18n'; import I18n from '../../../../helper/i18/i18n';
import {showAlert, TYPE} from '../../../../components/DropdownAlert';
const Success = (props) => { const Success = (props) => {
const [page, setPage] = useState(1); const [page, setPage] = useState(1);
...@@ -34,7 +35,7 @@ const Success = (props) => { ...@@ -34,7 +35,7 @@ const Success = (props) => {
setData(res.data.data); setData(res.data.data);
setTotalPage(res.data.meta.pages); setTotalPage(res.data.meta.pages);
} else { } else {
Alert.alert(I18n.t('Notification'), res.data.message); showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
} }
}; };
......
...@@ -7,6 +7,7 @@ import {useNavigation} from '@react-navigation/native'; ...@@ -7,6 +7,7 @@ import {useNavigation} from '@react-navigation/native';
import AppText from '../../../../components/AppText'; import AppText from '../../../../components/AppText';
import I18n from '../../../../helper/i18/i18n'; import I18n from '../../../../helper/i18/i18n';
import {TYPE} from '../../../../components/DropdownAlert';
const Watting = (props) => { const Watting = (props) => {
const [page, setPage] = useState(1); const [page, setPage] = useState(1);
...@@ -41,7 +42,7 @@ const Watting = (props) => { ...@@ -41,7 +42,7 @@ const Watting = (props) => {
setData(res.data.data); setData(res.data.data);
setTotalPage(res.data.meta.pages); setTotalPage(res.data.meta.pages);
} else { } else {
Alert.alert(I18n.t('Notification'), res.data.message); showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
} }
}; };
......
...@@ -31,6 +31,7 @@ import I18n from '../../../helper/i18/i18n'; ...@@ -31,6 +31,7 @@ import I18n from '../../../helper/i18/i18n';
import {OTPWALLET} from '../../../routers/ScreenNames'; import {OTPWALLET} from '../../../routers/ScreenNames';
import {getOTPApi} from '../../../apis/Functions/users'; import {getOTPApi} from '../../../apis/Functions/users';
import {showAlert, TYPE} from '../../../components/DropdownAlert';
const {width} = Dimensions.get('window'); const {width} = Dimensions.get('window');
...@@ -56,12 +57,11 @@ const WalletDeposit = (props) => { ...@@ -56,12 +57,11 @@ const WalletDeposit = (props) => {
if (res.data.code == 200) { if (res.data.code == 200) {
navigate.navigate(OTPWALLET, {type: 'DEPOSIT', amount, notes}); navigate.navigate(OTPWALLET, {type: 'DEPOSIT', amount, notes});
} else { } else {
setTimeout(() => { showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
Alert.alert(I18n.t('Notification'), res.data.message);
}, 500);
} }
} else { } else {
Alert.alert( showAlert(
TYPE.WARN,
I18n.t('Notification'), I18n.t('Notification'),
I18n.t('Please_fill_in') + titles[index], I18n.t('Please_fill_in') + titles[index],
); );
......
...@@ -35,6 +35,7 @@ import TextMoney from '../../../components/Input/InputMoney'; ...@@ -35,6 +35,7 @@ import TextMoney from '../../../components/Input/InputMoney';
import I18n from '../../../helper/i18/i18n'; import I18n from '../../../helper/i18/i18n';
import {getOTPApi} from '../../../apis/Functions/users'; import {getOTPApi} from '../../../apis/Functions/users';
import {OTPWALLET} from '../../../routers/ScreenNames'; import {OTPWALLET} from '../../../routers/ScreenNames';
import {showAlert, TYPE} from '../../../components/DropdownAlert';
var radio_props = [ var radio_props = [
{label: I18n.t('FromWallet'), value: 'WALLET'}, {label: I18n.t('FromWallet'), value: 'WALLET'},
{label: I18n.t('FromCQGAccount'), value: 'INVESTMENT'}, {label: I18n.t('FromCQGAccount'), value: 'INVESTMENT'},
...@@ -74,7 +75,7 @@ const WalletWithdraw = (props) => { ...@@ -74,7 +75,7 @@ const WalletWithdraw = (props) => {
setData(newList); setData(newList);
} }
} else { } else {
Alert.alert(I18n.t('Notification'), I18n.t('Can_not_get_data')); showAlert(TYPE.ERROR, I18n.t('Notification'), I18n.t('Can_not_get_data'));
} }
}; };
...@@ -102,14 +103,13 @@ const WalletWithdraw = (props) => { ...@@ -102,14 +103,13 @@ const WalletWithdraw = (props) => {
notes, notes,
}); });
} else { } else {
setTimeout(() => { showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
Alert.alert(I18n.t('Notification'), res.data.message);
}, 500);
} }
props.hideLoading(); props.hideLoading();
} else { } else {
Alert.alert( showAlert(
TYPE.WARN,
I18n.t('Notification'), I18n.t('Notification'),
I18n.t('Please_fill_in') + titles[index], I18n.t('Please_fill_in') + titles[index],
); );
......
...@@ -6,6 +6,7 @@ import Item from './Item'; ...@@ -6,6 +6,7 @@ import Item from './Item';
import {getListWidthDraw} from '../../../apis/Functions/Widthdraw'; import {getListWidthDraw} from '../../../apis/Functions/Widthdraw';
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import I18n from '../../../helper/i18/i18n'; import I18n from '../../../helper/i18/i18n';
import {showAlert, TYPE} from '../../../components/DropdownAlert';
const WithdrawView = (props) => { const WithdrawView = (props) => {
const [data, setData] = useState([]); const [data, setData] = useState([]);
...@@ -21,7 +22,7 @@ const WithdrawView = (props) => { ...@@ -21,7 +22,7 @@ const WithdrawView = (props) => {
if (res.data.code == 200 && res.data.data) { if (res.data.code == 200 && res.data.data) {
setData(res.data.data); setData(res.data.data);
} else { } else {
Alert.alert(I18n.t('Notification'), I18n.t('Can_not_get_data')); showAlert(TYPE.ERROR, I18n.t('Notification'), I18n.t('Can_not_get_data'));
} }
}; };
......
...@@ -17,6 +17,7 @@ import {CONFIRMOTP} from '../../routers/ScreenNames'; ...@@ -17,6 +17,7 @@ import {CONFIRMOTP} from '../../routers/ScreenNames';
import {getOTPApi} from '../../apis/Functions/users'; import {getOTPApi} from '../../apis/Functions/users';
import {showLoading, hideLoading} from '../../actions/loadingAction'; import {showLoading, hideLoading} from '../../actions/loadingAction';
import I18n from '../../helper/i18/i18n'; import I18n from '../../helper/i18/i18n';
import {TYPE} from '../../components/DropdownAlert';
const ConfirmEmail = (props) => { const ConfirmEmail = (props) => {
const [value, setValue] = useState(''); const [value, setValue] = useState('');
...@@ -35,12 +36,14 @@ const ConfirmEmail = (props) => { ...@@ -35,12 +36,14 @@ const ConfirmEmail = (props) => {
if (res.data.code == 200) { if (res.data.code == 200) {
navigate.navigate(CONFIRMOTP, {email: value}); navigate.navigate(CONFIRMOTP, {email: value});
} else { } else {
setTimeout(() => { showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
Alert.alert(I18n.t('Notification'), res.data.message);
}, 500);
} }
} else { } else {
Alert.alert(I18n.t('Notification'), `${I18n.t('EnterEmailRequest')}!`); showAlert(
TYPE.WARN,
I18n.t('Notification'),
`${I18n.t('EnterEmailRequest')}!`,
);
} }
}; };
......
...@@ -26,6 +26,7 @@ import AppText from '../../components/AppText'; ...@@ -26,6 +26,7 @@ import AppText from '../../components/AppText';
import {showLoading, hideLoading} from '../../actions/loadingAction'; import {showLoading, hideLoading} from '../../actions/loadingAction';
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {showAlert, TYPE} from '../../components/DropdownAlert';
const CELL_COUNT = 4; const CELL_COUNT = 4;
...@@ -42,9 +43,9 @@ const ConfirmOTP = (propsa) => { ...@@ -42,9 +43,9 @@ const ConfirmOTP = (propsa) => {
const confirm = async () => { const confirm = async () => {
if (!value) { if (!value) {
Alert.alert(I18n.t('Notification'), I18n.t('EnterOTPRequest')); showAlert(TYPE.WARN, I18n.t('Notification'), I18n.t('EnterOTPRequest'));
} else if (value.length != 4) { } else if (value.length != 4) {
Alert.alert(I18n.t('Notification'), I18n.t('OTPInvalid')); showAlert(TYPE.WARN, I18n.t('Notification'), I18n.t('OTPInvalid'));
} else { } else {
propsa.showLoading(); propsa.showLoading();
const res = await verifyOTPApi({ const res = await verifyOTPApi({
...@@ -61,7 +62,7 @@ const ConfirmOTP = (propsa) => { ...@@ -61,7 +62,7 @@ const ConfirmOTP = (propsa) => {
email: propsa.route.params.email, email: propsa.route.params.email,
}); });
} else { } else {
Alert.alert(I18n.t('Notification'), res.data.message); showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
} }
} }
}; };
......
...@@ -28,6 +28,7 @@ import {connect} from 'react-redux'; ...@@ -28,6 +28,7 @@ import {connect} from 'react-redux';
import messaging from '@react-native-firebase/messaging'; import messaging from '@react-native-firebase/messaging';
import I18n from '../../helper/i18/i18n'; import I18n from '../../helper/i18/i18n';
import AppText from '../../components/AppText'; import AppText from '../../components/AppText';
import {showAlert, TYPE} from '../../components/DropdownAlert';
const Login = (props) => { const Login = (props) => {
const {navigation} = props; const {navigation} = props;
...@@ -90,12 +91,11 @@ const Login = (props) => { ...@@ -90,12 +91,11 @@ const Login = (props) => {
routes: [{name: TABNAVIGATOR}], routes: [{name: TABNAVIGATOR}],
}); });
} else { } else {
setTimeout(() => { showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
Alert.alert(I18n.t('Notification'), res.data.message);
}, 500);
} }
} else { } else {
Alert.alert( showAlert(
TYPE.WARN,
I18n.t('Notification'), I18n.t('Notification'),
I18n.t('Please_fill_in') + titles[index], I18n.t('Please_fill_in') + titles[index],
); );
......
...@@ -19,6 +19,7 @@ import I18n from '../../helper/i18/i18n'; ...@@ -19,6 +19,7 @@ import I18n from '../../helper/i18/i18n';
import {showLoading, hideLoading} from '../../actions/loadingAction'; import {showLoading, hideLoading} from '../../actions/loadingAction';
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {showAlert, TYPE} from '../../components/DropdownAlert';
const NewPassword = (props) => { const NewPassword = (props) => {
const [password, setPassword] = useState(''); const [password, setPassword] = useState('');
...@@ -29,7 +30,7 @@ const NewPassword = (props) => { ...@@ -29,7 +30,7 @@ const NewPassword = (props) => {
const changePass = async () => { const changePass = async () => {
if (!password || !cfPassword) { if (!password || !cfPassword) {
Alert.alert(I18n.t('EnterAllInfo')); showAlert(TYPE.WARN, I18n.t('Notification'), I18n.t('EnterAllInfo'));
} else { } else {
props.showLoading(); props.showLoading();
const res = await forgotPasswordApi({ const res = await forgotPasswordApi({
...@@ -42,18 +43,17 @@ const NewPassword = (props) => { ...@@ -42,18 +43,17 @@ const NewPassword = (props) => {
props.hideLoading(); props.hideLoading();
if (res.data.code == 200) { if (res.data.code == 200) {
await setTimeout(() => { navigate.reset({
Alert.alert(I18n.t('Notification'), I18n.t('ChangePasswordSuccess')); index: 1,
navigate.reset({ routes: [{name: AUTHEN}],
index: 1, });
routes: [{name: AUTHEN}], showAlert(
}); TYPE.SUCCESS,
}, 500); I18n.t('Notification'),
I18n.t('ChangePasswordSuccess'),
);
} else { } else {
setTimeout(() => { showAlert(TYPE.SUCCESS, I18n.t('Notification'), res.data.message);
console.log('response', res.data);
Alert.alert(I18n.t('Notification'), res.data.message);
}, 500);
} }
} }
}; };
......
...@@ -26,6 +26,7 @@ import AppText from '../../components/AppText'; ...@@ -26,6 +26,7 @@ import AppText from '../../components/AppText';
import {showLoading, hideLoading} from '../../actions/loadingAction'; import {showLoading, hideLoading} from '../../actions/loadingAction';
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {showAlert, TYPE} from '../../components/DropdownAlert';
const CELL_COUNT = 4; const CELL_COUNT = 4;
...@@ -42,9 +43,9 @@ const ConfirmOTP = (propsa) => { ...@@ -42,9 +43,9 @@ const ConfirmOTP = (propsa) => {
const confirm = async () => { const confirm = async () => {
if (!value) { if (!value) {
Alert.alert(I18n.t('Notification'), I18n.t('EnterOTPRequest')); showAlert(TYPE.WARN, I18n.t('Notification'), I18n.t('EnterOTPRequest'));
} else if (value.length != 4) { } else if (value.length != 4) {
Alert.alert(I18n.t('Notification'), I18n.t('OTPInvalid')); showAlert(TYPE.WARN, I18n.t('Notification'), I18n.t('OTPInvalid'));
} else { } else {
propsa.showLoading(); propsa.showLoading();
const res = await verifyOTPApi({ const res = await verifyOTPApi({
...@@ -83,22 +84,17 @@ const ConfirmOTP = (propsa) => { ...@@ -83,22 +84,17 @@ const ConfirmOTP = (propsa) => {
propsa.hideLoading(); propsa.hideLoading();
if (res.data.code == 200 && res.data.data) { if (res.data.code == 200 && res.data.data) {
setTimeout(() => { showAlert(
Alert.alert( TYPE.WARN,
I18n.t('Notification'), I18n.t('Notification'),
I18n.t('RegisterAccountSuccess'), I18n.t('RegisterAccountSuccess'),
); );
navigate.navigate('LOGIN'); navigate.navigate('LOGIN');
}, 500);
} else { } else {
setTimeout(() => { showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
Alert.alert(I18n.t('Notification'), res.data.message);
}, 500);
} }
} else { } else {
setTimeout(() => { showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
Alert.alert(I18n.t('Notification'), res.data.message);
}, 500);
} }
propsa.hideLoading(); propsa.hideLoading();
......
...@@ -17,6 +17,7 @@ import {registorApi, getOTPApi} from '../../apis/Functions/users'; ...@@ -17,6 +17,7 @@ import {registorApi, getOTPApi} from '../../apis/Functions/users';
import I18n from '../../helper/i18/i18n'; import I18n from '../../helper/i18/i18n';
import AppText from '../../components/AppText'; import AppText from '../../components/AppText';
import {REGISTEROTP} from '../../routers/ScreenNames'; import {REGISTEROTP} from '../../routers/ScreenNames';
import {showAlert, TYPE} from '../../components/DropdownAlert';
const Registor = (props) => { const Registor = (props) => {
const {navigation} = props; const {navigation} = props;
...@@ -58,12 +59,11 @@ const Registor = (props) => { ...@@ -58,12 +59,11 @@ const Registor = (props) => {
sponsor_id, sponsor_id,
}); });
} else { } else {
setTimeout(() => { showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
Alert.alert(I18n.t('Notification'), res.data.message);
}, 500);
} }
} else { } else {
Alert.alert( showAlert(
TYPE.ERROR,
I18n.t('Notification'), I18n.t('Notification'),
I18n.t('Please_fill_in') + titles[index], I18n.t('Please_fill_in') + titles[index],
); );
......
...@@ -7,6 +7,7 @@ import {sendFeedBack} from '../../apis/Functions/General'; ...@@ -7,6 +7,7 @@ import {sendFeedBack} from '../../apis/Functions/General';
import {showLoading, hideLoading} from '../../actions/loadingAction'; import {showLoading, hideLoading} from '../../actions/loadingAction';
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 {showAlert, TYPE} from '../../components/DropdownAlert';
const Feedback = (props) => { const Feedback = (props) => {
const naviation = useNavigation(); const naviation = useNavigation();
...@@ -25,18 +26,12 @@ const Feedback = (props) => { ...@@ -25,18 +26,12 @@ const Feedback = (props) => {
if (res?.status == 200 && res.data) { if (res?.status == 200 && res.data) {
if (res.data.code == 200) { if (res.data.code == 200) {
naviation.goBack(); naviation.goBack();
setTimeout(() => { showAlert(TYPE.SUCCESS, I18n.t('Notification'), res.data.message);
Alert.alert(I18n.t('Notification'), res.data.message);
}, 500);
} else { } else {
setTimeout(() => { showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
Alert.alert(I18n.t('Notification'), res.data.message);
}, 500);
} }
} else { } else {
setTimeout(() => { showAlert(TYPE.ERROR, I18n.t('Notification'), 'upload fail');
Alert.alert(I18n.t('Notification'), 'upload fail');
}, 500);
} }
}; };
const createFormData = (photo, body) => { const createFormData = (photo, body) => {
......
...@@ -10,157 +10,184 @@ import HomeView from './HomeView'; ...@@ -10,157 +10,184 @@ import HomeView from './HomeView';
import {getListCategoryProduct} from '../../apis/Functions/Transaction'; 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';
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});
const [dataPrice, setDataPrice] = useState([]); const [dataPrice, setDataPrice] = useState([]);
const [dataPriceFilter, setDataPriceFilter] = useState([]); const [dataPriceFilter, setDataPriceFilter] = useState([]);
const [listImage, setListImage] = useState([]); const [listImage, setListImage] = useState([]);
const [filters, setFilters] = useState([]); const [filters, setFilters] = useState([]);
const [filterId, setFilterId] = useState(null); const [filterId, setFilterId] = useState(null);
const [isSortName, setIsSortName] = useState(null); const [isSortName, setIsSortName] = useState(null);
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);
const SORT_TYPE = { const SORT_TYPE = {
DESC: 'DESC', DESC: 'DESC',
ASC: 'ASC' ASC: 'ASC',
} };
useEffect(() => { useEffect(() => {
getData(); getData();
initSocket(); initSocket();
}, []); }, []);
useEffect(() => { useEffect(() => {
const newList = filterId == -1 ? [...dataPrice] : _.filter([...dataPrice], item => item.category_id == filterId); const newList =
setDataPriceFilter(newList); filterId == -1
}, [dataPrice]); ? [...dataPrice]
: _.filter([...dataPrice], (item) => item.category_id == filterId);
const initSocket = () => { setDataPriceFilter(newList);
let io = require('socket.io-client'); }, [dataPrice]);
let socket = io.connect('http://222.252.22.174:8087', {
transports: ['websocket'],
jsonp: false,
reconnect: true,
});
socket.on('response-update-price', (message) => {
receivedMessage(message);
});
};
const receivedMessage = (message) => {
setDataPrice(message);
};
const getData = async () => {
props.showLoading();
const res = await getTransaction({});
if (res.data.code == 200 && res.data.data) {
setData(res.data.data);
} else {
Alert.alert(I18n.t('Notification'), I18n.t('Can_not_get_data'));
}
const res1 = await getImagesHome({}); const initSocket = () => {
if (res1.data.code == 200 && res1.data.data) { let io = require('socket.io-client');
setListImage(res1.data.data); let socket = io.connect('http://222.252.22.174:8087', {
} else { transports: ['websocket'],
Alert.alert(I18n.t('Notification'), I18n.t('Can_not_get_data')); jsonp: false,
} reconnect: true,
const resCategoryProduct = await getListCategoryProduct({ });
keyword: '', socket.on('response-update-price', (message) => {
platform: Platform.OS, receivedMessage(message);
page_size: 20, });
page_index: 1, };
type: 'PRODUCT',
});
console.log(resCategoryProduct);
if ((resCategoryProduct.data.code = 200 && resCategoryProduct.data.data)) {
let data = [];
data.push({id: -1, name: 'All'});
setFilters(data.concat([...resCategoryProduct.data.data]));
} else {
Alert.alert(I18n.t('Notification'), res.data.message);
}
const resPriceHome = await getPriceTable({});
if (resPriceHome.data.code == 200 && resPriceHome.data.data) {
setDataPrice(resPriceHome.data.data);
setDataPriceFilter(resPriceHome.data.data);
} else {
Alert.alert(I18n.t('Notification'), I18n.t('Can_not_get_data'));
}
props.hideLoading();
console.log('filterId', filterId);
};
const changeFilter = (id) => { const receivedMessage = (message) => {
setFilterId(id); setDataPrice(message);
const newList = id == -1 ? [...dataPrice] : _.filter([...dataPrice], item => item.category_id == id); };
setDataPriceFilter(newList);
console.log(id, newList);
};
const onSortByName = () => { const getData = async () => {
let type = 'ASC' props.showLoading();
if(!isSortName || isSortName == SORT_TYPE.ASC) type = SORT_TYPE.DESC const res = await getTransaction({});
let newData = type == SORT_TYPE.ASC ? [...dataPriceFilter].sort((a, b) => a.name > b.name ? 1 : -1 ) if (res.data.code == 200 && res.data.data) {
: [...dataPriceFilter].sort((a, b) => a.name < b.name ? 1 : -1 ) setData(res.data.data);
setDataPriceFilter(newData) } else {
setIsSortPriceOpenClose(null) showAlert(TYPE.ERROR, I18n.t('Notification'), I18n.t('Can_not_get_data'));
setIsSortName(type)
setIsSortPercent(null)
setIsSortPriceHighLow(null)
} }
const onSortByPercent = () => {
let type = 'ASC' const res1 = await getImagesHome({});
if(!isSortPercent || isSortPercent == SORT_TYPE.ASC) type = SORT_TYPE.DESC if (res1.data.code == 200 && res1.data.data) {
let newData = type == SORT_TYPE.ASC ? [...dataPriceFilter].sort((a, b) => a.change > b.change ? 1 : -1 ) setListImage(res1.data.data);
: [...dataPriceFilter].sort((a, b) => a.change < b.change ? 1 : -1 ) } else {
setDataPriceFilter(newData) showAlert(TYPE.ERROR, I18n.t('Notification'), I18n.t('Can_not_get_data'));
setIsSortPriceOpenClose(null)
setIsSortName(null)
setIsSortPercent(type)
setIsSortPriceHighLow(null)
} }
const onSortByPriceOpenClose = () => { const resCategoryProduct = await getListCategoryProduct({
let type = 'ASC' keyword: '',
if(!isSortPriceOpenClose || isSortPriceOpenClose == SORT_TYPE.ASC) type = SORT_TYPE.DESC platform: Platform.OS,
let newData = type == SORT_TYPE.ASC ? [...dataPriceFilter].sort((a, b) => a.open_price > b.open_price ? 1 : -1 ) page_size: 20,
: [...dataPriceFilter].sort((a, b) => a.open_price < b.open_price ? 1 : -1 ) page_index: 1,
setDataPriceFilter(newData) type: 'PRODUCT',
setIsSortPriceOpenClose(type) });
setIsSortName(null) console.log(resCategoryProduct);
setIsSortPercent(null) if ((resCategoryProduct.data.code = 200 && resCategoryProduct.data.data)) {
setIsSortPriceHighLow(null) let data = [];
data.push({id: -1, name: 'All'});
setFilters(data.concat([...resCategoryProduct.data.data]));
} else {
showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
} }
const onSortByPriceHighLow = () => { const resPriceHome = await getPriceTable({});
let type = 'ASC' if (resPriceHome.data.code == 200 && resPriceHome.data.data) {
if(!isSortPriceHighLow || isSortPriceHighLow == SORT_TYPE.ASC) type = SORT_TYPE.DESC setDataPrice(resPriceHome.data.data);
let newData = type == SORT_TYPE.ASC ? [...dataPriceFilter].sort((a, b) => a.high_price > b.high_price ? 1 : -1 ) setDataPriceFilter(resPriceHome.data.data);
: [...dataPriceFilter].sort((a, b) => a.high_price < b.high_price ? 1 : -1 ) } else {
setDataPriceFilter(newData) showAlert(TYPE.ERROR, I18n.t('Notification'), I18n.t('Can_not_get_data'));
setIsSortPriceOpenClose(null)
setIsSortName(null)
setIsSortPercent(null)
setIsSortPriceHighLow(type)
} }
props.hideLoading();
console.log('filterId', filterId);
};
const changeFilter = (id) => {
setFilterId(id);
const newList =
id == -1
? [...dataPrice]
: _.filter([...dataPrice], (item) => item.category_id == id);
setDataPriceFilter(newList);
console.log(id, newList);
};
const onSortByName = () => {
let type = 'ASC';
if (!isSortName || isSortName == SORT_TYPE.ASC) type = SORT_TYPE.DESC;
let newData =
type == SORT_TYPE.ASC
? [...dataPriceFilter].sort((a, b) => (a.name > b.name ? 1 : -1))
: [...dataPriceFilter].sort((a, b) => (a.name < b.name ? 1 : -1));
setDataPriceFilter(newData);
setIsSortPriceOpenClose(null);
setIsSortName(type);
setIsSortPercent(null);
setIsSortPriceHighLow(null);
};
const onSortByPercent = () => {
let type = 'ASC';
if (!isSortPercent || isSortPercent == SORT_TYPE.ASC) type = SORT_TYPE.DESC;
let newData =
type == SORT_TYPE.ASC
? [...dataPriceFilter].sort((a, b) => (a.change > b.change ? 1 : -1))
: [...dataPriceFilter].sort((a, b) => (a.change < b.change ? 1 : -1));
setDataPriceFilter(newData);
setIsSortPriceOpenClose(null);
setIsSortName(null);
setIsSortPercent(type);
setIsSortPriceHighLow(null);
};
const onSortByPriceOpenClose = () => {
let type = 'ASC';
if (!isSortPriceOpenClose || isSortPriceOpenClose == SORT_TYPE.ASC)
type = SORT_TYPE.DESC;
let newData =
type == SORT_TYPE.ASC
? [...dataPriceFilter].sort((a, b) =>
a.open_price > b.open_price ? 1 : -1,
)
: [...dataPriceFilter].sort((a, b) =>
a.open_price < b.open_price ? 1 : -1,
);
setDataPriceFilter(newData);
setIsSortPriceOpenClose(type);
setIsSortName(null);
setIsSortPercent(null);
setIsSortPriceHighLow(null);
};
const onSortByPriceHighLow = () => {
let type = 'ASC';
if (!isSortPriceHighLow || isSortPriceHighLow == SORT_TYPE.ASC)
type = SORT_TYPE.DESC;
let newData =
type == SORT_TYPE.ASC
? [...dataPriceFilter].sort((a, b) =>
a.high_price > b.high_price ? 1 : -1,
)
: [...dataPriceFilter].sort((a, b) =>
a.high_price < b.high_price ? 1 : -1,
);
setDataPriceFilter(newData);
setIsSortPriceOpenClose(null);
setIsSortName(null);
setIsSortPercent(null);
setIsSortPriceHighLow(type);
};
return <HomeView return (
data={data} <HomeView
dataPrice={dataPriceFilter} data={data}
listImage={listImage} dataPrice={dataPriceFilter}
filterId={filterId} listImage={listImage}
filters={filters} filterId={filterId}
setFilterId={changeFilter} filters={filters}
onSortByName={onSortByName} setFilterId={changeFilter}
onSortByPercent={onSortByPercent} onSortByName={onSortByName}
onSortByPriceOpenClose={onSortByPriceOpenClose} onSortByPercent={onSortByPercent}
onSortByPriceHighLow={onSortByPriceHighLow} onSortByPriceOpenClose={onSortByPriceOpenClose}
/>; onSortByPriceHighLow={onSortByPriceHighLow}
/>
);
}; };
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
return { return {
user: state.userReducer, user: state.userReducer,
}; };
}; };
export default connect(mapStateToProps, {showLoading, hideLoading})(Home); export default connect(mapStateToProps, {showLoading, hideLoading})(Home);
...@@ -5,6 +5,7 @@ import Item from './Item'; ...@@ -5,6 +5,7 @@ import Item from './Item';
import AppText from '../../../components/AppText'; import AppText from '../../../components/AppText';
import {getListTransaction} from '../../../apis/Functions/Widthdraw'; import {getListTransaction} from '../../../apis/Functions/Widthdraw';
import I18n from '../../../helper/i18/i18n'; import I18n from '../../../helper/i18/i18n';
import {showAlert, TYPE} from '../../../components/DropdownAlert';
const Payments = (props) => { const Payments = (props) => {
const [page, setPage] = useState(1); const [page, setPage] = useState(1);
...@@ -31,9 +32,8 @@ const Payments = (props) => { ...@@ -31,9 +32,8 @@ const Payments = (props) => {
if ((res.data.code = 200 && res.data.data)) { if ((res.data.code = 200 && res.data.data)) {
setData(res.data.data); setData(res.data.data);
setTotalPage(res.data.meta.pages); setTotalPage(res.data.meta.pages);
console.log(res.data.data);
} else { } else {
Alert.alert(I18n.t('Notification'), res.data.message); showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
} }
}; };
......
...@@ -28,13 +28,17 @@ import { ...@@ -28,13 +28,17 @@ import {
checkFormatArray, checkFormatArray,
} from '../../../../Config/Functions'; } from '../../../../Config/Functions';
import {updateInforUser} from '../../../../apis/Functions/users'; import {updateInforUser} from '../../../../apis/Functions/users';
import {showAlert, TYPE} from '../../../../components/DropdownAlert';
const GeneralInfor = (props) => { const GeneralInfor = (props) => {
const [phone, setPhone] = useState(props.user.phone); const [phone, setPhone] = useState(props.user.phone);
const [address, setAddress] = useState(props.user.address); const [address, setAddress] = useState(props.user.address);
const onClick = async () => { const onClick = async () => {
const titles = [I18n.t('Phone').toLowerCase(), I18n.t('Address').toLowerCase()]; const titles = [
I18n.t('Phone').toLowerCase(),
I18n.t('Address').toLowerCase(),
];
const index = checkFormatArray([phone, address]); const index = checkFormatArray([phone, address]);
if (index === true) { if (index === true) {
props.showLoading(); props.showLoading();
...@@ -46,18 +50,15 @@ const GeneralInfor = (props) => { ...@@ -46,18 +50,15 @@ const GeneralInfor = (props) => {
}); });
props.hideLoading(); props.hideLoading();
if (res.data.code == 200) { if (res.data.code == 200) {
setTimeout(() => { props.saveUserToRedux(res.data.data);
props.saveUserToRedux(res.data.data); showAlert(TYPE.SUCCESS, I18n.t('Notification'), res.data.message);
Alert.alert(I18n.t('Notification'), res.data.message); props.navigation.popToTop();
props.navigation.popToTop();
}, 500);
} else { } else {
setTimeout(() => { showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
Alert.alert(I18n.t('Notification'), res.data.message);
}, 500);
} }
} else { } else {
Alert.alert( showAlert(
TYPE.ERROR,
I18n.t('Notification'), I18n.t('Notification'),
I18n.t('Please_fill_in') + titles[index], I18n.t('Please_fill_in') + titles[index],
); );
...@@ -136,8 +137,7 @@ const GeneralInfor = (props) => { ...@@ -136,8 +137,7 @@ const GeneralInfor = (props) => {
<View style={{height: 40}} /> <View style={{height: 40}} />
<View style={{justifyContent: 'center', alignItems: 'center'}}> <View style={{justifyContent: 'center', alignItems: 'center'}}>
<TouchableOpacity onPress={onClick} style={styles.btn}> <TouchableOpacity onPress={onClick} style={styles.btn}>
<AppText i18nKey={'Update'} style={styles.txtBtn}> <AppText i18nKey={'Update'} style={styles.txtBtn}></AppText>
</AppText>
</TouchableOpacity> </TouchableOpacity>
</View> </View>
</View> </View>
......
...@@ -26,6 +26,7 @@ import {showLoading, hideLoading} from '../../actions/loadingAction'; ...@@ -26,6 +26,7 @@ import {showLoading, hideLoading} from '../../actions/loadingAction';
import {useNavigation} from '@react-navigation/native'; import {useNavigation} from '@react-navigation/native';
import I18n from '../../helper/i18/i18n'; import I18n from '../../helper/i18/i18n';
import SelectBankModal from './SelectBankModal'; import SelectBankModal from './SelectBankModal';
import {showAlert, TYPE} from '../../components/DropdownAlert';
const {width} = Dimensions.get('window'); const {width} = Dimensions.get('window');
...@@ -49,7 +50,7 @@ const AddMethodPay = (props) => { ...@@ -49,7 +50,7 @@ const AddMethodPay = (props) => {
if (res.data.code == 200 && res.data.data) { if (res.data.code == 200 && res.data.data) {
setData(res.data.data); setData(res.data.data);
} else { } else {
Alert.alert(I18n.t('Notification'), I18n.t('Can_not_get_data')); showAlert(TYPE.ERROR, I18n.t('Notification'), I18n.t('Can_not_get_data'));
} }
}; };
...@@ -77,17 +78,14 @@ const AddMethodPay = (props) => { ...@@ -77,17 +78,14 @@ const AddMethodPay = (props) => {
}); });
props.hideLoading(); props.hideLoading();
if (res.data.code == 200) { if (res.data.code == 200) {
setTimeout(() => { showAlert(TYPE.SUCCESS, I18n.t('Notification'), res.data.message);
Alert.alert(I18n.t('Notification'), res.data.message); navigate.goBack();
navigate.goBack();
}, 500);
} else { } else {
setTimeout(() => { showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
Alert.alert(I18n.t('Notification'), res.data.message);
}, 500);
} }
} else { } else {
Alert.alert( showAlert(
TYPE.ERROR,
I18n.t('Notification'), I18n.t('Notification'),
I18n.t('Please_fill_in') + titles[index], I18n.t('Please_fill_in') + titles[index],
); );
......
...@@ -4,6 +4,7 @@ import MethodPayView from './MethodPayView'; ...@@ -4,6 +4,7 @@ import MethodPayView from './MethodPayView';
import {getListWidthDraw} from '../../apis/Functions/Widthdraw'; import {getListWidthDraw} from '../../apis/Functions/Widthdraw';
import {useNavigation} from '@react-navigation/native'; import {useNavigation} from '@react-navigation/native';
import I18n from '../../helper/i18/i18n'; import I18n from '../../helper/i18/i18n';
import {showAlert, TYPE} from '../../components/DropdownAlert';
const MethodPay = (props) => { const MethodPay = (props) => {
const [data, setData] = useState([]); const [data, setData] = useState([]);
...@@ -31,7 +32,7 @@ const MethodPay = (props) => { ...@@ -31,7 +32,7 @@ const MethodPay = (props) => {
if (res.data.code == 200 && res.data.data) { if (res.data.code == 200 && res.data.data) {
setData(res.data.data); setData(res.data.data);
} else { } else {
Alert.alert(I18n.t('Notification'), I18n.t('Can_not_get_data')); showAlert(TYPE.ERROR, I18n.t('Notification'), I18n.t('Can_not_get_data'));
} }
}; };
......
import React, {useState, useEffect} from 'react'; import React, {useState, useEffect} from 'react';
import { import {
View, View,
Text, Text,
StyleSheet, StyleSheet,
FlatList, FlatList,
Dimensions, Dimensions,
TouchableOpacity, TouchableOpacity,
Alert, Alert,
KeyboardAvoidingView, KeyboardAvoidingView,
TouchableWithoutFeedback, TouchableWithoutFeedback,
Keyboard, Keyboard,
Platform, Platform,
} from 'react-native'; } from 'react-native';
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import R from '../../assets/R'; import R from '../../assets/R';
...@@ -22,198 +22,193 @@ import {getFontXD, WIDTHXD, checkFormatArray} from '../../Config/Functions'; ...@@ -22,198 +22,193 @@ import {getFontXD, WIDTHXD, checkFormatArray} from '../../Config/Functions';
import TextField from '../../components/Input/TextField'; import TextField from '../../components/Input/TextField';
import PickerItem from '../../components/Picker/PickerItem'; import PickerItem from '../../components/Picker/PickerItem';
import { import {
deleteMethodBank, deleteMethodBank,
addMethodBank, addMethodBank,
updateMethodBank, updateMethodBank,
} from '../../apis/Functions/Widthdraw'; } from '../../apis/Functions/Widthdraw';
import {showLoading, hideLoading} from '../../actions/loadingAction'; import {showLoading, hideLoading} from '../../actions/loadingAction';
import {useNavigation} from '@react-navigation/native'; import {useNavigation} from '@react-navigation/native';
import BankInfor from '../../components/BankInfor'; import BankInfor from '../../components/BankInfor';
import AppText from '../../components/AppText'; import AppText from '../../components/AppText';
import {TYPE} from '../../components/DropdownAlert';
const {width} = Dimensions.get('window'); const {width} = Dimensions.get('window');
const MethodPayDetail = (props) => { const MethodPayDetail = (props) => {
const [data, setData] = useState([]); const [data, setData] = useState([]);
const {params} = props.route; const {params} = props.route;
const [disable, setDisable] = useState(true); const [disable, setDisable] = useState(true);
const navigate = useNavigation(); const navigate = useNavigation();
const [branch_name, setBankName] = useState(params.branch_name); const [branch_name, setBankName] = useState(params.branch_name);
const [account_name, setAccountName] = useState(params.account_name); const [account_name, setAccountName] = useState(params.account_name);
const [account_no, setAccountNo] = useState(params.account_no); const [account_no, setAccountNo] = useState(params.account_no);
const onUpdate = async () => { const onUpdate = async () => {
const titles = [ const titles = [
I18n.t('Branch').toLowerCase(), I18n.t('Branch').toLowerCase(),
I18n.t('OwnerAccount2').toLowerCase(), I18n.t('OwnerAccount2').toLowerCase(),
I18n.t('AccountNumber').toLowerCase() I18n.t('AccountNumber').toLowerCase(),
]; ];
const index = checkFormatArray([branch_name, account_name, account_no]); const index = checkFormatArray([branch_name, account_name, account_no]);
if (index === true) { if (index === true) {
if ( if (
branch_name != params.branch_name || branch_name != params.branch_name ||
account_name != params.account_name || account_name != params.account_name ||
account_no != params.account_no account_no != params.account_no
) { ) {
props.showLoading();
const res = await updateMethodBank({
platform: Platform.OS,
id: params.id,
branch_name,
account_name,
account_no,
});
props.hideLoading();
if (res.data.code == 200) {
setTimeout(() => {
Alert.alert(I18n.t('Notification'), res.data.message);
navigate.goBack();
}, 500);
} else {
setTimeout(() => {
Alert.alert(I18n.t('Notification'), res.data.message);
}, 500);
}
} else {
Alert.alert(I18n.t('Notification'), I18n.t('NothingChange'));
}
} else {
Alert.alert(
I18n.t('Notification'),
I18n.t('Please_fill_in') + titles[index],
);
}
};
const onRemove = async () => {
props.showLoading(); props.showLoading();
const res = await deleteMethodBank({ const res = await updateMethodBank({
platform: Platform.OS, platform: Platform.OS,
id: params.id, id: params.id,
branch_name,
account_name,
account_no,
}); });
props.hideLoading(); props.hideLoading();
if (res.data.code == 200) { if (res.data.code == 200) {
setTimeout(() => { showAlert(TYPE.SUCCESS, I18n.t('Notification'), res.data.message);
Alert.alert(I18n.t('Notification'), res.data.message);
navigate.goBack(); navigate.goBack();
}, 500);
} else { } else {
setTimeout(() => { showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
Alert.alert(I18n.t('Notification'), res.data.message);
}, 500);
} }
}; } else {
showAlert(TYPE.WARN, I18n.t('Notification'), I18n.t('NothingChange'));
}
} else {
showAlert(
TYPE.WARN,
I18n.t('Notification'),
I18n.t('Please_fill_in') + titles[index],
);
}
};
const onRemove = async () => {
props.showLoading();
const res = await deleteMethodBank({
platform: Platform.OS,
id: params.id,
});
props.hideLoading();
if (res.data.code == 200) {
showAlert(TYPE.SUCCESS, I18n.t('Notification'), res.data.message);
navigate.goBack();
} else {
showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
}
};
return ( return (
<KeyboardAvoidingView <KeyboardAvoidingView
behavior={Platform.Os === 'ios' ? 'padding' : 'height'} behavior={Platform.Os === 'ios' ? 'padding' : 'height'}
style={{flex: 1}} style={{flex: 1}}
keyboardVerticalOffset={-50}> keyboardVerticalOffset={-50}>
<TouchableWithoutFeedback onPress={Keyboard.dismiss}> <TouchableWithoutFeedback onPress={Keyboard.dismiss}>
<View style={{flex: 1}}> <View style={{flex: 1}}>
<HeaderBack title={'DetailMethod'}/> <HeaderBack title={'DetailMethod'} />
<View style={{flex: 1}}> <View style={{flex: 1}}>
<View style={styles.container}> <View style={styles.container}>
<BankInfor <BankInfor
linkImg={params.bank.logo} linkImg={params.bank.logo}
title={I18n.t('SelectBank')} title={I18n.t('SelectBank')}
value={params.bank.name} value={params.bank.name}
/> />
<TextField <TextField
onChangeText={(val) => setBankName(val)} onChangeText={(val) => setBankName(val)}
title={I18n.t('Branch')} title={I18n.t('Branch')}
value={branch_name} value={branch_name}
/> />
<TextField <TextField
onChangeText={(val) => setAccountName(val)} onChangeText={(val) => setAccountName(val)}
title={I18n.t('OwnerAccountName')} title={I18n.t('OwnerAccountName')}
value={account_name} value={account_name}
/> />
<TextField <TextField
onChangeText={(val) => setAccountNo(val)} onChangeText={(val) => setAccountNo(val)}
title={I18n.t('AccountNumber')} title={I18n.t('AccountNumber')}
isNumber={true} isNumber={true}
value={account_no} value={account_no}
/> />
</View> </View>
</View> </View>
<View style={styles.footer}> <View style={styles.footer}>
<TouchableOpacity onPress={onUpdate} style={styles.btnLeft}> <TouchableOpacity onPress={onUpdate} style={styles.btnLeft}>
<AppText style={styles.txtAdd} i18nKey={('Update')}/> <AppText style={styles.txtAdd} i18nKey={'Update'} />
</TouchableOpacity> </TouchableOpacity>
<TouchableOpacity <TouchableOpacity
onPress={() => { onPress={() => {
Alert.alert( Alert.alert(
`${I18n.t('Notification')}!`, `${I18n.t('Notification')}!`,
I18n.t('DeletePaymentMethodConfirm'), I18n.t('DeletePaymentMethodConfirm'),
[ [
{ {
text: I18n.t('Forbidden'), text: I18n.t('Forbidden'),
style: 'cancel', style: 'cancel',
}, },
{text: I18n.t('Ok'), onPress: () => onRemove()}, {text: I18n.t('Ok'), onPress: () => onRemove()},
], ],
); );
}} }}
style={styles.btnRight}> style={styles.btnRight}>
<AppText style={styles.txtAdd} i18nKey={('Delete')}/> <AppText style={styles.txtAdd} i18nKey={'Delete'} />
</TouchableOpacity> </TouchableOpacity>
</View> </View>
</View> </View>
</TouchableWithoutFeedback> </TouchableWithoutFeedback>
</KeyboardAvoidingView> </KeyboardAvoidingView>
); );
}; };
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { container: {
paddingHorizontal: 20, paddingHorizontal: 20,
paddingTop: 10, paddingTop: 10,
}, },
footer: { footer: {
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', alignItems: 'center',
justifyContent: 'space-between', justifyContent: 'space-between',
marginBottom: 10, marginBottom: 10,
paddingHorizontal: 20, paddingHorizontal: 20,
}, },
btnLeft: { btnLeft: {
width: 150, width: 150,
height: 40, height: 40,
justifyContent: 'center', justifyContent: 'center',
alignItems: 'center', alignItems: 'center',
backgroundColor: R.colors.main, backgroundColor: R.colors.main,
borderRadius: 5, borderRadius: 5,
}, },
btnRight: { btnRight: {
width: 150, width: 150,
height: 40, height: 40,
justifyContent: 'center', justifyContent: 'center',
alignItems: 'center', alignItems: 'center',
backgroundColor: R.colors.main, backgroundColor: R.colors.main,
borderRadius: 5, borderRadius: 5,
}, },
txtAdd: { txtAdd: {
color: R.colors.white, color: R.colors.white,
fontSize: getFontXD(46), fontSize: getFontXD(46),
textTransform: 'uppercase', textTransform: 'uppercase',
fontWeight: 'bold', fontWeight: 'bold',
}, },
txtTitle: { txtTitle: {
fontSize: getFontXD(42), fontSize: getFontXD(42),
color: R.colors.color777, color: R.colors.color777,
marginBottom: 5, marginBottom: 5,
}, },
}); });
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
return { return {
user: state.userReducer, user: state.userReducer,
}; };
}; };
export default connect(mapStateToProps, { export default connect(mapStateToProps, {
showLoading, showLoading,
hideLoading, hideLoading,
})(MethodPayDetail); })(MethodPayDetail);
import React, {Component, useState, useEffect, useRef} from 'react'; import React, {Component, useState, useEffect, useRef} from 'react';
import {View, Text, Platform, FlatList} from 'react-native'; import {View, Text, Platform, FlatList} from 'react-native';
import {getListCalendar} from '../../../apis/Functions/NewFeed'; import {getListCalendar} from '../../../apis/Functions/NewFeed';
import {showAlert, TYPE} from '../../../components/DropdownAlert';
import {convertTimeApi} from '../../../Config/Functions'; import {convertTimeApi} from '../../../Config/Functions';
import I18n from '../../../helper/i18/i18n'; import I18n from '../../../helper/i18/i18n';
...@@ -31,7 +32,7 @@ const NewFeed = (props) => { ...@@ -31,7 +32,7 @@ const NewFeed = (props) => {
if (res.data.code == 200 && res.data.data) { if (res.data.code == 200 && res.data.data) {
setData(res.data.data); setData(res.data.data);
} else { } else {
Alert.alert(I18n.t('Notification'), I18n.t('Can_not_get_data')); showAlert(TYPE.ERROR, I18n.t('Notification'), I18n.t('Can_not_get_data'));
} }
}; };
......
...@@ -4,6 +4,7 @@ import I18n from '../../../helper/i18/i18n'; ...@@ -4,6 +4,7 @@ import I18n from '../../../helper/i18/i18n';
import MediaView from './MediaView'; import MediaView from './MediaView';
import {getListMedia} from '../../../apis/Functions/NewFeed'; import {getListMedia} from '../../../apis/Functions/NewFeed';
import {showAlert, TYPE} from '../../../components/DropdownAlert';
const Media = (props) => { const Media = (props) => {
const [data, setData] = useState([]); const [data, setData] = useState([]);
...@@ -24,7 +25,7 @@ const Media = (props) => { ...@@ -24,7 +25,7 @@ const Media = (props) => {
setMediaHot(res.data.data[0].data[0]); setMediaHot(res.data.data[0].data[0]);
setData(res.data.data); setData(res.data.data);
} else { } else {
Alert.alert(I18n.t('Notification'), I18n.t('Can_not_get_data')); showAlert(TYPE.ERROR, I18n.t('Notification'), I18n.t('Can_not_get_data'));
} }
}; };
......
...@@ -6,6 +6,7 @@ import { ...@@ -6,6 +6,7 @@ import {
ImageBackground, ImageBackground,
TouchableOpacity, TouchableOpacity,
FlatList, FlatList,
Alert,
} from 'react-native'; } from 'react-native';
import YouTube from 'react-native-youtube'; import YouTube from 'react-native-youtube';
import R from '../../../assets/R'; import R from '../../../assets/R';
...@@ -17,6 +18,7 @@ import {MEDIADETAIL} from '../../../routers/ScreenNames'; ...@@ -17,6 +18,7 @@ import {MEDIADETAIL} from '../../../routers/ScreenNames';
import {getDetailMedia} from '../../../apis/Functions/NewFeed'; import {getDetailMedia} from '../../../apis/Functions/NewFeed';
import I18n from '../../../helper/i18/i18n'; import I18n from '../../../helper/i18/i18n';
import AppText from '../../../components/AppText'; import AppText from '../../../components/AppText';
import {showAlert, TYPE} from '../../../components/DropdownAlert';
const Item = (props) => { const Item = (props) => {
const navigate = useNavigation(); const navigate = useNavigation();
...@@ -64,7 +66,7 @@ const MediaDetail = (props) => { ...@@ -64,7 +66,7 @@ const MediaDetail = (props) => {
if (res.data.code == 200 && res.data.data) { if (res.data.code == 200 && res.data.data) {
setData(res.data.data); setData(res.data.data);
} else { } else {
Alert.alert(I18n.t('Notification'), I18n.t('Can_not_get_data')); showAlert(TYPE.ERROR, I18n.t('Notification'), I18n.t('Can_not_get_data'));
} }
}; };
return ( return (
...@@ -83,7 +85,7 @@ const MediaDetail = (props) => { ...@@ -83,7 +85,7 @@ const MediaDetail = (props) => {
<Text style={styles.txtTitle}>{data.title}</Text> <Text style={styles.txtTitle}>{data.title}</Text>
</View> </View>
<View style={styles.body}> <View style={styles.body}>
<AppText style={styles.txtBig} i18nKey={('TopVideo')}/> <AppText style={styles.txtBig} i18nKey={'TopVideo'} />
<FlatList <FlatList
showsVerticalScrollIndicator={false} showsVerticalScrollIndicator={false}
data={data.related_videos} data={data.related_videos}
......
...@@ -15,6 +15,7 @@ import Item from './item'; ...@@ -15,6 +15,7 @@ import Item from './item';
import {getListNew, getListCategoryNew} from '../../../apis/Functions/NewFeed'; import {getListNew, getListCategoryNew} from '../../../apis/Functions/NewFeed';
import I18n from '../../../helper/i18/i18n'; import I18n from '../../../helper/i18/i18n';
import AppText from '../../../components/AppText'; import AppText from '../../../components/AppText';
import {showAlert, TYPE} from '../../../components/DropdownAlert';
const NewFeed = (props) => { const NewFeed = (props) => {
const [selected, setSelected] = useState(''); const [selected, setSelected] = useState('');
...@@ -35,7 +36,7 @@ const NewFeed = (props) => { ...@@ -35,7 +36,7 @@ const NewFeed = (props) => {
setFillters(res.data.data); setFillters(res.data.data);
console.log(res.data.data); console.log(res.data.data);
} else { } else {
Alert.alert(I18n.t('Notification'), res.data.message); showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
} }
}; };
...@@ -62,7 +63,7 @@ const NewFeed = (props) => { ...@@ -62,7 +63,7 @@ const NewFeed = (props) => {
setData(res.data.data); setData(res.data.data);
setTotalPage(res.data.meta.pages); setTotalPage(res.data.meta.pages);
} else { } else {
Alert.alert(I18n.t('Notification'), res.data.message); showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
} }
setisRefresh(false); setisRefresh(false);
}; };
......
...@@ -2,6 +2,7 @@ import React, {useState, useEffect} from 'react'; ...@@ -2,6 +2,7 @@ import React, {useState, useEffect} from 'react';
import {getListNotification} from '../../apis/Functions/users'; import {getListNotification} from '../../apis/Functions/users';
import NotificationView from './NotificaitonView'; import NotificationView from './NotificaitonView';
import I18n from '../../helper/i18/i18n'; import I18n from '../../helper/i18/i18n';
import {showAlert, TYPE} from '../../components/DropdownAlert';
const Notifcation = (props) => { const Notifcation = (props) => {
const [selected, setSelected] = useState(''); const [selected, setSelected] = useState('');
const [page, setPage] = useState(1); const [page, setPage] = useState(1);
...@@ -29,7 +30,7 @@ const Notifcation = (props) => { ...@@ -29,7 +30,7 @@ const Notifcation = (props) => {
setData(res.data.data); setData(res.data.data);
setTotalPage(res.data.meta.pages); setTotalPage(res.data.meta.pages);
} else { } else {
Alert.alert(I18n.t('Notification'), res.data.message); showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
} }
}; };
......
...@@ -6,6 +6,7 @@ import {updateLangugeApi} from '../../apis/Functions/users'; ...@@ -6,6 +6,7 @@ import {updateLangugeApi} from '../../apis/Functions/users';
import I18n from '../../helper/i18/i18n'; import I18n from '../../helper/i18/i18n';
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {showLoading, hideLoading} from '../../actions/loadingAction'; import {showLoading, hideLoading} from '../../actions/loadingAction';
import {showAlert, TYPE} from '../../components/DropdownAlert';
const Setting = (props) => { const Setting = (props) => {
const convertKeyLanguage = (key) => { const convertKeyLanguage = (key) => {
...@@ -21,13 +22,9 @@ const Setting = (props) => { ...@@ -21,13 +22,9 @@ const Setting = (props) => {
}); });
props.hideLoading(); props.hideLoading();
if (res.data.code == 200) { if (res.data.code == 200) {
setTimeout(() => { showAlert(TYPE.SUCCESS, I18n.t('Notification'), res.data.message);
Alert.alert(I18n.t('Notification'), res.data.message);
}, 500);
} else { } else {
setTimeout(() => { showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
Alert.alert(I18n.t('Notification'), res.data.message);
}, 500);
} }
}; };
......
...@@ -2,9 +2,13 @@ import React, {useState, useEffect} from 'react'; ...@@ -2,9 +2,13 @@ import React, {useState, useEffect} from 'react';
import {getListNotification} from '../../../apis/Functions/users'; import {getListNotification} from '../../../apis/Functions/users';
import DueDateView from './DueDateView'; import DueDateView from './DueDateView';
import I18n from '../../../helper/i18/i18n'; import I18n from '../../../helper/i18/i18n';
import {getListCategoryProduct, getTransactionListByCategory} from '../../../apis/Functions/Transaction'; import {
getListCategoryProduct,
getTransactionListByCategory,
} from '../../../apis/Functions/Transaction';
import {Alert, Platform} from 'react-native'; import {Alert, Platform} from 'react-native';
import PriceListView from '../PriceList/PriceListView'; import PriceListView from '../PriceList/PriceListView';
import {showAlert, TYPE} from '../../../components/DropdownAlert';
const DueDate = (props) => { const DueDate = (props) => {
const [page, setPage] = useState(1); const [page, setPage] = useState(1);
...@@ -18,7 +22,7 @@ const DueDate = (props) => { ...@@ -18,7 +22,7 @@ const DueDate = (props) => {
getCategoryData(); getCategoryData();
}, []); }, []);
useEffect(() => { useEffect(() => {
setData([]) setData([]);
getData(); getData();
}, [filterId]); }, [filterId]);
...@@ -36,7 +40,7 @@ const DueDate = (props) => { ...@@ -36,7 +40,7 @@ const DueDate = (props) => {
data.push({id: -1, name: 'All'}); data.push({id: -1, name: 'All'});
setFilters(data.concat([...res.data.data])); setFilters(data.concat([...res.data.data]));
} else { } else {
Alert.alert(I18n.t('Notification'), res.data.message); showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
} }
}; };
...@@ -53,7 +57,7 @@ const DueDate = (props) => { ...@@ -53,7 +57,7 @@ const DueDate = (props) => {
platform: Platform.OS, platform: Platform.OS,
page_size: 10, page_size: 10,
page_index: 1, page_index: 1,
type:'EXPIRY_DATE', type: 'EXPIRY_DATE',
category_id: filterId, category_id: filterId,
}); });
setIsRefresh(false); setIsRefresh(false);
...@@ -62,7 +66,7 @@ const DueDate = (props) => { ...@@ -62,7 +66,7 @@ const DueDate = (props) => {
setData(res.data.data); setData(res.data.data);
setTotalPage(res.data.meta.pages); setTotalPage(res.data.meta.pages);
} else { } else {
Alert.alert(I18n.t('Notification'), res.data.message); showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
} }
}; };
...@@ -80,7 +84,7 @@ const DueDate = (props) => { ...@@ -80,7 +84,7 @@ const DueDate = (props) => {
platform: Platform.OS, platform: Platform.OS,
page_size: 10, page_size: 10,
page_index: page + 1, page_index: page + 1,
type:'EXPIRY_DATE', type: 'EXPIRY_DATE',
category_id: filterId, category_id: filterId,
}); });
setPage(page + 1); setPage(page + 1);
...@@ -90,7 +94,6 @@ const DueDate = (props) => { ...@@ -90,7 +94,6 @@ const DueDate = (props) => {
setIsRefresh(false); setIsRefresh(false);
}; };
return ( return (
<DueDateView <DueDateView
onRefresh={onRefresh} onRefresh={onRefresh}
......
...@@ -2,9 +2,13 @@ import React, {useState, useEffect} from 'react'; ...@@ -2,9 +2,13 @@ import React, {useState, useEffect} from 'react';
import {getListNotification} from '../../../apis/Functions/users'; import {getListNotification} from '../../../apis/Functions/users';
import EscrowView from './EscrowView'; import EscrowView from './EscrowView';
import I18n from '../../../helper/i18/i18n'; import I18n from '../../../helper/i18/i18n';
import {getListCategoryProduct, getTransactionListByCategory} from '../../../apis/Functions/Transaction'; import {
getListCategoryProduct,
getTransactionListByCategory,
} from '../../../apis/Functions/Transaction';
import {Alert, Platform} from 'react-native'; import {Alert, Platform} from 'react-native';
import PriceListView from '../PriceList/PriceListView'; import PriceListView from '../PriceList/PriceListView';
import {showAlert, TYPE} from '../../../components/DropdownAlert';
const Escrow = (props) => { const Escrow = (props) => {
const [selected, setSelected] = useState(''); const [selected, setSelected] = useState('');
const [page, setPage] = useState(1); const [page, setPage] = useState(1);
...@@ -18,7 +22,7 @@ const Escrow = (props) => { ...@@ -18,7 +22,7 @@ const Escrow = (props) => {
getCategoryData(); getCategoryData();
}, []); }, []);
useEffect(() => { useEffect(() => {
setData([]) setData([]);
getData(); getData();
}, [filterId]); }, [filterId]);
...@@ -36,7 +40,7 @@ const Escrow = (props) => { ...@@ -36,7 +40,7 @@ const Escrow = (props) => {
data.push({id: -1, name: 'All'}); data.push({id: -1, name: 'All'});
setFilters(data.concat([...res.data.data])); setFilters(data.concat([...res.data.data]));
} else { } else {
Alert.alert(I18n.t('Notification'), res.data.message); showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
} }
}; };
...@@ -53,7 +57,7 @@ const Escrow = (props) => { ...@@ -53,7 +57,7 @@ const Escrow = (props) => {
platform: Platform.OS, platform: Platform.OS,
page_size: 10, page_size: 10,
page_index: 1, page_index: 1,
type:'ESCROW', type: 'ESCROW',
category_id: filterId, category_id: filterId,
}); });
setIsRefresh(false); setIsRefresh(false);
...@@ -62,7 +66,7 @@ const Escrow = (props) => { ...@@ -62,7 +66,7 @@ const Escrow = (props) => {
setData(res.data.data); setData(res.data.data);
setTotalPage(res.data.meta.pages); setTotalPage(res.data.meta.pages);
} else { } else {
Alert.alert(I18n.t('Notification'), res.data.message); showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
} }
}; };
...@@ -80,7 +84,7 @@ const Escrow = (props) => { ...@@ -80,7 +84,7 @@ const Escrow = (props) => {
platform: Platform.OS, platform: Platform.OS,
page_size: 10, page_size: 10,
page_index: page + 1, page_index: page + 1,
type:'ESCROW', type: 'ESCROW',
category_id: filterId, category_id: filterId,
}); });
setPage(page + 1); setPage(page + 1);
......
import React, {useState, useEffect} from 'react'; import React, {useState, useEffect} from 'react';
import {getListCategoryProduct, getTransactionListByCategory} from '../../../apis/Functions/Transaction'; import {
getListCategoryProduct,
getTransactionListByCategory,
} from '../../../apis/Functions/Transaction';
import PriceListView from './PriceListView'; import PriceListView from './PriceListView';
import I18n from '../../../helper/i18/i18n'; import I18n from '../../../helper/i18/i18n';
import {Alert, Platform} from 'react-native'; import {Alert, Platform} from 'react-native';
import {showAlert, TYPE} from '../../../components/DropdownAlert';
const PriceList = (props) => { const PriceList = (props) => {
const [selected, setSelected] = useState(''); const [selected, setSelected] = useState('');
const [page, setPage] = useState(1); const [page, setPage] = useState(1);
const [data, setData] = useState([]); const [data, setData] = useState([]);
const [tottalPage, setTotalPage] = useState(1); const [tottalPage, setTotalPage] = useState(1);
const [isRefresh, setIsRefresh] = useState(false); const [isRefresh, setIsRefresh] = useState(false);
const [filters, setFilters] = useState([]); const [filters, setFilters] = useState([]);
const [filterId, setFilterId] = useState(-1); const [filterId, setFilterId] = useState(-1);
useEffect(() => { useEffect(() => {
getCategoryData(); getCategoryData();
}, []); }, []);
useEffect(() => { useEffect(() => {
setData([]) setData([]);
getData(); getData();
}, [filterId]); }, [filterId]);
const getCategoryData = async () => { const getCategoryData = async () => {
// setIsRefresh(true); // setIsRefresh(true);
const res = await getListCategoryProduct({ const res = await getListCategoryProduct({
keyword: '', keyword: '',
platform: Platform.OS, platform: Platform.OS,
page_size: 20, page_size: 20,
page_index: 1, page_index: 1,
type: 'PRODUCT', type: 'PRODUCT',
}); });
if ((res.data.code = 200 && res.data.data)) { if ((res.data.code = 200 && res.data.data)) {
let data = []; let data = [];
data.push({id: -1, name: 'All'}); data.push({id: -1, name: 'All'});
setFilters(data.concat([...res.data.data])); setFilters(data.concat([...res.data.data]));
} else { } else {
Alert.alert(I18n.t('Notification'), res.data.message); showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
} }
}; };
const onRefresh = () => { const onRefresh = () => {
setPage(1); setPage(1);
getData(); getData();
}; };
const getData = async () => { const getData = async () => {
setIsRefresh(true); setIsRefresh(true);
setPage(1); setPage(1);
const res = await getTransactionListByCategory({ const res = await getTransactionListByCategory({
keyword: '', keyword: '',
platform: Platform.OS, platform: Platform.OS,
page_size: 10, page_size: 10,
page_index: 1, page_index: 1,
type:'PRICE_TABLE', type: 'PRICE_TABLE',
category_id: filterId, category_id: filterId,
}); });
setIsRefresh(false); setIsRefresh(false);
console.log('getData', res); console.log('getData', res);
if ((res.data.code = 200 && res.data.data)) { if ((res.data.code = 200 && res.data.data)) {
setData(res.data.data); setData(res.data.data);
setTotalPage(res.data.meta.pages); setTotalPage(res.data.meta.pages);
} else { } else {
Alert.alert(I18n.t('Notification'), res.data.message); showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
} }
}; };
const onLoadMore = () => { const onLoadMore = () => {
console.log(tottalPage); console.log(tottalPage);
if (page < tottalPage) { if (page < tottalPage) {
getDataLoadMore(); getDataLoadMore();
} }
}; };
const getDataLoadMore = async () => { const getDataLoadMore = async () => {
setIsRefresh(true); setIsRefresh(true);
const res = await getTransactionListByCategory({ const res = await getTransactionListByCategory({
keyword: '', keyword: '',
platform: Platform.OS, platform: Platform.OS,
page_size: 10, page_size: 10,
page_index: page + 1, page_index: page + 1,
type:'PRICE_TABLE', type: 'PRICE_TABLE',
category_id: filterId, category_id: filterId,
}); });
setPage(page + 1); setPage(page + 1);
if (res.data.code == 200) { if (res.data.code == 200) {
setData(data.concat(res.data.data)); setData(data.concat(res.data.data));
} }
setIsRefresh(false); setIsRefresh(false);
}; };
return ( return (
<PriceListView <PriceListView
onRefresh={onRefresh} onRefresh={onRefresh}
isRefresh={isRefresh} isRefresh={isRefresh}
onLoadMore={onLoadMore} onLoadMore={onLoadMore}
setFilterId={setFilterId} setFilterId={setFilterId}
filterId={filterId} filterId={filterId}
filters={filters} filters={filters}
data={data} data={data}
/> />
); );
}; };
export default PriceList; export default PriceList;
import React, {useEffect, useState} from 'react'; import React, {useEffect, useState} from 'react';
import { import {View, ScrollView, StyleSheet, Alert} from 'react-native';
View,
ScrollView,
StyleSheet, Alert,
} from 'react-native';
import R from '../../../../../assets/R'; import R from '../../../../../assets/R';
import GeneralInfo from './ItemView/GeneralInfo'; import GeneralInfo from './ItemView/GeneralInfo';
import TimeTransaction from './ItemView/TimeTransaction'; import TimeTransaction from './ItemView/TimeTransaction';
...@@ -12,42 +8,40 @@ import {HEIGHTXD} from '../../../../../Config/Functions'; ...@@ -12,42 +8,40 @@ import {HEIGHTXD} from '../../../../../Config/Functions';
import {showLoading, hideLoading} from '../../../../../actions/loadingAction'; import {showLoading, hideLoading} from '../../../../../actions/loadingAction';
import {getContractDescription} from '../../../../../apis/Functions/Transaction'; import {getContractDescription} from '../../../../../apis/Functions/Transaction';
import I18n from '../../../../../helper/i18/i18n'; import I18n from '../../../../../helper/i18/i18n';
import {showAlert, TYPE} from '../../../../../components/DropdownAlert';
const ContractDescription = (props) => { const ContractDescription = (props) => {
const[contractDescription, setContractDescription] = useState(null) const [contractDescription, setContractDescription] = useState(null);
useEffect(() => { useEffect(() => {
async function fetchData() { async function fetchData() {
showLoading() showLoading();
const res = await getContractDescription(props.route.params.id) const res = await getContractDescription(props.route.params.id);
if(res.status === 200 && res.data.code ===200) { if (res.status === 200 && res.data.code === 200) {
setContractDescription(res.data.data) setContractDescription(res.data.data);
} else { } else {
Alert.alert(I18n.t('Notification'), res.data.message); showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
} }
console.log(res)
hideLoading()
}
fetchData();
}, [props.route.params.id]);
return (
<ScrollView
style={styles.container}
showsVerticalScrollIndicator={false}>
<View style={{marginBottom: HEIGHTXD(100)}}>
<GeneralInfo contractDescription={contractDescription}/>
<TimeTransaction contractDescription={contractDescription}/>
<PriceInfo contractDescription={contractDescription}/>
</View>
</ScrollView>
);
hideLoading();
}
fetchData();
}, [props.route.params.id]);
return (
<ScrollView style={styles.container} showsVerticalScrollIndicator={false}>
<View style={{marginBottom: HEIGHTXD(100)}}>
<GeneralInfo contractDescription={contractDescription} />
<TimeTransaction contractDescription={contractDescription} />
<PriceInfo contractDescription={contractDescription} />
</View>
</ScrollView>
);
}; };
export default ContractDescription; export default ContractDescription;
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { container: {
flex: 1, flex: 1,
backgroundColor: R.colors.colorBackground, backgroundColor: R.colors.colorBackground,
paddingTop: HEIGHTXD(30), paddingTop: HEIGHTXD(30),
}, },
}); });
import React, {useEffect, useState} from 'react'; import React, {useEffect, useState} from 'react';
import { import {Alert, ScrollView, StyleSheet, Text, View} from 'react-native';
Alert,
ScrollView, StyleSheet, Text,
View,
} from 'react-native';
import {getFontXD, HEIGHTXD} from '../../../../../Config/Functions'; import {getFontXD, HEIGHTXD} from '../../../../../Config/Functions';
import R from '../../../../../assets/R'; import R from '../../../../../assets/R';
import {hideLoading, showLoading} from '../../../../../actions/loadingAction'; import {hideLoading, showLoading} from '../../../../../actions/loadingAction';
import {getContractDescription} from '../../../../../apis/Functions/Transaction'; import {getContractDescription} from '../../../../../apis/Functions/Transaction';
import I18n from '../../../../../helper/i18/i18n'; import I18n from '../../../../../helper/i18/i18n';
import {showAlert, TYPE} from '../../../../../components/DropdownAlert';
const QualityStandard = (props) => { const QualityStandard = (props) => {
const[qualityStandard, setQualityStandard] = useState('') const [qualityStandard, setQualityStandard] = useState('');
useEffect(() => { useEffect(() => {
async function fetchData() { async function fetchData() {
showLoading() showLoading();
const res = await getContractDescription(props.route.params.id) const res = await getContractDescription(props.route.params.id);
if(res.status === 200 && res.data.code ===200) { if (res.status === 200 && res.data.code === 200) {
setQualityStandard(res.data.data.quality_standard_desc) setQualityStandard(res.data.data.quality_standard_desc);
} else { } else {
Alert.alert(I18n.t('Notification'), res.data.message); showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
} }
hideLoading() hideLoading();
} }
fetchData(); fetchData();
}, [props.route.params.id]); }, [props.route.params.id]);
return ( return (
<ScrollView <ScrollView style={styles.container} showsVerticalScrollIndicator={false}>
style={styles.container} <View
showsVerticalScrollIndicator={false}> style={{
<View style={{marginBottom: HEIGHTXD(100), marginBottom: HEIGHTXD(100),
backgroundColor: R.colors.white, backgroundColor: R.colors.white,
width: '100%', width: '100%',
shadowColor: '#181F4D21', shadowColor: '#181F4D21',
shadowOffset: {width: 1, height: 1}, shadowOffset: {width: 1, height: 1},
shadowOpacity: 1, shadowOpacity: 1,
shadowRadius: 2, shadowRadius: 2,
elevation: 1,}}> elevation: 1,
<Text style={styles.content}>{qualityStandard}</Text> }}>
</View> <Text style={styles.content}>{qualityStandard}</Text>
</ScrollView> </View>
) </ScrollView>
);
} };
export default QualityStandard export default QualityStandard;
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { container: {
flex: 1, flex: 1,
backgroundColor: R.colors.colorBackground, backgroundColor: R.colors.colorBackground,
paddingTop: HEIGHTXD(30), paddingTop: HEIGHTXD(30),
}, },
content: { content: {
flex: 3.5, flex: 3.5,
fontSize: getFontXD(36), fontSize: getFontXD(36),
color: R.colors.black, color: R.colors.black,
paddingVertical: HEIGHTXD(30), paddingVertical: HEIGHTXD(30),
paddingHorizontal: HEIGHTXD(30) paddingHorizontal: HEIGHTXD(30),
}, },
}); });
...@@ -2,9 +2,13 @@ import React, {useState, useEffect} from 'react'; ...@@ -2,9 +2,13 @@ import React, {useState, useEffect} from 'react';
import {getListNotification} from '../../../apis/Functions/users'; import {getListNotification} from '../../../apis/Functions/users';
import TimeTransactionView from './TimeTransactionView'; import TimeTransactionView from './TimeTransactionView';
import I18n from '../../../helper/i18/i18n'; import I18n from '../../../helper/i18/i18n';
import {getListCategoryProduct, getTransactionListByCategory} from '../../../apis/Functions/Transaction'; import {
getListCategoryProduct,
getTransactionListByCategory,
} from '../../../apis/Functions/Transaction';
import {Alert, Platform} from 'react-native'; import {Alert, Platform} from 'react-native';
import PriceListView from '../PriceList/PriceListView'; import PriceListView from '../PriceList/PriceListView';
import {showAlert, TYPE} from '../../../components/DropdownAlert';
const PriceList = (props) => { const PriceList = (props) => {
const [selected, setSelected] = useState(''); const [selected, setSelected] = useState('');
const [page, setPage] = useState(1); const [page, setPage] = useState(1);
...@@ -18,7 +22,7 @@ const PriceList = (props) => { ...@@ -18,7 +22,7 @@ const PriceList = (props) => {
getCategoryData(); getCategoryData();
}, []); }, []);
useEffect(() => { useEffect(() => {
setData([]) setData([]);
getData(); getData();
}, [filterId]); }, [filterId]);
...@@ -36,7 +40,7 @@ const PriceList = (props) => { ...@@ -36,7 +40,7 @@ const PriceList = (props) => {
data.push({id: -1, name: 'All'}); data.push({id: -1, name: 'All'});
setFilters(data.concat([...res.data.data])); setFilters(data.concat([...res.data.data]));
} else { } else {
Alert.alert(I18n.t('Notification'), res.data.message); showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
} }
}; };
...@@ -53,7 +57,7 @@ const PriceList = (props) => { ...@@ -53,7 +57,7 @@ const PriceList = (props) => {
platform: Platform.OS, platform: Platform.OS,
page_size: 10, page_size: 10,
page_index: 1, page_index: 1,
type:'TRANSACTION_TIME', type: 'TRANSACTION_TIME',
category_id: filterId, category_id: filterId,
}); });
setIsRefresh(false); setIsRefresh(false);
...@@ -61,7 +65,7 @@ const PriceList = (props) => { ...@@ -61,7 +65,7 @@ const PriceList = (props) => {
setData(res.data.data); setData(res.data.data);
setTotalPage(res.data.meta.pages); setTotalPage(res.data.meta.pages);
} else { } else {
Alert.alert(I18n.t('Notification'), res.data.message); showAlert(TYPE.SUCCESS, I18n.t('Notification'), res.data.message);
} }
}; };
...@@ -79,7 +83,7 @@ const PriceList = (props) => { ...@@ -79,7 +83,7 @@ const PriceList = (props) => {
platform: Platform.OS, platform: Platform.OS,
page_size: 10, page_size: 10,
page_index: page + 1, page_index: page + 1,
type:'TRANSACTION_TIME', type: 'TRANSACTION_TIME',
category_id: filterId, category_id: filterId,
}); });
setPage(page + 1); setPage(page + 1);
......
...@@ -16,6 +16,10 @@ const images = { ...@@ -16,6 +16,10 @@ const images = {
iconMenu: require('./images/iconmenu.png'), iconMenu: require('./images/iconmenu.png'),
bgHome: require('./images/bgHome01.png'), bgHome: require('./images/bgHome01.png'),
iconWarn: require('./images/iconWarn.png'),
iconSuccess: require('./images/iconSuccess.png'),
iconError: require('./images/iconError.png'),
iconUser: require('./images/iconUser1.png'), iconUser: require('./images/iconUser1.png'),
iconUserHome: require('./images/iconUser.png'), iconUserHome: require('./images/iconUser.png'),
iconUserAccuracy: require('./images/iconUserAccuracy.png'), iconUserAccuracy: require('./images/iconUserAccuracy.png'),
......
class DropdownManager {
_defaultDropdown = null;
_defaultDropdownLongTime = null;
register(_ref, _refLongTime) {
if (!this._defaultDropdown) {
this._defaultDropdown = _ref;
}
if (!this._defaultDropdownLongTime) {
this._defaultDropdownLongTime = _refLongTime;
}
}
unregister(_ref, _refLongTime) {
if (!!this._defaultDropdown && this._defaultDropdown._id === _ref._id) {
this._defaultDropdown = null;
}
if (
!!this._defaultDropdownLongTime &&
this._defaultDropdownLongTime._id === _refLongTime._id
) {
this._defaultDropdownLongTime = null;
}
}
getDefault(isLongMessage = false) {
return isLongMessage
? this._defaultDropdownLongTime
: this._defaultDropdown;
}
}
export default new DropdownManager();
import DropdownManager from './DropdownManager';
// Type display dropdown
export const TYPE = {
SUCCESS: 'success',
INFO: 'info',
WARN: 'warn',
ERROR: 'error',
};
/**
* To display dropdown Alert in top screen
* @param type type of Alert (check it in TYPE above)
* @param title title of Alert
* @param description description of Alert
*/
export function showAlert(type, title, description) {
const ref = DropdownManager.getDefault(description.length > 60);
if (!!ref) {
ref.alertWithType(type, title, description);
}
}
/**
* To hide dropdown Alert in top screen
*/
export function hideAlert() {
const ref = DropdownManager.getDefault();
if (!!ref) {
ref.closeAction();
}
}
...@@ -34,6 +34,8 @@ import { ...@@ -34,6 +34,8 @@ import {
PACKETCQG, PACKETCQG,
} from '../../routers/ScreenNames'; } from '../../routers/ScreenNames';
import PickerAvtart from '../../components/Picker/PickerAvatart'; import PickerAvtart from '../../components/Picker/PickerAvatart';
import {showAlert, TYPE} from '../../components/DropdownAlert/index';
const renderWallet = (status, current_money, current_cqg_money, contract) => { const renderWallet = (status, current_money, current_cqg_money, contract) => {
const navigate = useNavigation(); const navigate = useNavigation();
if (status == 4) if (status == 4)
...@@ -220,7 +222,7 @@ const HeaderHome = (props) => { ...@@ -220,7 +222,7 @@ const HeaderHome = (props) => {
}; };
const copyToClipboard = () => { const copyToClipboard = () => {
Alert.alert(I18n.t('Notification'), I18n.t('CopyLink')); showAlert(TYPE.SUCCESS, I18n.t('Notification'), I18n.t('CopyLink'));
Clipboard.setString(props.user.sponsor_url); Clipboard.setString(props.user.sponsor_url);
}; };
......
...@@ -23,6 +23,7 @@ import {useNavigation} from '@react-navigation/native'; ...@@ -23,6 +23,7 @@ import {useNavigation} from '@react-navigation/native';
import {TABNAVIGATOR} from '../../routers/ScreenNames'; import {TABNAVIGATOR} from '../../routers/ScreenNames';
import {changeAvatart} from '../../apis/Functions/users'; import {changeAvatart} from '../../apis/Functions/users';
import {showLoading, hideLoading} from '../../actions/loadingAction'; import {showLoading, hideLoading} from '../../actions/loadingAction';
import {showAlert, TYPE} from '../../components/DropdownAlert/index';
const options = { const options = {
title: 'Select Avatar', title: 'Select Avatar',
...@@ -66,21 +67,16 @@ const PickerImg = (props) => { ...@@ -66,21 +67,16 @@ const PickerImg = (props) => {
props.hideLoading(); props.hideLoading();
if (res?.status == 200 && res.data) { if (res?.status == 200 && res.data) {
if (res.data.code == 200) { if (res.data.code == 200) {
setTimeout(() => { props.saveUserToRedux(res.data.data);
props.saveUserToRedux(res.data.data); showAlert(TYPE.SUCCESS, I18n.t('Notification'), res.data.message);
Alert.alert(I18n.t('Notification'), res.data.message);
}, 500);
} else { } else {
setImgAvatart(props.user.picture_url); setImgAvatart(props.user.picture_url);
setTimeout(() => {
Alert.alert(I18n.t('Notification'), res.data.message); showAlert(TYPE.ERROR, I18n.t('Notification'), res.data.message);
}, 500);
} }
} else { } else {
setImgAvatart(props.user.picture_url); setImgAvatart(props.user.picture_url);
setTimeout(() => { showAlert(TYPE.ERROR, I18n.t('Notification'), 'upload fail');
Alert.alert(I18n.t('Notification'), 'upload fail');
}, 500);
} }
}; };
......
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