@traund/orquezta-widget-calculator 1.0.0 → 1.0.2
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/index.js +20 -50
- package/dist/index.js.map +1 -1
- package/dist/module.js +20 -50
- package/dist/module.js.map +1 -1
- package/package.json +1 -1
- package/src/calculatorV2.js +3 -5
- package/src/core/backend-settings.js +3 -36
- package/src/core/endpoints.js +4 -4
- package/src/firebase.config.js +9 -2
- package/src/index.js +2 -0
- package/src/simulator.js +1 -1
- package/src/utils/operationsHelper.js +0 -1
package/package.json
CHANGED
package/src/calculatorV2.js
CHANGED
|
@@ -26,6 +26,7 @@ import { applyTaxDiscount } from "./helpers/taxDiscount";
|
|
|
26
26
|
import { getSignatureHeader } from "../src/core/signature";
|
|
27
27
|
class Calculator extends Component {
|
|
28
28
|
state = {
|
|
29
|
+
config: this.props.config ,
|
|
29
30
|
testMode: this.props.testMode,
|
|
30
31
|
sendValue: 100.0,
|
|
31
32
|
sendValueUSD: 100.0,
|
|
@@ -83,7 +84,7 @@ class Calculator extends Component {
|
|
|
83
84
|
taxReceiver: 0.00
|
|
84
85
|
};
|
|
85
86
|
|
|
86
|
-
ENDPOINTS = new Endpoints(this.state.testMode);
|
|
87
|
+
ENDPOINTS = new Endpoints(this.state.testMode,this.state.config);
|
|
87
88
|
|
|
88
89
|
constructor(props) {
|
|
89
90
|
super(props);
|
|
@@ -92,7 +93,7 @@ class Calculator extends Component {
|
|
|
92
93
|
|
|
93
94
|
async componentDidMount() {
|
|
94
95
|
//if (db) db.clearPersistence();
|
|
95
|
-
const firebase = await loadFirebaseDB(this.state.testMode);
|
|
96
|
+
const firebase = await loadFirebaseDB(this.state.testMode,this.state.config);
|
|
96
97
|
|
|
97
98
|
const db = firebase.firestore();
|
|
98
99
|
|
|
@@ -726,7 +727,6 @@ class Calculator extends Component {
|
|
|
726
727
|
model,
|
|
727
728
|
{
|
|
728
729
|
headers: {
|
|
729
|
-
...this.ENDPOINTS.HEADERS,
|
|
730
730
|
"x-api-access-sig": getSignatureHeader('POST', url, model,this.state.reference)
|
|
731
731
|
},
|
|
732
732
|
}
|
|
@@ -786,7 +786,6 @@ class Calculator extends Component {
|
|
|
786
786
|
model,
|
|
787
787
|
{
|
|
788
788
|
headers: {
|
|
789
|
-
...this.ENDPOINTS.HEADERS,
|
|
790
789
|
"x-api-access-sig": getSignatureHeader('POST', url, model,this.state.reference)
|
|
791
790
|
},
|
|
792
791
|
}
|
|
@@ -1068,7 +1067,6 @@ class Calculator extends Component {
|
|
|
1068
1067
|
url,
|
|
1069
1068
|
{
|
|
1070
1069
|
headers: {
|
|
1071
|
-
...this.ENDPOINTS.HEADERS,
|
|
1072
1070
|
"x-api-access-sig": getSignatureHeader('GET', url, null,this.state.reference)
|
|
1073
1071
|
},
|
|
1074
1072
|
}
|
|
@@ -1,47 +1,14 @@
|
|
|
1
1
|
export const BACKEND_SETTINGS = {
|
|
2
2
|
"staging": {
|
|
3
3
|
URL: process.env.NEXT_PUBLIC_STAGING_TRAUND_BACKEND_URL,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
},
|
|
7
|
-
FIREBASE: {
|
|
8
|
-
apiKey: process.env.NEXT_PUBLIC_STAGING_FIREBASE_API_KEY,
|
|
9
|
-
authDomain: process.env.NEXT_PUBLIC_STAGING_FIREBASE_AUTH_DOMAIN,
|
|
10
|
-
projectId: process.env.NEXT_PUBLIC_STAGING_FIREBASE_PROJECT_ID,
|
|
11
|
-
storageBucket: process.env.NEXT_PUBLIC_STAGING_FIREBASE_STORAGE_BUCKET,
|
|
12
|
-
messagingSenderId: process.env.NEXT_PUBLIC_STAGING_FIREBASE_MESSAGING_SENDER_ID,
|
|
13
|
-
appId: process.env.NEXT_PUBLIC_STAGING_FIREBASE_APP_ID,
|
|
14
|
-
measurementId: process.env.NEXT_PUBLIC_STAGING_FIREBASE_MEASUREMENT_ID,
|
|
15
|
-
}
|
|
4
|
+
|
|
16
5
|
},
|
|
17
6
|
"beta": {
|
|
18
7
|
URL: process.env.NEXT_PUBLIC_BETA_TRAUND_BACKEND_URL,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
},
|
|
22
|
-
FIREBASE: {
|
|
23
|
-
apiKey: process.env.NEXT_PUBLIC_BETA_FIREBASE_API_KEY,
|
|
24
|
-
authDomain: process.env.NEXT_PUBLIC_BETA_FIREBASE_AUTH_DOMAIN,
|
|
25
|
-
projectId: process.env.NEXT_PUBLIC_BETA_FIREBASE_PROJECT_ID,
|
|
26
|
-
storageBucket: process.env.NEXT_PUBLIC_BETA_FIREBASE_STORAGE_BUCKET,
|
|
27
|
-
messagingSenderId: process.env.NEXT_PUBLIC_BETA_FIREBASE_MESSAGING_SENDER_ID,
|
|
28
|
-
appId: process.env.NEXT_PUBLIC_BETA_FIREBASE_APP_ID,
|
|
29
|
-
measurementId: process.env.NEXT_PUBLIC_BETA_FIREBASE_MEASUREMENT_ID,
|
|
30
|
-
}
|
|
8
|
+
|
|
31
9
|
},
|
|
32
10
|
"production": {
|
|
33
11
|
URL: process.env.NEXT_PUBLIC_PROD_TRAUND_BACKEND_URL,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
FIREBASE: {
|
|
38
|
-
apiKey: process.env.NEXT_PUBLIC_PROD_FIREBASE_API_KEY,
|
|
39
|
-
authDomain: process.env.NEXT_PUBLIC_PROD_FIREBASE_AUTH_DOMAIN,
|
|
40
|
-
projectId: process.env.NEXT_PUBLIC_PROD_FIREBASE_PROJECT_ID,
|
|
41
|
-
storageBucket: process.env.NEXT_PUBLIC_PROD_FIREBASE_STORAGE_BUCKET,
|
|
42
|
-
messagingSenderId: process.env.NEXT_PUBLIC_PROD_FIREBASE_MESSAGING_SENDER_ID,
|
|
43
|
-
appId: process.env.NEXT_PUBLIC_PROD_FIREBASE_APP_ID,
|
|
44
|
-
measurementId: process.env.NEXT_PUBLIC_PROD_FIREBASE_MEASUREMENT_ID,
|
|
45
|
-
}
|
|
12
|
+
|
|
46
13
|
}
|
|
47
14
|
}
|
package/src/core/endpoints.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { BACKEND_SETTINGS } from "./backend-settings";
|
|
2
2
|
class EndPoints {
|
|
3
|
-
constructor(testMode = 'production') {
|
|
3
|
+
constructor(testMode = 'production', externalConfig = null) {
|
|
4
4
|
this._testMode = testMode;
|
|
5
|
-
this.baseUrl =
|
|
5
|
+
this.baseUrl = externalConfig && externalConfig.url;
|
|
6
6
|
this.path_managment_operations = `${this.baseUrl}/handle-operations`;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
get HEADERS() {
|
|
9
|
+
/*get HEADERS() {
|
|
10
10
|
return this.baseUrl = BACKEND_SETTINGS[this._testMode].HEADERS;
|
|
11
|
-
}
|
|
11
|
+
};*/
|
|
12
12
|
|
|
13
13
|
get COUPON() {
|
|
14
14
|
return {
|
package/src/firebase.config.js
CHANGED
|
@@ -2,9 +2,16 @@ import firebase from "firebase/app";
|
|
|
2
2
|
import 'firebase/firestore';
|
|
3
3
|
import { BACKEND_SETTINGS } from "./core/backend-settings";
|
|
4
4
|
|
|
5
|
-
const loadFirebaseDB = (testMode = 'production') => {
|
|
5
|
+
const loadFirebaseDB = (testMode = 'production', externalConfig = null) => {
|
|
6
6
|
try {
|
|
7
|
-
|
|
7
|
+
let firebaseConfig;
|
|
8
|
+
|
|
9
|
+
if (externalConfig && externalConfig.provider) {
|
|
10
|
+
firebaseConfig = externalConfig.provider;
|
|
11
|
+
} else {
|
|
12
|
+
return console.error('No Firebase configuration provided');
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
if (firebase.apps.length === 0) {
|
|
9
16
|
firebase.initializeApp(firebaseConfig);
|
|
10
17
|
}
|
package/src/index.js
CHANGED
|
@@ -10,6 +10,7 @@ function WrappedSimulator(props) {
|
|
|
10
10
|
onlyView={props.onlyView ?? false}
|
|
11
11
|
initialCountryTo={props.initialCountryTo ?? "PE-USD"}
|
|
12
12
|
reference={props.reference || ""}
|
|
13
|
+
config={props.config}
|
|
13
14
|
/>;
|
|
14
15
|
}
|
|
15
16
|
|
|
@@ -22,6 +23,7 @@ function WrappedCalculator(props) {
|
|
|
22
23
|
couponCode={props.couponCode || ""}
|
|
23
24
|
onlySimulation={props.onlySimulation ?? false}
|
|
24
25
|
reference={props.reference || ""}
|
|
26
|
+
config={props.config}
|
|
25
27
|
/>
|
|
26
28
|
);
|
|
27
29
|
}
|
package/src/simulator.js
CHANGED
|
@@ -37,7 +37,7 @@ function Simulator(props) {
|
|
|
37
37
|
const __calculateHelper = new CalculateHelper(props.testMode);
|
|
38
38
|
const __operationsHelper = new OperationsHelper(props.testMode, props.reference);
|
|
39
39
|
|
|
40
|
-
const __firebase = loadFirebaseDB(props.testMode);
|
|
40
|
+
const __firebase = loadFirebaseDB(props.testMode, props.config);
|
|
41
41
|
|
|
42
42
|
const [simulatorMode, setSimulatorMode] = useState(SimulatorMode.SEND);
|
|
43
43
|
const [suscribedGlobalOptions, setSuscribedGlobalOptions] = useState(false);
|