Commit 23ed3c8c by Giang Tran

api open cqg

parent e3c01803
// Initialize some variables before react-native code would access them
var onmessage=null, self=global;
// Cache Node's original require as __debug__.require
global.__debug__={require: require};
// Prevent leaking process.versions from debugger process to
// worker because pure React Native doesn't do that and some packages as js-md5 rely on this behavior
Object.defineProperty(process, "versions", {
value: undefined
});
// TODO: Replace by url.fileURLToPath method when Node 10 LTS become deprecated
function fileUrlToPath(url) {
if (process.platform === 'win32') {
return url.toString().replace('file:///', '');
} else {
return url.toString().replace('file://', '');
}
}
function getNativeModules() {
var NativeModules;
try {
// This approach is for old RN versions
NativeModules = global.require('NativeModules');
} catch (err) {
// ignore error and try another way for more recent RN versions
try {
var nativeModuleId;
var modules = global.__r.getModules();
var ids = Object.keys(modules);
for (var i = 0; i < ids.length; i++) {
if (modules[ids[i]].verboseName) {
var packagePath = new String(modules[ids[i]].verboseName);
if (packagePath.indexOf('Libraries/BatchedBridge/NativeModules.js') > 0 || packagePath.indexOf('Libraries\\BatchedBridge\\NativeModules.js') > 0) {
nativeModuleId = parseInt(ids[i], 10);
break;
}
}
}
if (nativeModuleId) {
NativeModules = global.__r(nativeModuleId);
}
}
catch (err) {
// suppress errors
}
}
return NativeModules;
}
// Originally, this was made for iOS only
var vscodeHandlers = {
'vscode_reloadApp': function () {
var NativeModules = getNativeModules();
if (NativeModules && NativeModules.DevMenu) {
NativeModules.DevMenu.reload();
}
},
'vscode_showDevMenu': function () {
var NativeModules = getNativeModules();
if (NativeModules && NativeModules.DevMenu) {
NativeModules.DevMenu.show();
}
}
};
process.on("message", function (message) {
if (message.data && vscodeHandlers[message.data.method]) {
vscodeHandlers[message.data.method]();
} else if(onmessage) {
onmessage(message);
}
});
var postMessage = function(message){
process.send(message);
};
if (!self.postMessage) {
self.postMessage = postMessage;
}
var importScripts = (function(){
var fs=require('fs'), vm=require('vm');
return function(scriptUrl){
scriptUrl = fileUrlToPath(scriptUrl);
var scriptCode = fs.readFileSync(scriptUrl, 'utf8');
// Add a 'debugger;' statement to stop code execution
// to wait for the sourcemaps to be processed by the debug adapter
vm.runInThisContext('debugger;' + scriptCode, {filename: scriptUrl});
};
})();
// Worker is ran as nodejs process, so console.trace() writes to stderr and it leads to error in native app
// To avoid this console.trace() is overridden to print stacktrace via console.log()
// Please, see Node JS implementation: https://github.com/nodejs/node/blob/master/lib/internal/console/constructor.js
console.trace = (function() {
return function() {
try {
var err = {
name: 'Trace',
message: require('util').format.apply(null, arguments)
};
// Node uses 10, but usually it's not enough for RN app trace
Error.stackTraceLimit = 30;
Error.captureStackTrace(err, console.trace);
console.log(err.stack);
} catch (e) {
console.error(e);
}
};
})();
// As worker is ran in node, it breaks broadcast-channels package approach of identifying if it’s ran in node:
// https://github.com/pubkey/broadcast-channel/blob/master/src/util.js#L64
// To avoid it if process.toString() is called if will return empty string instead of [object process].
var nativeObjectToString = Object.prototype.toString;
Object.prototype.toString = function() {
if (this === process) {
return '';
} else {
return nativeObjectToString.call(this);
}
};
"use strict";
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
/* global __fbBatchedBridge, self, importScripts, postMessage, onmessage: true */
/* eslint no-unused-vars: 0 */
onmessage = function () {
var visibilityState;
var showVisibilityWarning = function () {
var hasWarned = false;
return function () {
// Wait until `YellowBox` gets initialized before displaying the warning.
if (hasWarned || console.warn.toString().includes('[native code]')) {
return;
}
hasWarned = true;
console.warn('Remote debugger is in a background tab which may cause apps to ' + 'perform slowly. Fix this by foregrounding the tab (or opening it in ' + 'a separate window).');
};
}();
var messageHandlers = {
executeApplicationScript: function (message, sendReply) {
for (var key in message.inject) {
self[key] = JSON.parse(message.inject[key]);
}
var error;
try {
importScripts(message.url);
} catch (err) {
error = err.message;
}
sendReply(null
/* result */
, error);
},
setDebuggerVisibility: function (message) {
visibilityState = message.visibilityState;
}
};
return function (message) {
if (visibilityState === 'hidden') {
showVisibilityWarning();
}
var object = message.data;
var sendReply = function (result, error) {
postMessage({
replyID: object.id,
result: result,
error: error
});
};
var handler = messageHandlers[object.method];
if (handler) {
// Special cased handlers
handler(object, sendReply);
} else {
// Other methods get called on the bridge
var returnValue = [[], [], [], 0];
var error;
try {
if (typeof __fbBatchedBridge === 'object') {
returnValue = __fbBatchedBridge[object.method].apply(null, object.arguments);
} else {
error = 'Failed to call function, __fbBatchedBridge is undefined';
}
} catch (err) {
error = err.message;
} finally {
sendReply(JSON.stringify(returnValue), error);
}
}
};
}();
//# sourceMappingURL=debuggerWorker.js.map
// Notify debugger that we're done with loading
// and started listening for IPC messages
postMessage({workerLoaded:true});
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -4,8 +4,13 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug iOS",
"request": "launch",
"type": "reactnative",
"cwd": "${workspaceFolder}",
"platform": "ios"
},
{
"name": "Attach to Chrome",
"port": 9222,
......@@ -13,12 +18,6 @@
"type": "pwa-chrome",
"webRoot": "${workspaceFolder}"
},
{
"type": "chrome",
"request": "launch",
......
......@@ -30,10 +30,9 @@ const FeePro = (props) => {
if (selected.id == 10) {
const newList = listItem.map((e) => {
if (e.type_data != 'MD') return e;
if (e.selected == false) {
if (selected.selected == false) {
const newList = listItem.filter(
(e) => e.id != 10 && e.type_data == 'MD',
(e) => e.type_data == 'MD' && !e.selected,
);
props.onChooseAllMD(newList);
if (e.id == 10) return {...e, selected: true, disable: false};
......@@ -49,9 +48,9 @@ const FeePro = (props) => {
const newList = listItem.map((e) => {
if (e.type_data != 'TB') return e;
else {
if (e.selected == false) {
if (selected.selected == false) {
const newList = listItem.filter(
(e) => e.id != 10 && e.type_data == 'TB',
(e) => e.type_data == 'TB' && !e.selected,
);
props.onChooseAllTB(newList);
if (e.id == 11) return {...e, selected: true, disable: false};
......@@ -63,6 +62,7 @@ const FeePro = (props) => {
}
}
});
setListItem(newList);
} else {
const newList = listItem.map((e) => {
......
......@@ -10,7 +10,7 @@ const Footer = (props) => {
<Text style={styles.txtTitle}>Bn có th m tài khon th </Text>
<TouchableOpacity
onPress={() =>
Linking.openURL('https://reactnative.dev/docs/linking')
Linking.openURL('https://mdemo.cqg.com/cqg/desktop/demorequest')
}>
<Text style={styles.txtLink}>Ti đây.</Text>
</TouchableOpacity>
......@@ -22,9 +22,12 @@ const Footer = (props) => {
alignItems: 'center',
marginVertical: 10,
}}>
<View style={styles.btnSend}>
<TouchableOpacity
onPress={props.onClick}
onClick
style={styles.btnSend}>
<Text style={styles.txtSend}>M tài khon</Text>
</View>
</TouchableOpacity>
</View>
</View>
);
......
import React, {useState, useEffect} from 'react';
import {View, Text, StyleSheet, ScrollView} from 'react-native';
import {View, Text, StyleSheet, ScrollView, Alert} from 'react-native';
import HeaderBack from '../../../components/Header/HeaderBack';
import CheckBox from '@react-native-community/checkbox';
import R from '../../../assets/R';
......@@ -8,7 +8,10 @@ import ContainerTop from './ContainerTop';
import WrapNomarl from './WrapNomarl';
import Footer from './Footer';
import FeePro from './FeePro';
import {getListPacketCQG} from '../../../apis/Functions/packetCQG';
import {getListPacketCQG, openCQG} from '../../../apis/Functions/packetCQG';
import {connect} from 'react-redux';
import {showLoading, hideLoading} from '../../../actions/loadingAction';
import {useNavigation} from '@react-navigation/native';
const Item = () => {
const [isSelected, setSelection] = useState(false);
......@@ -41,14 +44,35 @@ const PacketCQG = (props) => {
const [feeNonPro, setFeeNonPro] = useState({data: [], title: ''});
const [feePro, setFeePro] = useState({data: [], title: ''});
const navigate = useNavigation();
const [price, setPrice] = useState(0);
useEffect(() => {
onChangeMoney();
}, [listData]);
const onClick = async () => {
const newList = listData.map((e) => e.id);
console.log(newList);
props.showLoading();
const res = await openCQG({packages: newList});
props.hideLoading();
console.log(res);
if (res.data.code == 200) {
setTimeout(() => {
Alert.alert('Thông báo!', res.data.message);
navigate.goBack();
}, 500);
} else {
setTimeout(() => {
Alert.alert('Thông báo!', res.data.message);
}, 500);
}
};
const onChangeMoney = () => {
setTimeout(() => {
console.log('Listdata update', listData);
let totalMoney = 0;
listData.map((e) => {
totalMoney += e.price_package.price;
......@@ -62,7 +86,6 @@ const PacketCQG = (props) => {
}, []);
const onChoosePacket = (item) => {
console.log('Add', item);
if (listData.length != 0) setListData(listData.concat(item));
else setListData([].concat(item));
onChangeMoney();
......@@ -92,11 +115,9 @@ const PacketCQG = (props) => {
onChangeMoney();
};
const onRemovePacket = (item) => {
console.log('Truoc remove', listData);
const newList = listData.filter((e) => e.id != item.id);
setListData(newList);
console.log('List sau remove', newList);
onChangeMoney();
};
const getData = async () => {
......@@ -145,7 +166,7 @@ const PacketCQG = (props) => {
data={feePro}
/>
<Footer price={price} />
<Footer onClick={onClick} price={price} />
<View style={{height: 20}} />
</View>
......@@ -207,4 +228,12 @@ const styles = StyleSheet.create({
},
});
export default PacketCQG;
const mapStateToProps = (state) => {
return {
loadding: state.loadingReducer,
};
};
export default connect(mapStateToProps, {
showLoading,
hideLoading,
})(PacketCQG);
......@@ -6,3 +6,8 @@ export const getListPacketCQG = async (body) =>
GetData(url.urlGetListPacketCQG, body)
.then((res) => res)
.catch((err) => err);
export const openCQG = async (body) =>
PostData(url.urlOpenCQG, body)
.then((res) => res)
.catch((err) => err);
......@@ -32,4 +32,5 @@ export default {
urlWalletDeposit: root + 'api/v1/customers/request-deposit',
urlGetListPacketCQG: root + 'api/v1/customers/get-list-fee-package',
urlOpenCQG: root + 'api/v1/customers/register-open-cqg',
};
......@@ -10,6 +10,11 @@ const FirebaseNotification = (props) => {
messaging().setBackgroundMessageHandler(async (remoteMessage) => {
console.log('Message handled in the background!', remoteMessage);
});
messaging().onNotificationOpenedApp(async (remoteMessage) => {
console.log('Message handled in the background!', remoteMessage);
});
useEffect(() => {
requestUserPermission();
const unsubscribe = messaging().onMessage(async (remoteMessage) => {
......
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