@traund/orquezta-widget-calculator 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.js CHANGED
@@ -23,16 +23,13 @@ import {CircleFlag as $5OpyM$CircleFlag} from "react-circle-flags";
23
23
  import $5OpyM$cryptojs from "crypto-js";
24
24
  import $5OpyM$materialuicoreChip from "@material-ui/core/Chip";
25
25
  import $5OpyM$moment from "moment";
26
+ import "aws-sdk";
26
27
  import {extend as $5OpyM$extend} from "dayjs";
27
28
  import * as $5OpyM$dayjsbusinesstime from "dayjs-business-time";
28
29
  import "dayjs/plugin/utc";
29
30
  import $5OpyM$materialuicoreMenuItem from "@material-ui/core/MenuItem";
30
31
 
31
32
 
32
- function $parcel$interopDefault(a) {
33
- return a && a.__esModule ? a.default : a;
34
- }
35
-
36
33
 
37
34
 
38
35
 
@@ -997,7 +994,7 @@ const $9ea2f2608ea58c4b$var$loadFirebaseDB = (testMode = 'production', externalC
997
994
  try {
998
995
  let firebaseConfig;
999
996
  if (externalConfig && externalConfig.provider) firebaseConfig = externalConfig.provider;
1000
- else firebaseConfig = (0, $c8082d1fff4ed783$export$7dfd6b97707a3d55)[testMode].FIREBASE;
997
+ else return console.error('No Firebase configuration provided');
1001
998
  if ((0, $5OpyM$firebaseapp).apps.length === 0) (0, $5OpyM$firebaseapp).initializeApp(firebaseConfig);
1002
999
  } catch (error) {
1003
1000
  if (!/already exist/.test(error.message)) console.error('Firebase initialization error', error.stack);
@@ -2325,38 +2322,41 @@ const $49f826b4fff6422b$var$Timer = (props)=>{
2325
2322
  var $49f826b4fff6422b$export$2e2bcd8739ae039 = $49f826b4fff6422b$var$Timer;
2326
2323
 
2327
2324
 
2328
- var $6f87a65d2d16a22f$exports = {};
2329
2325
 
2330
2326
  class $6f87a65d2d16a22f$var$EndPoints {
2331
- constructor(testMode = 'production'){
2327
+ constructor(testMode = 'production', externalConfig = null){
2332
2328
  this._testMode = testMode;
2333
- this.baseUrl = (0, $c8082d1fff4ed783$export$7dfd6b97707a3d55)[this._testMode].URL;
2329
+ this.baseUrl = externalConfig && externalConfig.backendUrl;
2334
2330
  this.path_managment_operations = `${this.baseUrl}/handle-operations`;
2335
2331
  }
2336
- get HEADERS() {
2337
- return this.baseUrl = (0, $c8082d1fff4ed783$export$7dfd6b97707a3d55)[this._testMode].HEADERS;
2338
- }
2339
- get COUPON() {
2332
+ get CALLBACK() {
2340
2333
  return {
2341
- validate: `${this.path_managment_operations}/coupon/v1/validate`
2334
+ landing_transfer: (baseUrl, locale)=>`${baseUrl}/${locale}/send`,
2335
+ landing_receive: (baseUrl, locale)=>`${baseUrl}/${locale}/receive`,
2336
+ landing_wallet: (baseUrl, locale)=>`${baseUrl}/${locale}/wallet`,
2337
+ referral_transfer: (baseUrl, locale, storeId)=>`${baseUrl}/${locale}/login?referral=operation&type=transfer&reference=${storeId}`,
2338
+ referral_receive: (baseUrl, locale, storeId)=>`${baseUrl}/${locale}/login?referral=operation&type=pay&reference=${storeId}`,
2339
+ referral_recharge: (baseUrl, locale, storeId)=>`${baseUrl}/${locale}/login?referral=operation&type=recharge&reference=${storeId}`
2342
2340
  };
2343
2341
  }
2344
- get TRANSACTION() {
2342
+ get OPERATIONS() {
2345
2343
  return {
2346
- calculate: `${this.path_managment_operations}/transaction/v1/calculate`,
2347
- calculate_v2: (storeId, source)=>`${this.path_managment_operations}/calculate/v1/update/${storeId}/${source}`
2344
+ calculate: (storeId, source)=>`${this.path_managment_operations}/calculate/v1/update/${storeId}/${source}`,
2345
+ validateCoupon: `${this.path_managment_operations}/coupon/v1/validate`
2348
2346
  };
2349
2347
  }
2350
- get CALCULATOR() {
2348
+ get EXCHANGE() {
2351
2349
  return {
2352
- exchangeRate: `https://api.exchangerate.host/convert?from=USD&to=`,
2353
- exchangeRatev2: 'https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies/usd.json',
2354
- exchangeBlue: `https://api.bluelytics.com.ar/v2/latest`,
2355
- convert: `https://api.exchangerate.host/convert?from=USD&to=`
2350
+ getRate: (currencyFrom, currencyTo)=>`https://api.exchangerate.host/convert?from=${currencyFrom}&to=${currencyTo}`,
2351
+ getRate_bk_1: (currencyFrom, currencyTo)=>`https://api-us.exchangerate.host/convert?from=${currencyFrom}&to=${currencyTo}`,
2352
+ getRate_bk_2: (currencyFrom, currencyTo)=>`https://api-eu.exchangerate.host/convert?from=${currencyFrom}&to=${currencyTo}`,
2353
+ getRate_v2: (currencyFrom)=>`https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies/${currencyFrom.toLowerCase()}.json`,
2354
+ getRate_v3: (currencyFrom, currencyTo)=>`https://cdnhlp-staging.traund.xyz/rates/v1/${currencyFrom}/${currencyTo}`,
2355
+ getUSDBlueRate: `https://api.bluelytics.com.ar/v2/latest`
2356
2356
  };
2357
2357
  }
2358
2358
  }
2359
- $6f87a65d2d16a22f$exports = $6f87a65d2d16a22f$var$EndPoints;
2359
+ var $6f87a65d2d16a22f$export$2e2bcd8739ae039 = $6f87a65d2d16a22f$var$EndPoints;
2360
2360
 
2361
2361
 
2362
2362
 
@@ -2538,7 +2538,7 @@ class $e8a8a43586c972c2$var$Calculator extends (0, $5OpyM$Component) {
2538
2538
  taxSender: 0.00,
2539
2539
  taxReceiver: 0.00
2540
2540
  };
2541
- ENDPOINTS = new (0, (/*@__PURE__*/$parcel$interopDefault($6f87a65d2d16a22f$exports)))(this.state.testMode);
2541
+ ENDPOINTS = new (0, $6f87a65d2d16a22f$export$2e2bcd8739ae039)(this.state.testMode, this.state.config);
2542
2542
  constructor(props){
2543
2543
  super(props);
2544
2544
  this.unsubscribe = [];
@@ -2701,14 +2701,14 @@ class $e8a8a43586c972c2$var$Calculator extends (0, $5OpyM$Component) {
2701
2701
  _convertAmount = async (currency)=>{
2702
2702
  try {
2703
2703
  if (currency == "ARS") {
2704
- const { data: data } = await (0, $5OpyM$axios).get(`${this.ENDPOINTS.CALCULATOR.exchangeBlue}`);
2704
+ const { data: data } = await (0, $5OpyM$axios).get(`${this.ENDPOINTS.EXCHANGE.getUSDBlueRate}`);
2705
2705
  let blueRate = await JSON.parse(JSON.stringify(data));
2706
2706
  blueRate = {
2707
2707
  result: blueRate.blue.value_sell
2708
2708
  };
2709
2709
  return blueRate;
2710
2710
  } else {
2711
- const { data: data } = await (0, $5OpyM$axios).get(`${this.ENDPOINTS.CALCULATOR.exchangeRatev2}`);
2711
+ const { data: data } = await (0, $5OpyM$axios).get(`${this.ENDPOINTS.EXCHANGE.getRate_v2(currency)}`);
2712
2712
  return {
2713
2713
  result: parseFloat(data['usd'][currency.toLowerCase()].toFixed(2))
2714
2714
  };
@@ -3034,7 +3034,7 @@ class $e8a8a43586c972c2$var$Calculator extends (0, $5OpyM$Component) {
3034
3034
  }
3035
3035
  };
3036
3036
  if (source == "initial" || source == "end") {
3037
- const url = this.ENDPOINTS.TRANSACTION.calculate_v2(this.state.storeId || sessionStorage.getItem('storeId'), "from");
3037
+ const url = this.ENDPOINTS.OPERATIONS.calculate(this.state.storeId || sessionStorage.getItem('storeId'), "from");
3038
3038
  const res = await (0, $5OpyM$axios).post(url, model, {
3039
3039
  headers: {
3040
3040
  "x-api-access-sig": (0, $be7f9e5745d99d09$export$3db7bf9691bf4b62)('POST', url, model, this.state.reference)
@@ -3075,7 +3075,7 @@ class $e8a8a43586c972c2$var$Calculator extends (0, $5OpyM$Component) {
3075
3075
  if (source == "to") this.setState({
3076
3076
  sendValue: ""
3077
3077
  });
3078
- const url = this.ENDPOINTS.TRANSACTION.calculate_v2(this.state.storeId, source);
3078
+ const url = this.ENDPOINTS.OPERATIONS.calculate(this.state.storeId, source);
3079
3079
  const res = await (0, $5OpyM$axios).post(url, model, {
3080
3080
  headers: {
3081
3081
  "x-api-access-sig": (0, $be7f9e5745d99d09$export$3db7bf9691bf4b62)('POST', url, model, this.state.reference)
@@ -3262,7 +3262,7 @@ class $e8a8a43586c972c2$var$Calculator extends (0, $5OpyM$Component) {
3262
3262
  plus: 0
3263
3263
  });
3264
3264
  //if (db) db.clearPersistence();
3265
- const firebase = await (0, $9ea2f2608ea58c4b$export$2e2bcd8739ae039)(this.state.testMode);
3265
+ const firebase = await (0, $9ea2f2608ea58c4b$export$2e2bcd8739ae039)(this.state.testMode, this.state.config);
3266
3266
  const db = firebase.firestore();
3267
3267
  if (this.state.couponRedeemed && this.state.couponValue != "") try {
3268
3268
  const userFS = await db.collection("transactions").doc(this.state.storeId).update({
@@ -3310,7 +3310,7 @@ class $e8a8a43586c972c2$var$Calculator extends (0, $5OpyM$Component) {
3310
3310
  return valid;
3311
3311
  };
3312
3312
  validateCoupon = async (cupon)=>{
3313
- const url = `${this.ENDPOINTS.COUPON.validate}/${cupon}`;
3313
+ const url = `${this.ENDPOINTS.OPERATIONS.validateCoupon}/${cupon}`;
3314
3314
  try {
3315
3315
  const response = await (0, $5OpyM$axios).get(url, {
3316
3316
  headers: {
@@ -4676,45 +4676,6 @@ var $e8a8a43586c972c2$export$2e2bcd8739ae039 = $e8a8a43586c972c2$var$Calculator;
4676
4676
 
4677
4677
 
4678
4678
 
4679
- class $c2624340fd589f7f$var$EndPoints {
4680
- constructor(testMode = 'production'){
4681
- this._testMode = testMode;
4682
- this.baseUrl = (0, $c8082d1fff4ed783$export$7dfd6b97707a3d55)[this._testMode].URL;
4683
- this.path_managment_operations = `${this.baseUrl}/handle-operations`;
4684
- }
4685
- get HEADERS() {
4686
- return this.baseUrl = (0, $c8082d1fff4ed783$export$7dfd6b97707a3d55)[this._testMode].HEADERS;
4687
- }
4688
- get CALLBACK() {
4689
- return {
4690
- landing_transfer: (baseUrl, locale)=>`${baseUrl}/${locale}/send`,
4691
- landing_receive: (baseUrl, locale)=>`${baseUrl}/${locale}/receive`,
4692
- landing_wallet: (baseUrl, locale)=>`${baseUrl}/${locale}/wallet`,
4693
- referral_transfer: (baseUrl, locale, storeId)=>`${baseUrl}/${locale}/login?referral=operation&type=transfer&reference=${storeId}`,
4694
- referral_receive: (baseUrl, locale, storeId)=>`${baseUrl}/${locale}/login?referral=operation&type=pay&reference=${storeId}`,
4695
- referral_recharge: (baseUrl, locale, storeId)=>`${baseUrl}/${locale}/login?referral=operation&type=recharge&reference=${storeId}`
4696
- };
4697
- }
4698
- get OPERATIONS() {
4699
- return {
4700
- calculate: (storeId, source)=>`${this.path_managment_operations}/calculate/v1/update/${storeId}/${source}`,
4701
- validateCoupon: `${this.path_managment_operations}/coupon/v1/validate`
4702
- };
4703
- }
4704
- get EXCHANGE() {
4705
- return {
4706
- getRate: (currencyFrom, currencyTo)=>`https://api.exchangerate.host/convert?from=${currencyFrom}&to=${currencyTo}`,
4707
- getRate_bk_1: (currencyFrom, currencyTo)=>`https://api-us.exchangerate.host/convert?from=${currencyFrom}&to=${currencyTo}`,
4708
- getRate_bk_2: (currencyFrom, currencyTo)=>`https://api-eu.exchangerate.host/convert?from=${currencyFrom}&to=${currencyTo}`,
4709
- getRate_v2: (currencyFrom)=>`https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies/${currencyFrom.toLowerCase()}.json`,
4710
- getRate_v3: (currencyFrom, currencyTo)=>`https://cdnhlp-staging.traund.xyz/rates/v1/${currencyFrom}/${currencyTo}`,
4711
- getUSDBlueRate: `https://api.bluelytics.com.ar/v2/latest`
4712
- };
4713
- }
4714
- }
4715
- var $c2624340fd589f7f$export$2e2bcd8739ae039 = $c2624340fd589f7f$var$EndPoints;
4716
-
4717
-
4718
4679
  const $3217af864b2b4eed$export$1b5eb083c754a86b = Object.freeze({
4719
4680
  COUNTRY: "country",
4720
4681
  WALLET: "wallet",
@@ -4844,8 +4805,8 @@ var $ee6357194386215f$export$2e2bcd8739ae039 = $ee6357194386215f$var$TransferUse
4844
4805
 
4845
4806
 
4846
4807
  class $9ac168cb9a22c932$var$RateHelper {
4847
- constructor(testMode = 'production'){
4848
- this.endpoints = new (0, $c2624340fd589f7f$export$2e2bcd8739ae039)(testMode);
4808
+ constructor(testMode = 'production', externalConfig = null){
4809
+ this.endpoints = new (0, $6f87a65d2d16a22f$export$2e2bcd8739ae039)(testMode, externalConfig.backendUrl);
4849
4810
  }
4850
4811
  async getExchangeRate(currencyFrom, currencyTo) {
4851
4812
  try {
@@ -5444,9 +5405,10 @@ function $6bf8ac1124443ad4$export$354ffc3468f9d23e(calculateType, day) {
5444
5405
 
5445
5406
 
5446
5407
 
5408
+
5447
5409
  class $aeba0491dead64b0$var$OperationsHelper {
5448
- constructor(testMode = 'production', secretKey = null){
5449
- this.endpoints = new (0, $c2624340fd589f7f$export$2e2bcd8739ae039)(testMode);
5410
+ constructor(testMode = 'production', secretKey = null, config = null){
5411
+ this.endpoints = new (0, $6f87a65d2d16a22f$export$2e2bcd8739ae039)(testMode, config.backendUrl);
5450
5412
  this.reference = secretKey;
5451
5413
  this.FEES = {
5452
5414
  "ach": {
@@ -7057,7 +7019,7 @@ function $c4ee7a827d19e0d2$var$Simulator(props) {
7057
7019
  */ const { locale: locale, pathname: pathname, locales: locales } = props;
7058
7020
  const content = locale === "es" ? (0, $af3f68c5ac2f1e3c$export$2e2bcd8739ae039) : (0, $18d8bd1c5cecbd36$export$2e2bcd8739ae039);
7059
7021
  const classes = $c4ee7a827d19e0d2$var$useStyles();
7060
- const __ENDPOINTS = new (0, $c2624340fd589f7f$export$2e2bcd8739ae039)(props.testMode);
7022
+ const __ENDPOINTS = new (0, $6f87a65d2d16a22f$export$2e2bcd8739ae039)(props.testMode, props.config?.backendUrl);
7061
7023
  const __calculateHelper = new (0, $006ea4d50140482f$export$2e2bcd8739ae039)(props.testMode);
7062
7024
  const __operationsHelper = new (0, $aeba0491dead64b0$export$2e2bcd8739ae039)(props.testMode, props.reference);
7063
7025
  const __firebase = (0, $9ea2f2608ea58c4b$export$2e2bcd8739ae039)(props.testMode, props.config);