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) => {
......
...@@ -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, {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