@traund/orquezta-widget-calculator 1.1.2 → 1.1.4

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/src/calculator.js CHANGED
@@ -28,2131 +28,2131 @@ import FlagsHelpers from "./helpers/flagsHelpers";
28
28
  import { applyTaxDiscount } from "./helpers/taxDiscount";
29
29
  import { getSignatureHeader } from "./core/signature";
30
30
  class Calculator extends Component {
31
- state = {
32
- config: this.props.config ,
33
- testMode: this.props.testMode,
34
- sendValue: 100.0,
35
- sendValueUSD: 100.0,
36
- convertValue: 100.0,
37
- convertValueCrypto: 100.0,
38
- receivedValue: 0.0,
39
- fees: {},
40
- fromExchangeRate: 0.00,
41
- couponValue: this.props.onlySimulation ? "" : this.props.couponCode,
42
- fromCountryValue: "US",
43
- fromCurrencyValue: "USD",
44
- toCountryValue: "PE-USD",
45
- toCurrencyValue: "USD",
46
- isLoading: false,
47
- storeId: null,
48
- email: "",
49
- hasError: false,
50
- hasAmountError: false,
51
- hasEmailError: false,
52
- hasValidCoupon: true,
53
- isValid: true,
54
- isSuccess: false,
55
- showCallToAction: false,
56
- countryError: {
57
- hasErrors: false,
58
- value: "",
59
- },
60
- calculator: {},
61
- minFromValue: 20,
62
- maxFromValue: 5000,
63
- minToValue: 80,
64
- maxToValue: 20000,
65
- plus: 0,
66
- couponRedeemed: false,
67
- typingTimeout: 0,
68
- typingTimeoutCoupon: 0,
69
- calculating: true,
70
- banks: false,
71
- loadingTo: true,
72
- loadingFrom: false,
73
- recalculate: false,
74
- paymentMethods: [],
75
- exchangeRateLabel: "x",
76
- exchangeRate: 0.0,
77
- isUsdt: false,
78
- networkFee: 0.0,
79
- paypalFee: 0.0,
80
- traundFee: 0.0,
81
- totalFees: 0.0,
82
- showTotalFees: false,
83
- isCountryFromPayPal: false,
84
- onlySimulation: this.props.onlySimulation,
85
- reference:this.props.reference,
86
- secretKey: this.props.secretKey,
87
- taxSender: 0.00,
88
- taxReceiver: 0.00
89
- };
90
-
91
- ENDPOINTS = new Endpoints(this.state.testMode,this.state.config);
92
-
93
- constructor(props) {
94
- super(props);
95
- this.unsubscribe = [];
31
+ state = {
32
+ config: this.props.config,
33
+ testMode: this.props.testMode,
34
+ sendValue: 100.0,
35
+ sendValueUSD: 100.0,
36
+ convertValue: 100.0,
37
+ convertValueCrypto: 100.0,
38
+ receivedValue: 0.0,
39
+ fees: {},
40
+ fromExchangeRate: 0.00,
41
+ couponValue: this.props.onlySimulation ? "" : this.props.couponCode,
42
+ fromCountryValue: "US",
43
+ fromCurrencyValue: "USD",
44
+ toCountryValue: "PE-USD",
45
+ toCurrencyValue: "USD",
46
+ isLoading: false,
47
+ storeId: null,
48
+ email: "",
49
+ hasError: false,
50
+ hasAmountError: false,
51
+ hasEmailError: false,
52
+ hasValidCoupon: true,
53
+ isValid: true,
54
+ isSuccess: false,
55
+ showCallToAction: false,
56
+ countryError: {
57
+ hasErrors: false,
58
+ value: "",
59
+ },
60
+ calculator: {},
61
+ minFromValue: 20,
62
+ maxFromValue: 5000,
63
+ minToValue: 80,
64
+ maxToValue: 20000,
65
+ plus: 0,
66
+ couponRedeemed: false,
67
+ typingTimeout: 0,
68
+ typingTimeoutCoupon: 0,
69
+ calculating: true,
70
+ banks: false,
71
+ loadingTo: true,
72
+ loadingFrom: false,
73
+ recalculate: false,
74
+ paymentMethods: [],
75
+ exchangeRateLabel: "x",
76
+ exchangeRate: 0.0,
77
+ isUsdt: false,
78
+ networkFee: 0.0,
79
+ paypalFee: 0.0,
80
+ traundFee: 0.0,
81
+ totalFees: 0.0,
82
+ showTotalFees: false,
83
+ isCountryFromPayPal: false,
84
+ onlySimulation: this.props.onlySimulation,
85
+ reference: this.props.reference,
86
+ secretKey: this.props.secretKey,
87
+ taxSender: 0.00,
88
+ taxReceiver: 0.00
89
+ };
90
+
91
+ ENDPOINTS = new Endpoints(this.state.testMode, this.state.config);
92
+
93
+ constructor(props) {
94
+ super(props);
95
+ this.unsubscribe = [];
96
+ }
97
+
98
+ async componentDidMount() {
99
+ //if (db) db.clearPersistence();
100
+ const firebase = await loadFirebaseDB(this.state.testMode, this.state.config);
101
+ const db = firebase.firestore();
102
+
103
+ this.subscribeCalculatorConfig(db);
104
+
105
+ if (
106
+ !sessionStorage.getItem(`storeId`) ||
107
+ sessionStorage.getItem(`storeId`) == null ||
108
+ sessionStorage.getItem(`storeId`) == undefined ||
109
+ sessionStorage.getItem(`storeId`) == ""
110
+ ) {
111
+ await this.createTransaction(db);
112
+ } else {
113
+ await this.setState({ storeId: sessionStorage.getItem(`storeId`) });
96
114
  }
97
115
 
98
- async componentDidMount() {
99
- //if (db) db.clearPersistence();
100
- const firebase = await loadFirebaseDB(this.state.testMode, this.state.config);
101
- const db = firebase.firestore();
116
+ this.calculate("initial");
102
117
 
103
- this.subscribeCalculatorConfig(db);
118
+ this.subscribeTransaction(db);
104
119
 
105
- if (
106
- !sessionStorage.getItem(`storeId`) ||
107
- sessionStorage.getItem(`storeId`) == null ||
108
- sessionStorage.getItem(`storeId`) == undefined ||
109
- sessionStorage.getItem(`storeId`) == ""
110
- ) {
111
- await this.createTransaction(db);
112
- } else {
113
- await this.setState({ storeId: sessionStorage.getItem(`storeId`) });
114
- }
120
+ // this.unloadListener(db);
121
+ }
115
122
 
116
- this.calculate("initial");
123
+ componentWillUnmount() {
124
+ this.unsubscribe && this.unsubscribe.map((unsubscribe) => unsubscribe());
125
+ clearTimeout(this.state.recalc);
126
+ }
117
127
 
118
- this.subscribeTransaction(db);
128
+ setIdForPaymentMethods(payments) {
129
+ if (payments) {
130
+ let paymentsWithId = payments.map((el) => {
131
+ return {
132
+ ...el,
133
+ id: el.name.replace(/ /g, "").toLowerCase(),
134
+ };
135
+ });
119
136
 
120
- // this.unloadListener(db);
121
- }
137
+ const active = paymentsWithId.find(payment => payment.isActive);
138
+ if (active) {
139
+ if (active.id === 'trc20') {
140
+ this.setState({ isUsdt: true });
141
+ }
142
+ }
122
143
 
123
- componentWillUnmount() {
124
- this.unsubscribe && this.unsubscribe.map((unsubscribe) => unsubscribe());
125
- clearTimeout(this.state.recalc);
144
+ return paymentsWithId;
126
145
  }
127
-
128
- setIdForPaymentMethods(payments) {
129
- if (payments) {
130
- let paymentsWithId = payments.map((el) => {
131
- return {
132
- ...el,
133
- id: el.name.replace(/ /g, "").toLowerCase(),
134
- };
135
- });
136
146
 
137
- const active = paymentsWithId.find(payment => payment.isActive);
138
- if (active) {
139
- if (active.id === 'trc20') {
140
- this.setState({ isUsdt: true });
141
- }
142
- }
147
+ return false;
148
+ }
149
+
150
+ createTransaction = async (db) => {
151
+ let model = {
152
+ coupon: this.state.couponValue,
153
+ from: {
154
+ amount: +this.state.sendValue,
155
+ country: this.state.fromCountryValue,
156
+ currency: this.state.fromCurrencyValue,
157
+ },
158
+ to: {
159
+ amount: +this.state.receivedValue,
160
+ country: this.state.toCountryValue,
161
+ currency: this.state.toCurrencyValue,
162
+ },
163
+ timestamp: Date.now(),
164
+ };
143
165
 
144
- return paymentsWithId;
145
- }
166
+ try {
167
+ const transaction = await db.collection("transactions").add(model);
168
+ await this.setState({ storeId: transaction.id });
169
+ sessionStorage.setItem("storeId", `${transaction.id}`);
170
+ } catch (e) {
171
+ this.setState({ hasError: true });
172
+ }
173
+ };
146
174
 
147
- return false;
175
+ addLabelToPaymentMethods = (paymentMethods) => {
176
+ if (paymentMethods) {
177
+ return paymentMethods.map(paymentMethod => ({ ...paymentMethod, label: this.paymentMethodLabel(paymentMethod.name) }));
148
178
  }
179
+ }
180
+
181
+ paymentMethodLabel = (paymentMethodName) => {
182
+ const content = this.props.locale === 'es' ? es : en;
183
+ const labels = {
184
+ Zelle: 'Zelle',
185
+ BBVABank: content.banks.bbva,
186
+ STP: 'STP',
187
+ //BANK: 'BANK',
188
+ CreditBankOfPeru: content.banks.bcp,
189
+ Interbank: 'Interbank',
190
+ ScotiabankPeru: content.banks.scotiabank_peru,
191
+ WesternDiscountBank: content.banks.western_discount_bank,
192
+ Provincial: 'Provincial',
193
+ Mercantil: 'Mercantil',
194
+ Banesco: 'Banesco',
195
+ UalaNew: 'Ualá',
196
+ MercadoPagoNew: 'Mercado Pago',
197
+ bank: 'Otra entidad financiera (CBU)'
198
+ }
199
+ return paymentMethodName in labels ? labels[paymentMethodName] : paymentMethodName;
200
+ }
201
+
202
+ subscribeTransaction = async (db) => {
203
+ try {
204
+ const transactions = await db
205
+ .collection("transactions")
206
+ .doc(
207
+ `${this.state.storeId
208
+ ? this.state.storeId
209
+ : sessionStorage.getItem("storeId")
210
+ }`
211
+ )
212
+ .onSnapshot(async (transaction) => {
213
+ const data = await transaction.data();
214
+ if (data) {
215
+ const { from, to } = data;
216
+ let receivedValue = to.amount;
217
+
218
+ if (to.paymentMethods && to.paymentMethods.length > 0) {
219
+ const element = to.paymentMethods.find(element => element.isActive);
220
+ if (element) {
221
+ receivedValue = element.isWallet ? element.amountCrypto : element.amount;
222
+ }
223
+ }
149
224
 
150
- createTransaction = async (db) => {
151
- let model = {
152
- coupon: this.state.couponValue,
153
- from: {
154
- amount: +this.state.sendValue,
155
- country: this.state.fromCountryValue,
156
- currency: this.state.fromCurrencyValue,
157
- },
158
- to: {
159
- amount: +this.state.receivedValue,
160
- country: this.state.toCountryValue,
161
- currency: this.state.toCurrencyValue,
162
- },
163
- timestamp: new Date(),
164
- };
225
+ let {
226
+ newAmountSender,
227
+ newAmountReceiver,
228
+ appliedDiscountSender,
229
+ appliedDiscountReceiver
230
+ } = applyTaxDiscount(from.country, to.country, +this.state.sendValue, to.amount);
165
231
 
166
- try {
167
- const transaction = await db.collection("transactions").add(model);
168
- await this.setState({ storeId: transaction.id });
169
- sessionStorage.setItem("storeId", `${transaction.id}`);
170
- } catch (e) {
171
- this.setState({ hasError: true });
172
- }
173
- };
232
+ receivedValue = (+newAmountReceiver).toFixed(2);
174
233
 
175
- addLabelToPaymentMethods = (paymentMethods) => {
176
- if (paymentMethods) {
177
- return paymentMethods.map(paymentMethod => ({ ...paymentMethod, label: this.paymentMethodLabel(paymentMethod.name) }));
178
- }
179
- }
234
+ await this.setState({
235
+ sendValue: newAmountSender + appliedDiscountSender,
236
+ convertValue: from.amountConverted,
237
+ receivedValue: receivedValue,
238
+ fees: from.fees,
239
+ fromExchangeRate: from.exchangeRate,
240
+ fromCurrencyValue: from.currency,
241
+ toCurrencyValue: to.currency,
242
+ fromCountryValue: from.country === "TR" ? "WLT" : from.country,
243
+ toCountryValue: to.country,
244
+ coupon: data.coupon,
245
+ plus: data.coupon ? data.promo : 0,
246
+ couponRedeemed: false,
247
+ banks: this.setIdForPaymentMethods(to.banks),
248
+ paymentMethods: this.addLabelToPaymentMethods(this.setIdForPaymentMethods(to.paymentMethods)),
249
+ taxSender: appliedDiscountSender,
250
+ taxReceiver: appliedDiscountReceiver
251
+ }, () => {
252
+ this.showExchangeRate(receivedValue);
253
+ this.updateLimits();
254
+ this.addCoupon();
255
+ });
180
256
 
181
- paymentMethodLabel = (paymentMethodName) => {
182
- const content = this.props.locale === 'es' ? es : en;
183
- const labels = {
184
- Zelle: 'Zelle',
185
- BBVABank: content.banks.bbva,
186
- STP: 'STP',
187
- //BANK: 'BANK',
188
- CreditBankOfPeru: content.banks.bcp,
189
- Interbank: 'Interbank',
190
- ScotiabankPeru: content.banks.scotiabank_peru,
191
- WesternDiscountBank: content.banks.western_discount_bank,
192
- Provincial: 'Provincial',
193
- Mercantil: 'Mercantil',
194
- Banesco: 'Banesco',
195
- UalaNew: 'Ualá',
196
- MercadoPagoNew: 'Mercado Pago',
197
- bank: 'Otra entidad financiera (CBU)'
198
- }
199
- return paymentMethodName in labels ? labels[paymentMethodName] : paymentMethodName;
257
+ }
258
+ });
259
+ this.unsubscribe.push(transactions);
260
+ } catch (e) {
261
+ this.setState({ hasError: true });
200
262
  }
263
+ };
201
264
 
202
- subscribeTransaction = async (db) => {
203
- try {
204
- const transactions = await db
205
- .collection("transactions")
206
- .doc(
207
- `${this.state.storeId
208
- ? this.state.storeId
209
- : sessionStorage.getItem("storeId")
210
- }`
211
- )
212
- .onSnapshot(async (transaction) => {
213
- const data = await transaction.data();
214
- if (data) {
215
- const { from, to } = data;
216
- let receivedValue = to.amount;
217
-
218
- if (to.paymentMethods && to.paymentMethods.length > 0) {
219
- const element = to.paymentMethods.find(element => element.isActive);
220
- if (element) {
221
- receivedValue = element.isWallet ? element.amountCrypto : element.amount;
222
- }
223
- }
265
+ subscribeCalculatorConfig = async (db) => {
266
+ try {
267
+ const calculator = await db
268
+ .collection("variables")
269
+ .onSnapshot(async (variable) => {
270
+ let variables = {};
224
271
 
225
- let {
226
- newAmountSender,
227
- newAmountReceiver,
228
- appliedDiscountSender,
229
- appliedDiscountReceiver
230
- } = applyTaxDiscount(from.country, to.country, +this.state.sendValue, to.amount);
231
-
232
- receivedValue = (+newAmountReceiver).toFixed(2);
233
-
234
- await this.setState({
235
- sendValue: newAmountSender + appliedDiscountSender,
236
- convertValue: from.amountConverted,
237
- receivedValue: receivedValue,
238
- fees: from.fees,
239
- fromExchangeRate: from.exchangeRate,
240
- fromCurrencyValue: from.currency,
241
- toCurrencyValue: to.currency,
242
- fromCountryValue: from.country === "TR" ? "WLT" : from.country,
243
- toCountryValue: to.country,
244
- coupon: data.coupon,
245
- plus: data.coupon ? data.promo : 0,
246
- couponRedeemed: false,
247
- banks: this.setIdForPaymentMethods(to.banks),
248
- paymentMethods: this.addLabelToPaymentMethods(this.setIdForPaymentMethods(to.paymentMethods)),
249
- taxSender: appliedDiscountSender,
250
- taxReceiver: appliedDiscountReceiver
251
- }, () => {
252
- this.showExchangeRate(receivedValue);
253
- this.updateLimits();
254
- this.addCoupon();
255
- });
272
+ await variable.forEach((doc) => {
273
+ variables[doc.id] = doc.data();
274
+ });
256
275
 
257
- }
258
- });
259
- this.unsubscribe.push(transactions);
260
- } catch (e) {
261
- this.setState({ hasError: true });
262
- }
276
+ if (Object.keys(variables).length > 0) {
277
+ this.setState({
278
+ showCallToAction: variables["event"].show,
279
+ calculator: variables["calculator"],
280
+ }, () => {
281
+ const { timestamp, frequency } = variables["calculator"];
282
+ const currentTime = +new Date().getTime();
283
+ const diference = Math.abs(currentTime - timestamp) / 1000;
284
+ if (diference > frequency) this.updateCaculatorData(db);
285
+ });
286
+ }
287
+ });
288
+ this.unsubscribe.push(calculator);
289
+ return calculator;
290
+ } catch (e) {
291
+ // this.setState({ hasError: true });
292
+ }
293
+ };
294
+
295
+ _convertAmount = async (currency) => {
296
+ try {
297
+ if (currency == "ARS") {
298
+ const { data } = await axios.get(`${this.ENDPOINTS.EXCHANGE.getUSDBlueRate}`);
299
+ let blueRate = await JSON.parse(JSON.stringify(data));
300
+ blueRate = { result: blueRate.blue.value_sell };
301
+ return blueRate;
302
+ } else {
303
+ const { data } = await axios.get(`${this.ENDPOINTS.EXCHANGE.getRate_v2(currency)}`);
304
+ return { result: parseFloat(data['usd'][currency.toLowerCase()].toFixed(2)) };
305
+ }
306
+ } catch (e) {
307
+ return e;
308
+ }
309
+ };
310
+
311
+ updateCaculatorData = async (db) => {
312
+ const countryModel = {
313
+ active: false,
314
+ countryMax: 5000,
315
+ countryMin: 20,
316
+ usdSell: 0,
317
+ usdBuy: 0,
318
+ rates: { from: 1, to: 1 },
263
319
  };
264
320
 
265
- subscribeCalculatorConfig = async (db) => {
266
- try {
267
- const calculator = await db
268
- .collection("variables")
269
- .onSnapshot(async (variable) => {
270
- let variables = {};
271
-
272
- await variable.forEach((doc) => {
273
- variables[doc.id] = doc.data();
274
- });
275
-
276
- if (Object.keys(variables).length > 0) {
277
- this.setState({
278
- showCallToAction: variables["event"].show,
279
- calculator: variables["calculator"],
280
- }, () => {
281
- const { timestamp, frequency } = variables["calculator"];
282
- const currentTime = +new Date().getTime();
283
- const diference = Math.abs(currentTime - timestamp) / 1000;
284
- if (diference > frequency) this.updateCaculatorData(db);
285
- });
286
- }
287
- });
288
- this.unsubscribe.push(calculator);
289
- return calculator;
290
- } catch (e) {
291
- // this.setState({ hasError: true });
292
- }
293
- };
321
+ const availableCountries = [
322
+ "USDT",
323
+ "AR",
324
+ "CL",
325
+ "CO",
326
+ "DO",
327
+ "EC",
328
+ "MX",
329
+ "PE",
330
+ "PE-USD",
331
+ "US",
332
+ "VE",
333
+ "ES",
334
+ "WLT"
335
+ ];
336
+
337
+ const rates = {};
338
+ let body = { timestamp: new Date().getTime(), frequency: 43200 };
339
+ await Promise.all(
340
+ availableCountries.map(async (country) => {
341
+ let currency = "";
342
+ body[country] = { ...this.state.calculator[country] };
343
+ if (body[country] && body[country].countryTo && body[country]) {
344
+ return await Promise.all(
345
+ availableCountries.map(async (c) => {
346
+ if (c != country)
347
+ body[country].countryTo[c] = {
348
+ usdSell: 0,
349
+ usdBuy: 0,
350
+ ...body[country].countryTo[c],
351
+ };
352
+ let usdRate = "";
294
353
 
295
- _convertAmount = async (currency) => {
296
- try {
297
- if (currency == "ARS") {
298
- const { data } = await axios.get(`${this.ENDPOINTS.EXCHANGE.getUSDBlueRate}`);
299
- let blueRate = await JSON.parse(JSON.stringify(data));
300
- blueRate = { result: blueRate.blue.value_sell };
301
- return blueRate;
302
- } else {
303
- const { data } = await axios.get(`${this.ENDPOINTS.EXCHANGE.getRate_v2(currency)}`);
304
- return { result: parseFloat(data['usd'][currency.toLowerCase()].toFixed(2)) };
305
- }
306
- } catch (e) {
307
- return e;
308
- }
309
- };
354
+ if (!rates.hasOwnProperty(c)) {
355
+ let forceUSD = (c == "USDT" || c == "WLT");
356
+ currency = countries.find(
357
+ (country) => country.code == (forceUSD ? "US" : c)
358
+ ).currency;
310
359
 
311
- updateCaculatorData = async (db) => {
312
- const countryModel = {
313
- active: false,
314
- countryMax: 5000,
315
- countryMin: 20,
316
- usdSell: 0,
317
- usdBuy: 0,
318
- rates: { from: 1, to: 1 },
319
- };
360
+ usdRate =
361
+ currency == "USD"
362
+ ? { result: 1 }
363
+ : await this._convertAmount(currency);
320
364
 
321
- const availableCountries = [
322
- "USDT",
323
- "AR",
324
- "CL",
325
- "CO",
326
- "DO",
327
- "EC",
328
- "MX",
329
- "PE",
330
- "PE-USD",
331
- "US",
332
- "VE",
333
- "ES",
334
- "WLT"
335
- ];
336
-
337
- const rates = {};
338
- let body = { timestamp: new Date().getTime(), frequency: 43200 };
339
- await Promise.all(
340
- availableCountries.map(async (country) => {
341
- let currency = "";
342
- body[country] = { ...this.state.calculator[country] };
343
- if (body[country] && body[country].countryTo && body[country]) {
344
- return await Promise.all(
345
- availableCountries.map(async (c) => {
346
- if (c != country)
347
- body[country].countryTo[c] = {
348
- usdSell: 0,
349
- usdBuy: 0,
350
- ...body[country].countryTo[c],
351
- };
352
- let usdRate = "";
353
-
354
- if (!rates.hasOwnProperty(c)) {
355
- let forceUSD = (c == "USDT" || c == "WLT");
356
- currency = countries.find(
357
- (country) => country.code == (forceUSD ? "US" : c)
358
- ).currency;
359
-
360
- usdRate =
361
- currency == "USD"
362
- ? { result: 1 }
363
- : await this._convertAmount(currency);
364
-
365
- rates[c] = { buy: 0, sell: 0 };
366
- }
365
+ rates[c] = { buy: 0, sell: 0 };
366
+ }
367
367
 
368
- if (usdRate && typeof usdRate.result === "number") {
369
- rates[c].buy = rates[c].sell = parseFloat(
370
- c == "SV" ? usdRate.result : usdRate.result.toFixed(2)
371
- );
372
- } else {
373
- rates[c].buy = rates[c].sell = 1;
374
- }
375
- if (body[country].countryTo[c]) {
376
- body[country].countryTo[c].usdBuy = rates[c].buy;
377
- body[country].countryTo[c].usdSell = rates[c].sell;
378
- body[country].countryTo[c].countryMax = parseFloat(
379
- c == "SV"
380
- ? countryModel.countryMax * 1
381
- : (
382
- Math.ceil(countryModel.countryMax * rates[c].buy) /
383
- rates[c].buy
384
- ).toFixed(2)
385
- );
386
- body[country].countryTo[c].countryMin = parseFloat(
387
- (c == "SV"
388
- ? countryModel.countryMin * 1
389
- : Math.ceil(countryModel.countryMin * rates[c].buy) /
390
- rates[c].buy
391
- ).toFixed(2)
392
- );
393
- }
394
- if (rates[country]) {
395
- body[country].usdBuy = rates[country].buy;
396
- body[country].usdSell = rates[country].sell;
397
- body[country].countryMax = parseFloat(
398
- (country == "SV"
399
- ? countryModel.countryMax * 1
400
- : Math.ceil(
401
- country == "VE"
402
- ? 1000
403
- : countryModel.countryMax * rates[country].buy
404
- ) / rates[country].buy
405
- ).toFixed(2)
406
- );
407
- body[country].countryMin = parseFloat(
408
- (country == "SV"
409
- ? countryModel.countryMin * 1
410
- : Math.ceil(countryModel.countryMin * rates[country].buy) /
411
- rates[country].buy
412
- ).toFixed(2)
413
- );
414
- }
415
- })
416
- );
417
- }
368
+ if (usdRate && typeof usdRate.result === "number") {
369
+ rates[c].buy = rates[c].sell = parseFloat(
370
+ c == "SV" ? usdRate.result : usdRate.result.toFixed(2)
371
+ );
372
+ } else {
373
+ rates[c].buy = rates[c].sell = 1;
374
+ }
375
+ if (body[country].countryTo[c]) {
376
+ body[country].countryTo[c].usdBuy = rates[c].buy;
377
+ body[country].countryTo[c].usdSell = rates[c].sell;
378
+ body[country].countryTo[c].countryMax = parseFloat(
379
+ c == "SV"
380
+ ? countryModel.countryMax * 1
381
+ : (
382
+ Math.ceil(countryModel.countryMax * rates[c].buy) /
383
+ rates[c].buy
384
+ ).toFixed(2)
385
+ );
386
+ body[country].countryTo[c].countryMin = parseFloat(
387
+ (c == "SV"
388
+ ? countryModel.countryMin * 1
389
+ : Math.ceil(countryModel.countryMin * rates[c].buy) /
390
+ rates[c].buy
391
+ ).toFixed(2)
392
+ );
393
+ }
394
+ if (rates[country]) {
395
+ body[country].usdBuy = rates[country].buy;
396
+ body[country].usdSell = rates[country].sell;
397
+ body[country].countryMax = parseFloat(
398
+ (country == "SV"
399
+ ? countryModel.countryMax * 1
400
+ : Math.ceil(
401
+ country == "VE"
402
+ ? 1000
403
+ : countryModel.countryMax * rates[country].buy
404
+ ) / rates[country].buy
405
+ ).toFixed(2)
406
+ );
407
+ body[country].countryMin = parseFloat(
408
+ (country == "SV"
409
+ ? countryModel.countryMin * 1
410
+ : Math.ceil(countryModel.countryMin * rates[country].buy) /
411
+ rates[country].buy
412
+ ).toFixed(2)
413
+ );
414
+ }
418
415
  })
419
- );
420
- await db.collection("variables").doc("calculator").update(body);
416
+ );
417
+ }
418
+ })
419
+ );
420
+ await db.collection("variables").doc("calculator").update(body);
421
+ };
422
+
423
+ unloadListener = () => {
424
+ window.onbeforeunload = () => {
425
+ return this.beforeUnload();
421
426
  };
427
+ };
428
+
429
+ beforeUnload = async () => {
430
+ sessionStorage.removeItem("storeId");
431
+
432
+ //if (db) db.clearPersistence();
433
+ //const { db } = await loadFirebaseDB(this.state.testMode, this.state.config);
434
+ const firebase = await loadFirebaseDB(this.state.testMode, this.state.config);
435
+ const db = firebase.firestore();
436
+
437
+ return await db
438
+ .collection("transactions")
439
+ .doc(`${this.state.storeId}`)
440
+ .delete();
441
+ };
442
+
443
+ handleSend = async ({ target }) => {
444
+ await this.setState({ sendValue: target.value });
445
+ this.calculate();
446
+ };
447
+
448
+ handleReceived = async ({ target }) => {
449
+ await this.setState({ receivedValue: target.value });
450
+ this.calculate("to");
451
+ };
452
+
453
+ handleCoupon = async ({ target }) => {
454
+ if (this.state.typingTimeoutCoupon) {
455
+ clearTimeout(this.state.typingTimeoutCoupon);
456
+ }
422
457
 
423
- unloadListener = () => {
424
- window.onbeforeunload = () => {
425
- return this.beforeUnload();
426
- };
427
- };
458
+ let initialAmount = parseFloat(this.state.receivedValue || 0);
459
+ let plusAmount = parseFloat(this.state.plus || 0);
460
+ this.setState({
461
+ isValid: false,
462
+ hasValidCoupon: false,
463
+ countryError: { hasErrors: false, value: "" },
464
+ receivedValue: initialAmount - plusAmount,
465
+ couponRedeemed: false,
466
+ plus: 0,
467
+ });
468
+
469
+ // this.setState({
470
+ // hasValidCoupon: false,
471
+ // });
472
+
473
+ this.setState({
474
+ typingTimeoutCoupon: setTimeout(() => {
475
+ this.addCoupon();
476
+ }, 1200),
477
+ });
478
+
479
+ this.setState({
480
+ couponValue: target.value.toUpperCase(),
481
+ isValid: true,
482
+ hasValidCoupon: true,
483
+ countryError: { hasErrors: false, value: "" },
484
+ });
485
+ };
486
+
487
+ handleIsLoading = (value) => {
488
+ this.setState({ isLoading: value });
489
+ };
490
+
491
+ handleToCountryValue = async (value) => {
492
+ await this.setState({ toCountryValue: value, receivedValue: "" });
493
+ await this.updateLimits();
494
+ this.calculate("from");
495
+ this.setState({ banks: false });
496
+ };
497
+
498
+ handleToCurrencyValue = (value) => {
499
+ this.setState({ toCurrencyValue: value });
500
+ };
501
+
502
+ handleFromCountryValue = async (value) => {
503
+ await this.setState({ fromCountryValue: value, isCountryFromPayPal: value == "PAYPAL" });
504
+ await this.updateLimits();
505
+ this.calculate();
506
+ };
507
+
508
+ handleFromCurrencyValue = (value) => {
509
+ this.setState({ fromCurrencyValue: value });
510
+ };
511
+
512
+ updateLimits = (selectedMethod) => {
513
+
514
+ const countryData = this.state.calculator[this.state.fromCountryValue == "TR" ? "WLT" : this.state.fromCountryValue];
515
+ let { countryMin, countryMax, usdBuy } = countryData;
516
+ let { usdSell } = countryData.countryTo[this.state.toCountryValue || "US"];
517
+ if (
518
+ this.state.paymentMethods &&
519
+ this.state.paymentMethods.length &&
520
+ this.state.paymentMethods[0].isWallet &&
521
+ this.state.paymentMethods[0].isActive
522
+ ) {
523
+ //usdBuy = 1;
524
+ usdSell = 1;
525
+ }
428
526
 
429
- beforeUnload = async () => {
430
- sessionStorage.removeItem("storeId");
527
+ this.setState({
528
+ minFromValue:
529
+ this.state.fromCountryValue == "SV"
530
+ ? countryMin * usdBuy
531
+ : Math.ceil(countryMin * usdBuy),
532
+ maxFromValue:
533
+ this.state.fromCountryValue == "SV"
534
+ ? countryMax * usdBuy
535
+ : Math.ceil(countryMax * usdBuy),
536
+ minToValue:
537
+ this.state.toCountryValue == "SV"
538
+ ? countryMin * usdSell
539
+ : Math.ceil(countryMin * usdSell),
540
+ maxToValue:
541
+ this.state.toCountryValue == "SV"
542
+ ? countryMax * usdSell
543
+ : Math.ceil(countryMax * usdSell),
544
+ });
545
+ };
546
+
547
+ getCountryLimits = (countryFrom, countryTo) => {
548
+ const countryData = this.state.calculator[countryFrom];
549
+ let { countryMin, countryMax, usdBuy } = countryData;
550
+ let { usdSell } = countryData.countryTo[countryTo];
551
+ if (
552
+ this.state.paymentMethods &&
553
+ this.state.paymentMethods.length &&
554
+ this.state.paymentMethods[0].isWallet &&
555
+ this.state.paymentMethods[0].isActive
556
+ ) {
557
+ //usdBuy = 1;
558
+ usdSell = 1;
559
+ }
431
560
 
432
- //if (db) db.clearPersistence();
433
- //const { db } = await loadFirebaseDB(this.state.testMode, this.state.config);
434
- const firebase = await loadFirebaseDB(this.state.testMode, this.state.config);
435
- const db = firebase.firestore();
561
+ let limits = {
562
+ minFromValue: 0,
563
+ maxFromValue: 0,
564
+ minToValue: 0,
565
+ maxToValue: 0,
566
+ }
436
567
 
437
- return await db
438
- .collection("transactions")
439
- .doc(`${this.state.storeId}`)
440
- .delete();
441
- };
568
+ if (countryFrom == "SV") {
569
+ limits.minFromValue = countryMin * usdBuy;
570
+ limits.maxFromValue = countryMax * usdBuy;
571
+ } else {
572
+ limits.minFromValue = Math.ceil(countryMin * usdBuy);
573
+ limits.maxFromValue = Math.ceil(countryMax * usdBuy);
574
+ }
442
575
 
443
- handleSend = async ({ target }) => {
444
- await this.setState({ sendValue: target.value });
445
- this.calculate();
446
- };
576
+ if (countryTo == "SV") {
577
+ limits.minToValue = countryMin * usdSell;
578
+ limits.maxToValue = countryMax * usdSell;
579
+ } else {
580
+ limits.minToValue = Math.ceil(countryMin * usdSell);
581
+ limits.maxToValue = Math.ceil(countryMax * usdSell);
582
+ }
447
583
 
448
- handleReceived = async ({ target }) => {
449
- await this.setState({ receivedValue: target.value });
450
- this.calculate("to");
451
- };
584
+ return limits;
585
+ };
586
+
587
+ calculateExchangeRate = (receivedValue) => {
588
+ const {
589
+ fromCurrencyValue,
590
+ isUsdt,
591
+ sendValue,
592
+ isCountryFromPayPal
593
+ } = this.state;
594
+
595
+ if (sendValue != 0 && receivedValue != 0) {
596
+ let rate = 0.00;
597
+ let networkFee = 0.00;
598
+ let countryFromFee = 0.00;
599
+
600
+ let amountFromCalc = sendValue;
601
+ let fee = this.state.calculator[this.state.fromCountryValue].fee ?
602
+ this.state.calculator[this.state.fromCountryValue].fee
603
+ : { type: "A", value: 0.00, enabled: false }
604
+
605
+ if (fee.enabled) {
606
+ countryFromFee = fee.type == "A" ? fee.value : (amountFromCalc * fee.value).toFixed(2);
607
+ amountFromCalc = amountFromCalc - (networkFee + countryFromFee);
608
+ }
452
609
 
453
- handleCoupon = async ({ target }) => {
454
- if (this.state.typingTimeoutCoupon) {
455
- clearTimeout(this.state.typingTimeoutCoupon);
456
- }
610
+ let amountFromUSD = fromCurrencyValue == "USD" ?
611
+ amountFromCalc :
612
+ parseFloat(amountFromCalc) / this.state.calculator[this.state.fromCountryValue].usdBuy;
613
+
614
+ if (isUsdt) {
615
+ rate = 1.00;
616
+ networkFee = isCountryFromPayPal ? 2.00 : (Math.abs(amountFromUSD - receivedValue / rate).toFixed(2));
617
+ } else {
618
+ rate = isCountryFromPayPal ?
619
+ rate = (Math.floor((receivedValue / amountFromCalc) * 100) / 100).toFixed(2) :
620
+ (Math.floor((receivedValue / sendValue) * 100) / 100).toFixed(2);
621
+ }
457
622
 
458
- let initialAmount = parseFloat(this.state.receivedValue || 0);
459
- let plusAmount = parseFloat(this.state.plus || 0);
460
- this.setState({
461
- isValid: false,
462
- hasValidCoupon: false,
463
- countryError: { hasErrors: false, value: "" },
464
- receivedValue: initialAmount - plusAmount,
465
- couponRedeemed: false,
466
- plus: 0,
467
- });
623
+ if (rate < 1) {
624
+ rate = (Math.floor((sendValue / receivedValue) * 100) / 100).toFixed(2);
625
+ networkFee = (Math.abs(receivedValue * rate - amountFromUSD).toFixed(2));
626
+ }
468
627
 
469
- // this.setState({
470
- // hasValidCoupon: false,
471
- // });
628
+ this.setState({
629
+ exchangeRate: rate,
630
+ networkFee: networkFee,
631
+ countryFromFee: countryFromFee,
632
+ sendValueUSD: amountFromUSD
633
+ });
634
+ }
635
+ };
636
+
637
+ showExchangeRate = (receivedValue) => {
638
+ const withoutFee = { amount: 0, value: 0, type: "A", amountUSD: 0, enabled: false };
639
+ const {
640
+ fromCurrencyValue,
641
+ isUsdt,
642
+ convertValue,
643
+ fromExchangeRate,
644
+ fees
645
+ } = this.state;
646
+
647
+ let convertValueCrypto = convertValue;
648
+ let showTotalFees = false;
649
+ let exchangeRateLabel = "x";
650
+
651
+ if (convertValue != 0 && receivedValue != 0) {
652
+
653
+ let feeTraund = fees.traund != null ? { ...fees.traund, enabled: true } : withoutFee;
654
+ let feePaypal = fees.paypal != null ? { ...fees.paypal, enabled: true } : withoutFee;
655
+
656
+ let rate = fromExchangeRate;
657
+ let networkFee = 0.00;
658
+ let traundFeeValue = feeTraund.enabled ? feeTraund.amount : 0.00;
659
+ let paypalFeeValue = feePaypal.enabled ? feePaypal.amount : 0.00;
660
+
661
+ showTotalFees = paypalFeeValue > 0;
662
+ if (isUsdt) {
663
+ rate = 1;
664
+ networkFee = Math.abs(convertValue - receivedValue / rate);
665
+ if (fromCurrencyValue != "USD") {
666
+ {
667
+ const { sendValue, paymentMethods } = this.state;
668
+ if (paymentMethods.length && paymentMethods[0].isWallet) {
669
+ networkFee = Math.abs(sendValue - Number(paymentMethods[0].amount) / fromExchangeRate)
670
+ }
671
+ }
672
+ }
673
+ convertValueCrypto = receivedValue;
674
+ showTotalFees = true;
675
+ }
472
676
 
473
- this.setState({
474
- typingTimeoutCoupon: setTimeout(() => {
475
- this.addCoupon();
476
- }, 1200),
477
- });
677
+ if (rate < 1) {
678
+ exchangeRateLabel = "÷"
679
+ rate = (Math.floor((convertValue / receivedValue) * 100) / 100).toFixed(2);
680
+ networkFee = Math.abs(receivedValue * rate - convertValue);
681
+ }
682
+ let totalFees = traundFeeValue + paypalFeeValue + networkFee;
683
+
684
+ this.setState({
685
+ exchangeRateLabel: exchangeRateLabel,
686
+ exchangeRate: rate,
687
+ traundFee: traundFeeValue.toFixed(2),
688
+ paypalFee: paypalFeeValue.toFixed(2),
689
+ networkFee: networkFee.toFixed(2),
690
+ showTotalFees: showTotalFees,
691
+ totalFees: totalFees,
692
+ convertValueCrypto: convertValueCrypto
693
+ });
694
+ }
695
+ };
696
+
697
+ calculate = async (source = "from") => {
698
+ this.setState({
699
+ recalculate: false,
700
+ isUsdt: false,
701
+ exchangeRate: 0.0,
702
+ couponValue: this.state.couponValue,
703
+ couponRedeemed: false,
704
+ reference: this.state.reference,
705
+ secretKey: this.state.secretKey,
706
+ plus: 0
707
+ });
708
+ if (this.state.recalc) {
709
+ clearTimeout(this.state.recalc);
710
+ }
478
711
 
479
- this.setState({
480
- couponValue: target.value.toUpperCase(),
481
- isValid: true,
482
- hasValidCoupon: true,
483
- countryError: { hasErrors: false, value: "" },
484
- });
712
+ let {
713
+ newAmountSender,
714
+ } = applyTaxDiscount(this.state.fromCountryValue === "WLT" ? "TR" : this.state.fromCountryValue, this.state.toCountryValue, this.state.sendValue, this.state.receivedValue);
715
+
716
+ let model = {
717
+ coupon: this.state.couponValue,
718
+ from: {
719
+ amount: newAmountSender,
720
+ country: this.state.fromCountryValue === "WLT" ? "TR" : this.state.fromCountryValue,
721
+ currency: this.state.fromCurrencyValue,
722
+ },
723
+ to: {
724
+ amount: this.state.receivedValue,
725
+ country: this.state.toCountryValue,
726
+ currency: this.state.toCurrencyValue,
727
+ },
485
728
  };
486
729
 
487
- handleIsLoading = (value) => {
488
- this.setState({ isLoading: value });
489
- };
730
+ if (source == "initial" || source == "end") {
731
+ const url = this.ENDPOINTS.OPERATIONS.calculate(this.state.storeId || sessionStorage.getItem('storeId'), "from");
490
732
 
491
- handleToCountryValue = async (value) => {
492
- await this.setState({ toCountryValue: value, receivedValue: "" });
493
- await this.updateLimits();
494
- this.calculate("from");
495
- this.setState({ banks: false });
496
- };
733
+ const res = await axios.post(
734
+ url,
735
+ model,
736
+ {
737
+ headers: {
738
+ "x-api-access-sig": getSignatureHeader('POST', url, model, this.state.reference, this.state.secretKey)
739
+ },
740
+ }
741
+ );
497
742
 
498
- handleToCurrencyValue = (value) => {
499
- this.setState({ toCurrencyValue: value });
500
- };
743
+ if (res) {
744
+ await this.setState({
745
+ loadingTo: false,
746
+ loadingFrom: false,
747
+ recalculate: true,
748
+ recalc: setTimeout(() => {
749
+ this.calculate();
750
+ }, 5 * 60 * 1000),
751
+ });
752
+ }
501
753
 
502
- handleFromCountryValue = async (value) => {
503
- await this.setState({ fromCountryValue: value, isCountryFromPayPal: value == "PAYPAL" });
504
- await this.updateLimits();
505
- this.calculate();
506
- };
754
+ this.setState({
755
+ loadingTo: false,
756
+ loadingFrom: false,
757
+ }, () => {
758
+ this.addCoupon()
759
+ });
507
760
 
508
- handleFromCurrencyValue = (value) => {
509
- this.setState({ fromCurrencyValue: value });
510
- };
761
+ return;
762
+ }
511
763
 
512
- updateLimits = (selectedMethod) => {
513
-
514
- const countryData = this.state.calculator[this.state.fromCountryValue == "TR" ? "WLT" : this.state.fromCountryValue];
515
- let { countryMin, countryMax, usdBuy } = countryData;
516
- let { usdSell } = countryData.countryTo[this.state.toCountryValue || "US"];
764
+ if (this.state.typingTimeout) clearTimeout(this.state.typingTimeout);
765
+ this.setState({
766
+ typingTimeout: setTimeout(async () => {
767
+ let validAmount = this.validateAmount(model.from.amount, "from");
768
+ let validAmountTo = this.validateAmount(model.to.amount, "to");
517
769
  if (
518
- this.state.paymentMethods &&
519
- this.state.paymentMethods.length &&
520
- this.state.paymentMethods[0].isWallet &&
521
- this.state.paymentMethods[0].isActive
770
+ (validAmount && validAmountTo) ||
771
+ (validAmount && source == "from") ||
772
+ (validAmountTo && source == "to")
522
773
  ) {
523
- //usdBuy = 1;
524
- usdSell = 1;
525
- }
774
+ await this.setState({
775
+ loadingTo: source == "from",
776
+ loadingFrom: source == "to",
777
+ couponValue: this.state.couponValue,
778
+ couponRedeemed: false,
779
+ plus: 0
780
+ });
526
781
 
527
- this.setState({
528
- minFromValue:
529
- this.state.fromCountryValue == "SV"
530
- ? countryMin * usdBuy
531
- : Math.ceil(countryMin * usdBuy),
532
- maxFromValue:
533
- this.state.fromCountryValue == "SV"
534
- ? countryMax * usdBuy
535
- : Math.ceil(countryMax * usdBuy),
536
- minToValue:
537
- this.state.toCountryValue == "SV"
538
- ? countryMin * usdSell
539
- : Math.ceil(countryMin * usdSell),
540
- maxToValue:
541
- this.state.toCountryValue == "SV"
542
- ? countryMax * usdSell
543
- : Math.ceil(countryMax * usdSell),
544
- });
545
- };
782
+ if (source == "from")
783
+ this.setState({
784
+ receivedValue: "",
785
+ });
786
+ if (source == "to")
787
+ this.setState({
788
+ sendValue: "",
789
+ });
790
+ const url = this.ENDPOINTS.OPERATIONS.calculate(this.state.storeId, source)
546
791
 
547
- getCountryLimits = (countryFrom, countryTo) => {
548
- const countryData = this.state.calculator[countryFrom];
549
- let { countryMin, countryMax, usdBuy } = countryData;
550
- let { usdSell } = countryData.countryTo[countryTo];
551
- if (
552
- this.state.paymentMethods &&
553
- this.state.paymentMethods.length &&
554
- this.state.paymentMethods[0].isWallet &&
555
- this.state.paymentMethods[0].isActive
556
- ) {
557
- //usdBuy = 1;
558
- usdSell = 1;
559
- }
792
+ const res = await axios.post(
793
+ url,
794
+ model,
795
+ {
796
+ headers: {
797
+ "x-api-access-sig": getSignatureHeader('POST', url, model, this.state.reference, this.state.secretKey)
798
+ },
799
+ }
800
+ );
560
801
 
561
- let limits = {
562
- minFromValue: 0,
563
- maxFromValue: 0,
564
- minToValue: 0,
565
- maxToValue: 0,
802
+ if (res) {
803
+ await this.setState({
804
+ loadingTo: false,
805
+ loadingFrom: false,
806
+ recalculate: true,
807
+ recalc: setTimeout(() => {
808
+ this.calculate();
809
+ }, 5 * 60 * 1000),
810
+ });
811
+ }
566
812
  }
813
+ }, 650),
814
+ }, () => {
815
+ this.addCoupon();
816
+ });
817
+ };
567
818
 
568
- if (countryFrom == "SV") {
569
- limits.minFromValue = countryMin * usdBuy;
570
- limits.maxFromValue = countryMax * usdBuy;
571
- } else {
572
- limits.minFromValue = Math.ceil(countryMin * usdBuy);
573
- limits.maxFromValue = Math.ceil(countryMax * usdBuy);
574
- }
819
+ async addCoupon() {
820
+ let initialAmount = parseFloat(this.state.receivedValue || 0);
821
+ let plusAmount = parseFloat(this.state.plus || 0);
575
822
 
576
- if (countryTo == "SV") {
577
- limits.minToValue = countryMin * usdSell;
578
- limits.maxToValue = countryMax * usdSell;
579
- } else {
580
- limits.minToValue = Math.ceil(countryMin * usdSell);
581
- limits.maxToValue = Math.ceil(countryMax * usdSell);
582
- }
823
+ if (initialAmount == 0) return;
583
824
 
584
- return limits;
585
- };
825
+ if (this.state.couponValue == "") {
826
+ this.setState({
827
+ isValid: true,
828
+ hasValidCoupon: true,
829
+ countryError: { hasErrors: false, value: "" },
830
+ receivedValue: initialAmount - plusAmount,
831
+ couponRedeemed: false,
832
+ plus: 0,
833
+ });
834
+ return;
835
+ }
586
836
 
587
- calculateExchangeRate = (receivedValue) => {
588
- const {
589
- fromCurrencyValue,
590
- isUsdt,
591
- sendValue,
592
- isCountryFromPayPal
593
- } = this.state;
594
-
595
- if (sendValue != 0 && receivedValue != 0) {
596
- let rate = 0.00;
597
- let networkFee = 0.00;
598
- let countryFromFee = 0.00;
599
-
600
- let amountFromCalc = sendValue;
601
- let fee = this.state.calculator[this.state.fromCountryValue].fee ?
602
- this.state.calculator[this.state.fromCountryValue].fee
603
- : { type: "A", value: 0.00, enabled: false }
604
-
605
- if (fee.enabled) {
606
- countryFromFee = fee.type == "A" ? fee.value : (amountFromCalc * fee.value).toFixed(2);
607
- amountFromCalc = amountFromCalc - (networkFee + countryFromFee);
608
- }
837
+ let { data } = await this.validateCoupon(this.state.couponValue);
838
+ let { isValid, settings } = data.data;
609
839
 
610
- let amountFromUSD = fromCurrencyValue == "USD" ?
611
- amountFromCalc :
612
- parseFloat(amountFromCalc) / this.state.calculator[this.state.fromCountryValue].usdBuy;
613
-
614
- if (isUsdt) {
615
- rate = 1.00;
616
- networkFee = isCountryFromPayPal ? 2.00 : (Math.abs(amountFromUSD - receivedValue / rate).toFixed(2));
617
- } else {
618
- rate = isCountryFromPayPal ?
619
- rate = (Math.floor((receivedValue / amountFromCalc) * 100) / 100).toFixed(2) :
620
- (Math.floor((receivedValue / sendValue) * 100) / 100).toFixed(2);
621
- }
840
+ if (!isValid) {
841
+ this.setState({
842
+ isValid: false,
843
+ hasValidCoupon: false,
844
+ countryError: { hasErrors: false, value: "" },
845
+ receivedValue: initialAmount - plusAmount,
846
+ couponRedeemed: false,
847
+ plus: 0,
848
+ });
622
849
 
623
- if (rate < 1) {
624
- rate = (Math.floor((sendValue / receivedValue) * 100) / 100).toFixed(2);
625
- networkFee = (Math.abs(receivedValue * rate - amountFromUSD).toFixed(2));
626
- }
850
+ return;
851
+ }
627
852
 
628
- this.setState({
629
- exchangeRate: rate,
630
- networkFee: networkFee,
631
- countryFromFee: countryFromFee,
632
- sendValueUSD: amountFromUSD
633
- });
634
- }
635
- };
853
+ let countryFrom = data.data.settings.countryFrom;
854
+ let countryTo = data.data.settings.countryTo;
855
+
856
+ if (
857
+ countryFrom.length != 0 &&
858
+ !countryFrom.includes(this.state.fromCountryValue)
859
+ ) {
860
+ this.setState({
861
+ isValid: false,
862
+ hasValidCoupon: false,
863
+ countryError: { hasErrors: true, value: "from" },
864
+ receivedValue: initialAmount - plusAmount,
865
+ couponRedeemed: false,
866
+ plus: 0,
867
+ });
868
+ return;
869
+ }
636
870
 
637
- showExchangeRate = (receivedValue) => {
638
- const withoutFee = { amount: 0, value: 0, type: "A", amountUSD: 0, enabled: false };
639
- const {
640
- fromCurrencyValue,
641
- isUsdt,
642
- convertValue,
643
- fromExchangeRate,
644
- fees
645
- } = this.state;
646
-
647
- let convertValueCrypto = convertValue;
648
- let showTotalFees = false;
649
- let exchangeRateLabel = "x";
650
-
651
- if (convertValue != 0 && receivedValue != 0) {
652
-
653
- let feeTraund = fees.traund != null ? { ...fees.traund, enabled: true } : withoutFee;
654
- let feePaypal = fees.paypal != null ? { ...fees.paypal, enabled: true } : withoutFee;
655
-
656
- let rate = fromExchangeRate;
657
- let networkFee = 0.00;
658
- let traundFeeValue = feeTraund.enabled ? feeTraund.amount : 0.00;
659
- let paypalFeeValue = feePaypal.enabled ? feePaypal.amount : 0.00;
660
-
661
- showTotalFees = paypalFeeValue > 0;
662
- if (isUsdt) {
663
- rate = 1;
664
- networkFee = Math.abs(convertValue - receivedValue / rate);
665
- if (fromCurrencyValue != "USD") {
666
- {
667
- const { sendValue, paymentMethods } = this.state;
668
- if (paymentMethods.length && paymentMethods[0].isWallet) {
669
- networkFee = Math.abs(sendValue - Number(paymentMethods[0].amount) / fromExchangeRate)
670
- }
671
- }
672
- }
673
- convertValueCrypto = receivedValue;
674
- showTotalFees = true;
675
- }
871
+ if (
872
+ countryTo.length != 0 &&
873
+ !countryTo.includes(this.state.toCountryValue)
874
+ ) {
875
+ this.setState({
876
+ isValid: false,
877
+ hasValidCoupon: false,
878
+ countryError: { hasErrors: true, value: "to" },
879
+ receivedValue: initialAmount - plusAmount,
880
+ couponRedeemed: false,
881
+ plus: 0,
882
+ });
676
883
 
677
- if (rate < 1) {
678
- exchangeRateLabel = "÷"
679
- rate = (Math.floor((convertValue / receivedValue) * 100) / 100).toFixed(2);
680
- networkFee = Math.abs(receivedValue * rate - convertValue);
681
- }
682
- let totalFees = traundFeeValue + paypalFeeValue + networkFee;
884
+ return;
885
+ }
683
886
 
684
- this.setState({
685
- exchangeRateLabel: exchangeRateLabel,
686
- exchangeRate: rate,
687
- traundFee: traundFeeValue.toFixed(2),
688
- paypalFee: paypalFeeValue.toFixed(2),
689
- networkFee: networkFee.toFixed(2),
690
- showTotalFees: showTotalFees,
691
- totalFees: totalFees,
692
- convertValueCrypto: convertValueCrypto
693
- });
694
- }
695
- };
887
+ if (this.state.isUsdt) {
888
+ this.setState({
889
+ isValid: false,
890
+ hasValidCoupon: false,
891
+ countryError: { hasErrors: true, value: "to" },
892
+ receivedValue: initialAmount - plusAmount,
893
+ couponRedeemed: false,
894
+ plus: 0,
895
+ });
896
+ return;
897
+ }
696
898
 
697
- calculate = async (source = "from") => {
698
- this.setState({
699
- recalculate: false,
700
- isUsdt: false,
701
- exchangeRate: 0.0,
702
- couponValue: this.state.couponValue,
703
- couponRedeemed: false,
704
- reference: this.state.reference ,
705
- secretKey: this.state.secretKey,
706
- plus: 0
707
- });
708
- if (this.state.recalc) {
709
- clearTimeout(this.state.recalc);
710
- }
899
+ let receivedRate = this.state.fromCurrencyValue == "USD" ?
900
+ ((initialAmount - plusAmount) / this.state.sendValue) :
901
+ (this.state.calculator[this.state.toCountryValue].usdBuy);
711
902
 
712
- let {
713
- newAmountSender,
714
- } = applyTaxDiscount(this.state.fromCountryValue === "WLT" ? "TR" : this.state.fromCountryValue, this.state.toCountryValue, this.state.sendValue, this.state.receivedValue);
715
-
716
- let model = {
717
- coupon: this.state.couponValue,
718
- from: {
719
- amount: newAmountSender,
720
- country: this.state.fromCountryValue === "WLT" ? "TR" : this.state.fromCountryValue,
721
- currency: this.state.fromCurrencyValue,
722
- },
723
- to: {
724
- amount: this.state.receivedValue,
725
- country: this.state.toCountryValue,
726
- currency: this.state.toCurrencyValue,
727
- },
728
- };
903
+ let minAmount = parseInt(receivedRate * parseFloat(settings.minAmount || 0));
904
+ let maxAmount = parseInt(receivedRate * parseFloat(settings.maxAmount || 0));
905
+ let maxExchangeAmount = parseInt(receivedRate * parseFloat(settings.maxExchangeAmount || 0));
729
906
 
730
- if (source == "initial" || source == "end") {
731
- const url = this.ENDPOINTS.OPERATIONS.calculate(this.state.storeId || sessionStorage.getItem('storeId'), "from");
907
+ if (initialAmount < minAmount || initialAmount > maxAmount) {
908
+ this.setState({
909
+ isValid: false,
910
+ hasValidCoupon: false,
911
+ countryError: { hasErrors: true, value: "amount_from" },
912
+ receivedValue: initialAmount - plusAmount,
913
+ couponRedeemed: false,
914
+ plus: 0,
915
+ });
916
+ return;
917
+ }
732
918
 
733
- const res = await axios.post(
734
- url,
735
- model,
736
- {
737
- headers: {
738
- "x-api-access-sig": getSignatureHeader('POST', url, model,this.state.reference,this.state.secretKey)
739
- },
740
- }
741
- );
742
-
743
- if (res) {
744
- await this.setState({
745
- loadingTo: false,
746
- loadingFrom: false,
747
- recalculate: true,
748
- recalc: setTimeout(() => {
749
- this.calculate();
750
- }, 5 * 60 * 1000),
751
- });
752
- }
919
+ if (!this.state.couponRedeemed) {
920
+ let plus = 0;
753
921
 
754
- this.setState({
755
- loadingTo: false,
756
- loadingFrom: false,
757
- }, () => {
758
- this.addCoupon()
759
- });
922
+ if (settings.discountType == "A") {
923
+ plus = parseInt(receivedRate * parseFloat(settings.amount));
924
+ } else if (settings.discountType == "P") {
925
+ plus = Math.trunc(this.state.receivedValue * parseFloat(settings.amount)).toFixed(2);
926
+ }
760
927
 
761
- return;
762
- }
928
+ if (maxExchangeAmount && (parseFloat(plus) > parseFloat(maxExchangeAmount))) {
929
+ plus = parseFloat(maxExchangeAmount);
930
+ }
931
+
932
+ const newAmount = initialAmount + parseFloat(plus);
933
+
934
+ this.setState({
935
+ isValid: true,
936
+ hasValidCoupon: true,
937
+ countryError: { hasErrors: false, value: "" },
938
+ receivedValue: newAmount,
939
+ couponRedeemed: true,
940
+ plus,
941
+ });
942
+ }
943
+ }
944
+
945
+ removeCoupon = async () => {
946
+ let initialAmount = parseFloat(this.state.receivedValue || 0);
947
+ let plusAmount = parseFloat(this.state.plus || 0);
948
+
949
+ this.setState({
950
+ couponValue: "",
951
+ isValid: true,
952
+ hasValidCoupon: true,
953
+ countryError: { hasErrors: false, value: "" },
954
+ receivedValue: initialAmount - plusAmount,
955
+ couponRedeemed: false,
956
+ plus: 0,
957
+ });
958
+ }
959
+
960
+ handleSubmitForm = async () => {
961
+ this.handleIsLoading(true);
962
+
963
+ let validAmount = this.validateAmount(this.state.sendValue, "from");
964
+ let validAmountTo = this.validateAmount(this.state.receivedValue, "to");
965
+ let validForm = true;
966
+
967
+ if (!validAmount || !validAmountTo) {
968
+ this.setState({ hasError: true });
969
+ this.setState({ isValid: false });
970
+ validForm = false;
971
+ } else {
972
+ this.setState({ hasError: false });
973
+ this.setState({ isValid: true });
974
+ validForm = true;
975
+ }
763
976
 
764
- if (this.state.typingTimeout) clearTimeout(this.state.typingTimeout);
977
+ if (validForm) {
978
+ if (this.state.couponValue.length > 0) {
979
+ this.addCoupon();
980
+ }
981
+ else if (this.state.couponValue.length == 0 && this.state.couponRedeemed) {
765
982
  this.setState({
766
- typingTimeout: setTimeout(async () => {
767
- let validAmount = this.validateAmount(model.from.amount, "from");
768
- let validAmountTo = this.validateAmount(model.to.amount, "to");
769
- if (
770
- (validAmount && validAmountTo) ||
771
- (validAmount && source == "from") ||
772
- (validAmountTo && source == "to")
773
- ) {
774
- await this.setState({
775
- loadingTo: source == "from",
776
- loadingFrom: source == "to",
777
- couponValue: this.state.couponValue,
778
- couponRedeemed: false,
779
- plus: 0
780
- });
781
-
782
- if (source == "from")
783
- this.setState({
784
- receivedValue: "",
785
- });
786
- if (source == "to")
787
- this.setState({
788
- sendValue: "",
789
- });
790
- const url = this.ENDPOINTS.OPERATIONS.calculate(this.state.storeId, source)
791
-
792
- const res = await axios.post(
793
- url,
794
- model,
795
- {
796
- headers: {
797
- "x-api-access-sig": getSignatureHeader('POST', url, model,this.state.reference,this.state.secretKey)
798
- },
799
- }
800
- );
801
-
802
- if (res) {
803
- await this.setState({
804
- loadingTo: false,
805
- loadingFrom: false,
806
- recalculate: true,
807
- recalc: setTimeout(() => {
808
- this.calculate();
809
- }, 5 * 60 * 1000),
810
- });
811
- }
812
- }
813
- }, 650),
814
- }, () => {
815
- this.addCoupon();
983
+ isValid: true,
984
+ hasValidCoupon: true,
985
+ countryError: { hasErrors: false, value: "" },
986
+ receivedValue: this.state.receivedValue - this.state.plus,
987
+ couponRedeemed: false,
988
+ plus: 0,
816
989
  });
817
- };
818
-
819
- async addCoupon() {
820
- let initialAmount = parseFloat(this.state.receivedValue || 0);
821
- let plusAmount = parseFloat(this.state.plus || 0);
990
+ }
822
991
 
823
- if (initialAmount == 0) return;
992
+ //if (db) db.clearPersistence();
993
+ const firebase = await loadFirebaseDB(this.state.testMode, this.state.config);
994
+ const db = firebase.firestore();
824
995
 
825
- if (this.state.couponValue == "") {
826
- this.setState({
827
- isValid: true,
828
- hasValidCoupon: true,
829
- countryError: { hasErrors: false, value: "" },
830
- receivedValue: initialAmount - plusAmount,
831
- couponRedeemed: false,
832
- plus: 0,
996
+ if (this.state.couponRedeemed && this.state.couponValue != "") {
997
+ try {
998
+ const userFS = await db
999
+ .collection("transactions")
1000
+ .doc(this.state.storeId)
1001
+ .update({
1002
+ coupon: this.state.couponValue,
1003
+ promo: +this.state.plus,
833
1004
  });
834
- return;
1005
+ } catch (e) {
1006
+ this.setState({ hasError: true });
835
1007
  }
1008
+ }
836
1009
 
837
- let { data } = await this.validateCoupon(this.state.couponValue);
838
- let { isValid, settings } = data.data;
1010
+ if (this.state.paymentMethods && this.state.paymentMethods.length) {
1011
+ try {
1012
+ let transactionFS = await db
1013
+ .collection("transactions")
1014
+ .doc(this.state.storeId)
1015
+ .get();
1016
+
1017
+ if (transactionFS.exists) {
1018
+ let transactionData = transactionFS.data();
1019
+ let toReplace = {
1020
+ ...transactionData.to,
1021
+ paymentMethods: this.state.paymentMethods,
1022
+ };
1023
+
1024
+ await db
1025
+ .collection("transactions")
1026
+ .doc(this.state.storeId)
1027
+ .update({ to: toReplace });
1028
+ }
1029
+ } catch (e) {
1030
+ this.setState({ hasError: true });
1031
+ }
1032
+ }
1033
+ window.location.replace(`${this.props.startUrl.replace(/\/+$/, "")}/${this.state.storeId}`);
1034
+ }
1035
+ };
1036
+
1037
+ openChat = (message) => {
1038
+ // tidioChatApi.open();
1039
+ // tidioChatApi.messageFromVisitor(message);
1040
+ };
1041
+
1042
+ validateAmount = (value, origin) => {
1043
+ let valid = true;
1044
+
1045
+ if (origin == "from") {
1046
+ valid = !(
1047
+ value < this.state.minFromValue || value > this.state.maxFromValue
1048
+ );
1049
+ } else if (origin == "to") {
1050
+ valid = !(value < this.state.minToValue || value > this.state.maxToValue);
1051
+ }
839
1052
 
840
- if (!isValid) {
841
- this.setState({
842
- isValid: false,
843
- hasValidCoupon: false,
844
- countryError: { hasErrors: false, value: "" },
845
- receivedValue: initialAmount - plusAmount,
846
- couponRedeemed: false,
847
- plus: 0,
848
- });
1053
+ return valid;
1054
+ };
849
1055
 
850
- return;
851
- }
1056
+ validateEmail = (email) => {
1057
+ let valid = true;
852
1058
 
853
- let countryFrom = data.data.settings.countryFrom;
854
- let countryTo = data.data.settings.countryTo;
1059
+ if (
1060
+ !/^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(
1061
+ email
1062
+ )
1063
+ ) {
1064
+ valid = false;
1065
+ }
855
1066
 
856
- if (
857
- countryFrom.length != 0 &&
858
- !countryFrom.includes(this.state.fromCountryValue)
859
- ) {
860
- this.setState({
861
- isValid: false,
862
- hasValidCoupon: false,
863
- countryError: { hasErrors: true, value: "from" },
864
- receivedValue: initialAmount - plusAmount,
865
- couponRedeemed: false,
866
- plus: 0,
867
- });
868
- return;
869
- }
1067
+ return valid;
1068
+ };
870
1069
 
871
- if (
872
- countryTo.length != 0 &&
873
- !countryTo.includes(this.state.toCountryValue)
874
- ) {
875
- this.setState({
876
- isValid: false,
877
- hasValidCoupon: false,
878
- countryError: { hasErrors: true, value: "to" },
879
- receivedValue: initialAmount - plusAmount,
880
- couponRedeemed: false,
881
- plus: 0,
882
- });
1070
+ validateCoupon = async (cupon) => {
1071
+ const url = `${this.ENDPOINTS.OPERATIONS.validateCoupon}/${cupon}`
883
1072
 
884
- return;
1073
+ try {
1074
+ const response = await axios.get(
1075
+ url,
1076
+ {
1077
+ headers: {
1078
+ "x-api-access-sig": getSignatureHeader('GET', url, null, this.state.reference, this.state.secretKey)
1079
+ },
885
1080
  }
1081
+ );
1082
+ return response;
1083
+ } catch {
1084
+ this.handleIsLoading(false);
1085
+ }
1086
+ };
886
1087
 
887
- if (this.state.isUsdt) {
888
- this.setState({
889
- isValid: false,
890
- hasValidCoupon: false,
891
- countryError: { hasErrors: true, value: "to" },
892
- receivedValue: initialAmount - plusAmount,
893
- couponRedeemed: false,
894
- plus: 0,
895
- });
896
- return;
897
- }
1088
+ changeBank = async ({ target }) => {
898
1089
 
899
- let receivedRate = this.state.fromCurrencyValue == "USD" ?
900
- ((initialAmount - plusAmount) / this.state.sendValue) :
901
- (this.state.calculator[this.state.toCountryValue].usdBuy);
1090
+ if (!target.value) return;
902
1091
 
903
- let minAmount = parseInt(receivedRate * parseFloat(settings.minAmount || 0));
904
- let maxAmount = parseInt(receivedRate * parseFloat(settings.maxAmount || 0));
905
- let maxExchangeAmount = parseInt(receivedRate * parseFloat(settings.maxExchangeAmount || 0));
1092
+ const selected = this.state.paymentMethods.find(
1093
+ (payment) => payment.id == target.value
1094
+ );
906
1095
 
907
- if (initialAmount < minAmount || initialAmount > maxAmount) {
908
- this.setState({
909
- isValid: false,
910
- hasValidCoupon: false,
911
- countryError: { hasErrors: true, value: "amount_from" },
912
- receivedValue: initialAmount - plusAmount,
913
- couponRedeemed: false,
914
- plus: 0,
915
- });
916
- return;
917
- }
1096
+ let newOrder = this.state.paymentMethods.map((payment) => {
1097
+ if (payment.name == selected.name) payment.isActive = true;
1098
+ else payment.isActive = false;
1099
+ return payment;
1100
+ });
918
1101
 
919
- if (!this.state.couponRedeemed) {
920
- let plus = 0;
1102
+ this.setState({ isUsdt: selected.id === 'trc20' });
921
1103
 
922
- if (settings.discountType == "A") {
923
- plus = parseInt(receivedRate * parseFloat(settings.amount));
924
- } else if (settings.discountType == "P") {
925
- plus = Math.trunc(this.state.receivedValue * parseFloat(settings.amount)).toFixed(2);
926
- }
1104
+ if (selected.isWallet) {
1105
+ await this.setState({
1106
+ receivedValue: selected.amountCrypto,
1107
+ paymentMethods: this.arraymove(newOrder),
1108
+ }, () => {
1109
+ this.showExchangeRate(selected.amountCrypto)
1110
+ });
927
1111
 
928
- if (maxExchangeAmount && (parseFloat(plus) > parseFloat(maxExchangeAmount))) {
929
- plus = parseFloat(maxExchangeAmount);
930
- }
1112
+ this.updateLimits();
931
1113
 
932
- const newAmount = initialAmount + parseFloat(plus);
1114
+ return;
1115
+ }
933
1116
 
934
- this.setState({
935
- isValid: true,
936
- hasValidCoupon: true,
937
- countryError: { hasErrors: false, value: "" },
938
- receivedValue: newAmount,
939
- couponRedeemed: true,
940
- plus,
941
- });
942
- }
1117
+ await this.setState({
1118
+ receivedValue: selected.amount,
1119
+ paymentMethods: this.arraymove(newOrder),
1120
+ }, () => {
1121
+ this.showExchangeRate(selected.amount);
1122
+ });
1123
+
1124
+ this.updateLimits();
1125
+ };
1126
+
1127
+ arraymove = (array) => {
1128
+ var newArray = array.slice();
1129
+ newArray.sort(function (a) {
1130
+ return !a.isActive ? 1 : -1;
1131
+ }); // put in first
1132
+ return newArray;
1133
+ };
1134
+
1135
+ handleOnChangeFromCountry = ({ target }, option) => {
1136
+ this.setState({ isUsdt: false });
1137
+ if (option) {
1138
+ this.handleFromCountryValue(option.code);
1139
+ this.handleFromCurrencyValue(option.currency);
1140
+
1141
+ if (
1142
+ option.code == this.state.toCountryValue ||
1143
+ !this.state.calculator[option.code].countryTo[this.state.toCountryValue]
1144
+ .active
1145
+ ) {
1146
+ this.handleToCountryValue("");
1147
+ this.handleToCurrencyValue("");
1148
+ }
1149
+ } else {
1150
+ this.handleFromCountryValue(null);
1151
+ this.handleFromCurrencyValue(null);
1152
+ }
1153
+ };
1154
+
1155
+ handleOnChangeToCountry = ({ target }, option) => {
1156
+ this.setState({ isUsdt: false });
1157
+ if (option) {
1158
+ this.handleToCountryValue(option.code);
1159
+ this.handleToCurrencyValue(option.currency);
1160
+ } else {
1161
+ this.handleToCountryValue(null);
1162
+ this.handleToCurrencyValue(null);
943
1163
  }
1164
+ };
1165
+
1166
+ filterOptions = (options, { inputValue }) =>
1167
+ matchSorter(options, inputValue, { keys: ["label", "currency"] });
1168
+
1169
+ render() {
1170
+
1171
+ const classes = {
1172
+ root: {
1173
+ fontFamily: "Poppins",
1174
+ padding: "26px 21px 0 21px",
1175
+ maxWidth: 400,
1176
+ flexGrow: 1,
1177
+ borderRadius: "24px",
1178
+ borderWidth: "1px",
1179
+ backgroundColor: "#FFFFFF",
1180
+ boxShadow: "0px 4px 7px rgba(61, 71, 86, 0.52)"
1181
+ },
1182
+ labelAmount: {
1183
+ fontFamily: "Poppins",
1184
+ fontStyle: "normal",
1185
+ fontWeight: 500,
1186
+ fontSize: "16px",
1187
+ lineHeight: "20px",
1188
+ color: "#000F37",
1189
+ marginTop: "25px"
1190
+ },
1191
+ inputAmount: {
1192
+ background: "#C7CDD7",
1193
+ borderRadius: "2px"
1194
+ },
1195
+ inputAmountText: {
1196
+ marginLeft: "10px",
1197
+ fontFamily: "Poppins",
1198
+ fontStyle: "normal",
1199
+ fontWeight: 600,
1200
+ fontSize: "20px",
1201
+ lineHeight: "20px",
1202
+ color: "#000F37",
1203
+ textAlign: "center"
1204
+ },
1205
+ labelCoupon: {
1206
+ fontFamily: "Poppins",
1207
+ fontStyle: "normal",
1208
+ fontWeight: 400,
1209
+ fontSize: "15px",
1210
+ lineHeight: "20px",
1211
+ color: "#000F37"
1212
+ },
1213
+ inputCoupon: {
1214
+ background: "#A1ACBD",
1215
+ borderRadius: "2px"
1216
+ },
1217
+ inputCouponText: {
1218
+ marginLeft: "10px",
1219
+ fontFamily: "Poppins",
1220
+ fontStyle: "normal",
1221
+ fontWeight: 500,
1222
+ fontSize: "18px",
1223
+ lineHeight: "20px",
1224
+ color: "#000F37",
1225
+ textAlign: "center"
1226
+ },
1227
+ buttonStart: {
1228
+ background: "#008AFF",
1229
+ borderRadius: "12px",
1230
+ maxWidth: "100%",
1231
+ minWidth: "100%"
1232
+ },
1233
+ buttonStartDisabled: {
1234
+ background: "#C0C0C0",
1235
+ borderRadius: "12px",
1236
+ maxWidth: "100%",
1237
+ minWidth: "100%"
1238
+ },
1239
+ textButtonStart: {
1240
+ fontFamily: "Poppins",
1241
+ fontStyle: "normal",
1242
+ fontWeight: 400,
1243
+ fontSize: "16px",
1244
+ lineHeight: "20px",
1245
+ color: "#F4F4F4"
1246
+ },
1247
+ buttonRemoveCoupon: {
1248
+ background: "#000F37",
1249
+ //borderRadius: "8px",
1250
+ maxWidth: "70%",
1251
+ minWidth: "70%"
1252
+ },
1253
+ textRemoveCoupon: {
1254
+ fontFamily: "Poppins",
1255
+ fontStyle: "normal",
1256
+ fontWeight: 300,
1257
+ fontSize: "15px",
1258
+ lineHeight: "24px",
1259
+ color: "#F4F4F4"
1260
+ },
1261
+ labelUpdateTC: {
1262
+ fontFamily: "Poppins",
1263
+ fontStyle: "normal",
1264
+ fontWeight: 400,
1265
+ fontSize: "14px",
1266
+ lineHeight: "16px",
1267
+ color: "#000F37",
1268
+ textAlign: "center"
1269
+ },
1270
+ textTimeTC: {
1271
+ fontWeight: "bold",
1272
+ textAlign: "center"
1273
+ },
1274
+ divider: {
1275
+ height: 28,
1276
+ margin: 4
1277
+ },
1278
+ rootFlags: {
1279
+ fontFamily: "Poppins",
1280
+ padding: "5px 5px",
1281
+ minWidth: 100,
1282
+ //maxWidth: 150,
1283
+ borderWidth: "0px",
1284
+ },
1285
+ };
944
1286
 
945
- removeCoupon = async () => {
946
- let initialAmount = parseFloat(this.state.receivedValue || 0);
947
- let plusAmount = parseFloat(this.state.plus || 0);
1287
+ const { locale, pathname, locales } = this.props;
1288
+ const content = locale === "es" ? es : en;
1289
+ let {
1290
+ sendValue,
1291
+ receivedValue,
1292
+ couponValue,
1293
+ fromCountryValue,
1294
+ fromCurrencyValue,
1295
+ toCountryValue,
1296
+ toCurrencyValue,
1297
+ email,
1298
+ isValid,
1299
+ showCallToAction,
1300
+ minFromValue,
1301
+ maxFromValue,
1302
+ minToValue,
1303
+ maxToValue,
1304
+ plus,
1305
+ calculator,
1306
+ loadingTo,
1307
+ loadingFrom,
1308
+ banks,
1309
+ taxSender,
1310
+ taxReceiver,
1311
+ recalculate,
1312
+ paymentMethods,
1313
+ isLoading,
1314
+ hasValidCoupon,
1315
+ traundFee,
1316
+ paypalFee,
1317
+ networkFee,
1318
+ totalFees,
1319
+ convertValueCrypto,
1320
+ convertValue,
1321
+ exchangeRate,
1322
+ onlySimulation,
1323
+ } = this.state;
1324
+
1325
+ let startDisabled = loadingFrom || loadingTo || isLoading || !hasValidCoupon;
1326
+
1327
+ // if (sendValue > 0) {
1328
+ // sendValue = sendValue % 1 == 0 ? Number(sendValue).toFixed(0) : Number(sendValue).toFixed(2);
1329
+ // }
1330
+
1331
+ // if (receivedValue > 0) {
1332
+ // receivedValue = receivedValue % 1 == 0 ? Number(receivedValue).toFixed(0) : Number(receivedValue).toFixed(2);
1333
+ // }
1334
+
1335
+ if (traundFee != null && traundFee > 0) {
1336
+ traundFee = traundFee % 1 == 0 ? Number(traundFee).toFixed(0) : Number(traundFee).toFixed(2);
1337
+ }
948
1338
 
949
- this.setState({
950
- couponValue: "",
951
- isValid: true,
952
- hasValidCoupon: true,
953
- countryError: { hasErrors: false, value: "" },
954
- receivedValue: initialAmount - plusAmount,
955
- couponRedeemed: false,
956
- plus: 0,
957
- });
1339
+ if (paypalFee != null && paypalFee > 0) {
1340
+ paypalFee = paypalFee % 1 == 0 ? Number(paypalFee).toFixed(0) : Number(paypalFee).toFixed(2);
958
1341
  }
959
1342
 
960
- handleSubmitForm = async () => {
961
- this.handleIsLoading(true);
962
-
963
- let validAmount = this.validateAmount(this.state.sendValue, "from");
964
- let validAmountTo = this.validateAmount(this.state.receivedValue, "to");
965
- let validForm = true;
966
-
967
- if (!validAmount || !validAmountTo) {
968
- this.setState({ hasError: true });
969
- this.setState({ isValid: false });
970
- validForm = false;
971
- } else {
972
- this.setState({ hasError: false });
973
- this.setState({ isValid: true });
974
- validForm = true;
975
- }
976
-
977
- if (validForm) {
978
- if (this.state.couponValue.length > 0) {
979
- this.addCoupon();
980
- }
981
- else if (this.state.couponValue.length == 0 && this.state.couponRedeemed) {
982
- this.setState({
983
- isValid: true,
984
- hasValidCoupon: true,
985
- countryError: { hasErrors: false, value: "" },
986
- receivedValue: this.state.receivedValue - this.state.plus,
987
- couponRedeemed: false,
988
- plus: 0,
989
- });
990
- }
991
-
992
- //if (db) db.clearPersistence();
993
- const firebase = await loadFirebaseDB(this.state.testMode, this.state.config);
994
- const db = firebase.firestore();
995
-
996
- if (this.state.couponRedeemed && this.state.couponValue != "") {
997
- try {
998
- const userFS = await db
999
- .collection("transactions")
1000
- .doc(this.state.storeId)
1001
- .update({
1002
- coupon: this.state.couponValue,
1003
- promo: +this.state.plus,
1004
- });
1005
- } catch (e) {
1006
- this.setState({ hasError: true });
1007
- }
1008
- }
1009
-
1010
- if (this.state.paymentMethods && this.state.paymentMethods.length) {
1011
- try {
1012
- let transactionFS = await db
1013
- .collection("transactions")
1014
- .doc(this.state.storeId)
1015
- .get();
1016
-
1017
- if (transactionFS.exists) {
1018
- let transactionData = transactionFS.data();
1019
- let toReplace = {
1020
- ...transactionData.to,
1021
- paymentMethods: this.state.paymentMethods,
1022
- };
1023
-
1024
- await db
1025
- .collection("transactions")
1026
- .doc(this.state.storeId)
1027
- .update({ to: toReplace });
1028
- }
1029
- } catch (e) {
1030
- this.setState({ hasError: true });
1031
- }
1032
- }
1033
- window.location.replace(`${this.props.startUrl.replace(/\/+$/, "")}/${this.state.storeId}`);
1034
- }
1035
- };
1036
-
1037
- openChat = (message) => {
1038
- // tidioChatApi.open();
1039
- // tidioChatApi.messageFromVisitor(message);
1040
- };
1041
-
1042
- validateAmount = (value, origin) => {
1043
- let valid = true;
1044
-
1045
- if (origin == "from") {
1046
- valid = !(
1047
- value < this.state.minFromValue || value > this.state.maxFromValue
1048
- );
1049
- } else if (origin == "to") {
1050
- valid = !(value < this.state.minToValue || value > this.state.maxToValue);
1051
- }
1052
-
1053
- return valid;
1054
- };
1055
-
1056
- validateEmail = (email) => {
1057
- let valid = true;
1058
-
1059
- if (
1060
- !/^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(
1061
- email
1062
- )
1063
- ) {
1064
- valid = false;
1065
- }
1066
-
1067
- return valid;
1068
- };
1069
-
1070
- validateCoupon = async (cupon) => {
1071
- const url = `${this.ENDPOINTS.OPERATIONS.validateCoupon}/${cupon}`
1072
-
1073
- try {
1074
- const response = await axios.get(
1075
- url,
1076
- {
1077
- headers: {
1078
- "x-api-access-sig": getSignatureHeader('GET', url, null,this.state.reference,this.state.secretKey)
1079
- },
1080
- }
1081
- );
1082
- return response;
1083
- } catch {
1084
- this.handleIsLoading(false);
1085
- }
1086
- };
1087
-
1088
- changeBank = async ({ target }) => {
1089
-
1090
- if (!target.value) return;
1091
-
1092
- const selected = this.state.paymentMethods.find(
1093
- (payment) => payment.id == target.value
1094
- );
1095
-
1096
- let newOrder = this.state.paymentMethods.map((payment) => {
1097
- if (payment.name == selected.name) payment.isActive = true;
1098
- else payment.isActive = false;
1099
- return payment;
1100
- });
1101
-
1102
- this.setState({ isUsdt: selected.id === 'trc20' });
1103
-
1104
- if (selected.isWallet) {
1105
- await this.setState({
1106
- receivedValue: selected.amountCrypto,
1107
- paymentMethods: this.arraymove(newOrder),
1108
- }, () => {
1109
- this.showExchangeRate(selected.amountCrypto)
1110
- });
1111
-
1112
- this.updateLimits();
1113
-
1114
- return;
1115
- }
1116
-
1117
- await this.setState({
1118
- receivedValue: selected.amount,
1119
- paymentMethods: this.arraymove(newOrder),
1120
- }, () => {
1121
- this.showExchangeRate(selected.amount);
1122
- });
1123
-
1124
- this.updateLimits();
1125
- };
1126
-
1127
- arraymove = (array) => {
1128
- var newArray = array.slice();
1129
- newArray.sort(function (a) {
1130
- return !a.isActive ? 1 : -1;
1131
- }); // put in first
1132
- return newArray;
1133
- };
1134
-
1135
- handleOnChangeFromCountry = ({ target }, option) => {
1136
- this.setState({ isUsdt: false });
1137
- if (option) {
1138
- this.handleFromCountryValue(option.code);
1139
- this.handleFromCurrencyValue(option.currency);
1140
-
1141
- if (
1142
- option.code == this.state.toCountryValue ||
1143
- !this.state.calculator[option.code].countryTo[this.state.toCountryValue]
1144
- .active
1145
- ) {
1146
- this.handleToCountryValue("");
1147
- this.handleToCurrencyValue("");
1148
- }
1149
- } else {
1150
- this.handleFromCountryValue(null);
1151
- this.handleFromCurrencyValue(null);
1152
- }
1153
- };
1154
-
1155
- handleOnChangeToCountry = ({ target }, option) => {
1156
- this.setState({ isUsdt: false });
1157
- if (option) {
1158
- this.handleToCountryValue(option.code);
1159
- this.handleToCurrencyValue(option.currency);
1160
- } else {
1161
- this.handleToCountryValue(null);
1162
- this.handleToCurrencyValue(null);
1163
- }
1164
- };
1165
-
1166
- filterOptions = (options, { inputValue }) =>
1167
- matchSorter(options, inputValue, { keys: ["label", "currency"] });
1168
-
1169
- render() {
1170
-
1171
- const classes = {
1172
- root: {
1173
- fontFamily: "Poppins",
1174
- padding: "26px 21px 0 21px",
1175
- maxWidth: 400,
1176
- flexGrow: 1,
1177
- borderRadius: "24px",
1178
- borderWidth: "1px",
1179
- backgroundColor: "#FFFFFF",
1180
- boxShadow: "0px 4px 7px rgba(61, 71, 86, 0.52)"
1181
- },
1182
- labelAmount: {
1183
- fontFamily: "Poppins",
1184
- fontStyle: "normal",
1185
- fontWeight: 500,
1186
- fontSize: "16px",
1187
- lineHeight: "20px",
1188
- color: "#000F37",
1189
- marginTop:"25px"
1190
- },
1191
- inputAmount: {
1192
- background: "#C7CDD7",
1193
- borderRadius: "2px"
1194
- },
1195
- inputAmountText: {
1196
- marginLeft: "10px",
1197
- fontFamily: "Poppins",
1198
- fontStyle: "normal",
1199
- fontWeight: 600,
1200
- fontSize: "20px",
1201
- lineHeight: "20px",
1202
- color: "#000F37",
1203
- textAlign: "center"
1204
- },
1205
- labelCoupon: {
1206
- fontFamily: "Poppins",
1207
- fontStyle: "normal",
1208
- fontWeight: 400,
1209
- fontSize: "15px",
1210
- lineHeight: "20px",
1211
- color: "#000F37"
1212
- },
1213
- inputCoupon: {
1214
- background: "#A1ACBD",
1215
- borderRadius: "2px"
1216
- },
1217
- inputCouponText: {
1218
- marginLeft: "10px",
1219
- fontFamily: "Poppins",
1220
- fontStyle: "normal",
1221
- fontWeight: 500,
1222
- fontSize: "18px",
1223
- lineHeight: "20px",
1224
- color: "#000F37",
1225
- textAlign: "center"
1226
- },
1227
- buttonStart: {
1228
- background: "#008AFF",
1229
- borderRadius: "12px",
1230
- maxWidth: "100%",
1231
- minWidth: "100%"
1232
- },
1233
- buttonStartDisabled: {
1234
- background: "#C0C0C0",
1235
- borderRadius: "12px",
1236
- maxWidth: "100%",
1237
- minWidth: "100%"
1238
- },
1239
- textButtonStart: {
1240
- fontFamily: "Poppins",
1241
- fontStyle: "normal",
1242
- fontWeight: 400,
1243
- fontSize: "16px",
1244
- lineHeight: "20px",
1245
- color: "#F4F4F4"
1246
- },
1247
- buttonRemoveCoupon: {
1248
- background: "#000F37",
1249
- //borderRadius: "8px",
1250
- maxWidth: "70%",
1251
- minWidth: "70%"
1252
- },
1253
- textRemoveCoupon: {
1254
- fontFamily: "Poppins",
1255
- fontStyle: "normal",
1256
- fontWeight: 300,
1257
- fontSize: "15px",
1258
- lineHeight: "24px",
1259
- color: "#F4F4F4"
1260
- },
1261
- labelUpdateTC: {
1262
- fontFamily: "Poppins",
1263
- fontStyle: "normal",
1264
- fontWeight: 400,
1265
- fontSize: "14px",
1266
- lineHeight: "16px",
1267
- color: "#000F37",
1268
- textAlign: "center"
1269
- },
1270
- textTimeTC: {
1271
- fontWeight: "bold",
1272
- textAlign: "center"
1273
- },
1274
- divider: {
1275
- height: 28,
1276
- margin: 4
1277
- },
1278
- rootFlags: {
1279
- fontFamily: "Poppins",
1280
- padding: "5px 5px",
1281
- minWidth: 100,
1282
- //maxWidth: 150,
1283
- borderWidth: "0px",
1284
- },
1285
- };
1286
-
1287
- const { locale, pathname, locales } = this.props;
1288
- const content = locale === "es" ? es : en;
1289
- let {
1290
- sendValue,
1291
- receivedValue,
1292
- couponValue,
1293
- fromCountryValue,
1294
- fromCurrencyValue,
1295
- toCountryValue,
1296
- toCurrencyValue,
1297
- email,
1298
- isValid,
1299
- showCallToAction,
1300
- minFromValue,
1301
- maxFromValue,
1302
- minToValue,
1303
- maxToValue,
1304
- plus,
1305
- calculator,
1306
- loadingTo,
1307
- loadingFrom,
1308
- banks,
1309
- taxSender,
1310
- taxReceiver,
1311
- recalculate,
1312
- paymentMethods,
1313
- isLoading,
1314
- hasValidCoupon,
1315
- traundFee,
1316
- paypalFee,
1317
- networkFee,
1318
- totalFees,
1319
- convertValueCrypto,
1320
- convertValue,
1321
- exchangeRate,
1322
- onlySimulation,
1323
- } = this.state;
1324
-
1325
- let startDisabled = loadingFrom || loadingTo || isLoading || !hasValidCoupon;
1326
-
1327
- // if (sendValue > 0) {
1328
- // sendValue = sendValue % 1 == 0 ? Number(sendValue).toFixed(0) : Number(sendValue).toFixed(2);
1329
- // }
1330
-
1331
- // if (receivedValue > 0) {
1332
- // receivedValue = receivedValue % 1 == 0 ? Number(receivedValue).toFixed(0) : Number(receivedValue).toFixed(2);
1333
- // }
1334
-
1335
- if (traundFee != null && traundFee > 0) {
1336
- traundFee = traundFee % 1 == 0 ? Number(traundFee).toFixed(0) : Number(traundFee).toFixed(2);
1337
- }
1338
-
1339
- if (paypalFee != null && paypalFee > 0) {
1340
- paypalFee = paypalFee % 1 == 0 ? Number(paypalFee).toFixed(0) : Number(paypalFee).toFixed(2);
1341
- }
1342
-
1343
- if (networkFee != null && networkFee > 0) {
1344
- networkFee = networkFee % 1 == 0 ? Number(networkFee).toFixed(0) : Number(networkFee).toFixed(2);
1345
- }
1343
+ if (networkFee != null && networkFee > 0) {
1344
+ networkFee = networkFee % 1 == 0 ? Number(networkFee).toFixed(0) : Number(networkFee).toFixed(2);
1345
+ }
1346
1346
 
1347
- if (totalFees != null && totalFees > 0) {
1348
- totalFees = totalFees % 1 == 0 ? Number(totalFees).toFixed(0) : Number(totalFees).toFixed(2);
1349
- }
1347
+ if (totalFees != null && totalFees > 0) {
1348
+ totalFees = totalFees % 1 == 0 ? Number(totalFees).toFixed(0) : Number(totalFees).toFixed(2);
1349
+ }
1350
1350
 
1351
- if (convertValueCrypto != null && convertValueCrypto > 0) {
1352
- convertValueCrypto = convertValueCrypto % 1 == 0 ? Number(convertValueCrypto).toFixed(0) : Number(convertValueCrypto).toFixed(2);
1353
- }
1351
+ if (convertValueCrypto != null && convertValueCrypto > 0) {
1352
+ convertValueCrypto = convertValueCrypto % 1 == 0 ? Number(convertValueCrypto).toFixed(0) : Number(convertValueCrypto).toFixed(2);
1353
+ }
1354
1354
 
1355
- if (convertValue != null && convertValue > 0) {
1356
- convertValue = convertValue % 1 == 0 ? Number(convertValue).toFixed(0) : Number(convertValue).toFixed(2);
1357
- }
1355
+ if (convertValue != null && convertValue > 0) {
1356
+ convertValue = convertValue % 1 == 0 ? Number(convertValue).toFixed(0) : Number(convertValue).toFixed(2);
1357
+ }
1358
1358
 
1359
- if (exchangeRate != null && exchangeRate > 0) {
1360
- exchangeRate = exchangeRate % 1 == 0 ? Number(exchangeRate).toFixed(0) : Number(exchangeRate).toFixed(2);
1361
- }
1359
+ if (exchangeRate != null && exchangeRate > 0) {
1360
+ exchangeRate = exchangeRate % 1 == 0 ? Number(exchangeRate).toFixed(0) : Number(exchangeRate).toFixed(2);
1361
+ }
1362
1362
 
1363
- return (
1364
- <Fragment>
1365
- <link
1366
- href="https://fonts.googleapis.com/css2?family=Poppins:wght@500&display=swap"
1367
- rel="stylesheet"
1368
- />
1369
- <link
1370
- href="https://fonts.googleapis.com/css2?family=Poppins:wght@400&display=swap"
1371
- rel="stylesheet"
1372
- />
1373
- <Paper sx={classes.root}>
1374
- <Grid container direction="column" spacing={0}>
1375
- <Grid container direction="column" spacing={0}>
1376
- <Grid>
1377
- <Typography
1378
- sx={classes.labelAmount}
1379
- gutterBottom
1380
- variant="subtitle1"
1381
- component="div"
1382
- >
1383
- {content.landing.send_content}
1384
- </Typography>
1385
- </Grid>
1386
- <Grid size={{ xs: 12}} container>
1387
- <Grid size={{ xs: 8, md:9}}
1388
- >
1389
- <Paper sx={classes.inputAmount}>
1390
- <InputBase
1391
- id="send"
1392
- sx={classes.inputAmountText}
1393
- required
1394
- value={sendValue}
1395
- //type="number"
1396
- disabled={loadingFrom || loadingTo}
1397
- startAdornment={
1398
- <InputAdornment
1399
- position="start"
1400
- sx={{ marginTop: "0px" }}
1401
- >
1402
- <span>{loadingFrom && <CircularProgress size={18} />}</span>
1403
- </InputAdornment>
1404
- }
1405
- slotProps={{
1406
- input: { min: minFromValue, max: maxFromValue }
1407
- }}
1408
- onChange={this.handleSend}
1409
- />
1410
- </Paper>
1411
- </Grid>
1412
- <Grid size={{ xs: 4, md:3}}
1413
- >
1414
- <Autocomplete
1415
- disabled={loadingTo || loadingFrom}
1416
- options={countries.filter((country) => {
1417
- if (
1418
- calculator &&
1419
- calculator[country.code] &&
1420
- calculator[country.code].active
1421
- )
1422
- return country;
1423
- })}
1424
- sx={{
1425
- fontSize: 14,
1426
- "& > span": {
1427
- marginRight: 10,
1428
- fontSize: 18,
1429
- },
1430
- }}
1431
- value={
1432
- countries.filter(
1433
- (country) => country.code == fromCountryValue
1434
- )[0]
1435
- }
1436
- autoHighlight
1437
- getOptionLabel={(option) => `${option.currency}`}
1438
- renderOption={(props, option) => (
1439
- <Box component="li" {...props}>
1440
- <span style={{ marginRight: "5px" }}>
1441
- <FlagsHelpers code={option.code == "PE-USD" ? "PE" : option.code} />
1442
- </span>
1443
- {option.code === "WLT" ? "WLT" : option.code === "USDT"? "USDT" : option.currency}
1444
- </Box>
1445
- )}
1446
- disableClearable
1447
- renderInput={(params) => (
1448
- <Paper variant="outlined" sx={classes.rootFlags}>
1449
- <TextField
1450
- sx={{ fontSize: "15px" }}
1451
- {...params}
1452
- variant="standard"
1453
- slotProps={{
1454
- input: {
1455
- ...params.InputProps,
1456
- startAdornment: (
1457
- <FlagsHelpers
1458
- code={this.state.fromCountryValue == "PE-USD" ?
1459
- "PE" :
1460
- this.state.fromCountryValue
1461
- }>
1462
- </FlagsHelpers>
1463
- ),
1464
- disableUnderline: true,
1465
- }
1466
- }}
1467
- />
1468
- </Paper>
1469
- )}
1470
- onChange={this.handleOnChangeFromCountry}
1471
- />
1472
- </Grid>
1473
- </Grid>
1474
- <Grid size={{ xs: 12}} container>
1475
- {!isLoading && !loadingFrom && !loadingTo && (
1476
- <FormHelperText sx={{ color: "red" }}>
1477
- {(sendValue < minFromValue &&
1478
- content.landing.min_value.replace(
1479
- "minValue",
1480
- minFromValue
1481
- )) ||
1482
- (sendValue > maxFromValue &&
1483
- content.landing.max_value.replace(
1484
- "maxValue",
1485
- maxFromValue
1486
- ))}
1487
- </FormHelperText>
1488
- )}
1489
- </Grid>
1490
- </Grid>
1491
- {(!isLoading && !loadingFrom && !loadingTo) &&
1492
- <Grid size={{ xs: 12}} container direction="column">
1493
- <Grid size={{ xs: 12}} container spacing={1}>
1494
- <Grid size={{ xs: 1}}>
1495
- <Typography variant="body2" color="textSecondary"></Typography>
1496
- </Grid>
1497
- <Grid size={{ xs: 3, md: 4 }} >
1498
- <Typography
1499
- variant="body2"
1500
- color="textSecondary"
1501
- sx={{ textAlign: "right" }}
1502
- >
1503
- {traundFee}
1504
- </Typography>
1505
- </Grid>
1506
- <Grid size={{ xs: 1}}>
1507
- <Typography variant="body2" color="textSecondary">
1508
- {fromCurrencyValue}
1509
- </Typography>
1510
- </Grid>
1511
- <Grid size={{ xs: 1}}>
1512
- <Typography variant="body2" color="textSecondary">{" "}</Typography>
1513
- </Grid>
1514
- <Grid size="grow">
1515
- <Typography
1516
- variant="body2"
1517
- color="textSecondary"
1518
- sx={{ fontWeight: "bold", textAlign: "left", marginLeft: "10px" }}
1519
- >
1520
- {content.calculator.comision}
1521
- </Typography>
1522
- </Grid>
1523
- </Grid>
1524
- {this.state.isCountryFromPayPal &&
1525
- <Grid size={{ xs: 12}} container spacing={1}>
1526
- <Grid size={{ xs: 1}}>
1527
- <Typography variant="body2" color="textSecondary"></Typography>
1528
- </Grid>
1529
- <Grid size={{ xs: 3, md: 4 }} >
1363
+ return (
1364
+ <Fragment>
1365
+ <link
1366
+ href="https://fonts.googleapis.com/css2?family=Poppins:wght@500&display=swap"
1367
+ rel="stylesheet"
1368
+ />
1369
+ <link
1370
+ href="https://fonts.googleapis.com/css2?family=Poppins:wght@400&display=swap"
1371
+ rel="stylesheet"
1372
+ />
1373
+ <Paper sx={classes.root}>
1374
+ <Grid container direction="column" spacing={0}>
1375
+ <Grid container direction="column" spacing={0}>
1376
+ <Grid>
1530
1377
  <Typography
1531
- variant="body2"
1532
- color="textSecondary"
1533
- sx={{ textAlign: "right" }}
1378
+ sx={classes.labelAmount}
1379
+ gutterBottom
1380
+ variant="subtitle1"
1381
+ component="div"
1534
1382
  >
1535
- {paypalFee}
1383
+ {content.landing.send_content}
1536
1384
  </Typography>
1537
1385
  </Grid>
1538
- <Grid size={{ xs: 1}}>
1539
- <Typography variant="body2" color="textSecondary">
1540
- {fromCurrencyValue}
1541
- </Typography>
1542
- </Grid>
1543
- <Grid size={{ xs: 1}}>
1544
- <Typography variant="body2" color="textSecondary">{" "}</Typography>
1545
- </Grid>
1546
- <Grid size="grow">
1547
- <Typography
1548
- variant="body2"
1549
- color="textSecondary"
1550
- sx={{ fontWeight: "bold", textAlign: "left", marginLeft: "10px" }}
1386
+ <Grid size={{ xs: 12 }} container>
1387
+ <Grid size={{ xs: 8, md: 9 }}
1551
1388
  >
1552
- {content.calculator.paypal_fee}
1553
- </Typography>
1554
- </Grid>
1555
- </Grid>
1556
- }
1557
- {this.state.isUsdt &&
1558
- <Grid size={{ xs: 12}} container spacing={1}>
1559
- <Grid size={{ xs: 1}}>
1560
- <Typography variant="body2" color="textSecondary"></Typography>
1561
- </Grid>
1562
- <Grid size={{ xs: 3, md: 4 }}>
1563
- <Typography
1564
- variant="body2"
1565
- color="textSecondary"
1566
- sx={{ textAlign: "right" }}
1389
+ <Paper sx={classes.inputAmount}>
1390
+ <InputBase
1391
+ id="send"
1392
+ sx={classes.inputAmountText}
1393
+ required
1394
+ value={sendValue}
1395
+ //type="number"
1396
+ disabled={loadingFrom || loadingTo}
1397
+ startAdornment={
1398
+ <InputAdornment
1399
+ position="start"
1400
+ sx={{ marginTop: "0px" }}
1401
+ >
1402
+ <span>{loadingFrom && <CircularProgress size={18} />}</span>
1403
+ </InputAdornment>
1404
+ }
1405
+ slotProps={{
1406
+ input: { min: minFromValue, max: maxFromValue }
1407
+ }}
1408
+ onChange={this.handleSend}
1409
+ />
1410
+ </Paper>
1411
+ </Grid>
1412
+ <Grid size={{ xs: 4, md: 3 }}
1567
1413
  >
1568
- {networkFee}
1569
- </Typography>
1570
- </Grid>
1571
- <Grid size={{ xs: 1}}>
1572
- <Typography variant="body2" color="textSecondary">
1573
- {fromCurrencyValue}
1574
- </Typography>
1575
- </Grid>
1576
- <Grid size={{ xs: 1}}>
1577
- <Typography variant="body2" color="textSecondary">{" "}</Typography>
1414
+ <Autocomplete
1415
+ disabled={loadingTo || loadingFrom}
1416
+ options={countries.filter((country) => {
1417
+ if (
1418
+ calculator &&
1419
+ calculator[country.code] &&
1420
+ calculator[country.code].active
1421
+ )
1422
+ return country;
1423
+ })}
1424
+ sx={{
1425
+ fontSize: 14,
1426
+ "& > span": {
1427
+ marginRight: 10,
1428
+ fontSize: 18,
1429
+ },
1430
+ }}
1431
+ value={
1432
+ countries.filter(
1433
+ (country) => country.code == fromCountryValue
1434
+ )[0]
1435
+ }
1436
+ autoHighlight
1437
+ getOptionLabel={(option) => `${option.currency}`}
1438
+ renderOption={(props, option) => (
1439
+ <Box component="li" {...props}>
1440
+ <span style={{ marginRight: "5px" }}>
1441
+ <FlagsHelpers code={option.code == "PE-USD" ? "PE" : option.code} />
1442
+ </span>
1443
+ {option.code === "WLT" ? "WLT" : option.code === "USDT" ? "USDT" : option.currency}
1444
+ </Box>
1445
+ )}
1446
+ disableClearable
1447
+ renderInput={(params) => (
1448
+ <Paper variant="outlined" sx={classes.rootFlags}>
1449
+ <TextField
1450
+ sx={{ fontSize: "15px" }}
1451
+ {...params}
1452
+ variant="standard"
1453
+ slotProps={{
1454
+ input: {
1455
+ ...params.InputProps,
1456
+ startAdornment: (
1457
+ <FlagsHelpers
1458
+ code={this.state.fromCountryValue == "PE-USD" ?
1459
+ "PE" :
1460
+ this.state.fromCountryValue
1461
+ }>
1462
+ </FlagsHelpers>
1463
+ ),
1464
+ disableUnderline: true,
1465
+ }
1466
+ }}
1467
+ />
1468
+ </Paper>
1469
+ )}
1470
+ onChange={this.handleOnChangeFromCountry}
1471
+ />
1472
+ </Grid>
1578
1473
  </Grid>
1579
- <Grid size="grow">
1580
- <Typography
1581
- variant="body2"
1582
- color="textSecondary"
1583
- sx={{ fontWeight: "bold", textAlign: "left", marginLeft: "10px" }}
1584
- >
1585
- {content.calculator.tron_network_fee}
1586
- </Typography>
1474
+ <Grid size={{ xs: 12 }} container>
1475
+ {!isLoading && !loadingFrom && !loadingTo && (
1476
+ <FormHelperText sx={{ color: "red" }}>
1477
+ {(sendValue < minFromValue &&
1478
+ content.landing.min_value.replace(
1479
+ "minValue",
1480
+ minFromValue
1481
+ )) ||
1482
+ (sendValue > maxFromValue &&
1483
+ content.landing.max_value.replace(
1484
+ "maxValue",
1485
+ maxFromValue
1486
+ ))}
1487
+ </FormHelperText>
1488
+ )}
1587
1489
  </Grid>
1588
1490
  </Grid>
1589
- }
1590
- <Grid size={{ xs: 10}}>
1591
- <Divider ></Divider>
1592
- </Grid>
1593
- {taxSender > 0 &&
1594
- <>
1595
- <Grid size={{ xs: 12}} container spacing={1}>
1596
- <Grid size={{ xs: 1}}>
1597
- <Typography
1598
- variant="subtitle2"
1599
- color="textPrimary"
1600
- sx={{ fontWeight: "bold", textAlign: "right" }}
1601
- >
1602
- -
1603
- </Typography>
1604
- </Grid>
1605
- <Grid size={{ xs: 3, md: 4 }}>
1606
- <Typography
1607
- variant="subtitle2"
1608
- color="textPrimary"
1609
- sx={{ fontWeight: "bold", textAlign: "right" }}
1610
- >
1611
- {taxSender}
1612
- </Typography>
1613
- </Grid>
1614
- <Grid size={{ xs: 1}}>
1615
- <Typography
1616
- variant="subtitle2"
1617
- color="textPrimary"
1618
- sx={{ fontWeight: "bold" }}
1619
- >
1620
- {fromCurrencyValue}
1621
- </Typography>
1622
- </Grid>
1623
- <Grid size={{ xs: 1}}>
1624
- <Typography variant="subtitle2" color="textPrimary">{" "}</Typography>
1625
- </Grid>
1626
- <Grid size="grow">
1627
- <Typography
1628
- variant="subtitle2"
1629
- color="textPrimary"
1630
- sx={{ fontWeight: "bold", textAlign: "left", marginLeft: "10px" }}
1631
- >
1632
- {fromCurrencyValue == "COP" ? content?.calculator.tax_co : content?.calculator.tax_pe}
1633
- </Typography>
1634
- </Grid>
1635
- </Grid>
1636
- <Grid size={{ xs: 12}} container spacing={1}>
1637
- <Grid size={{ xs: 1}}>
1638
- <Typography
1639
- variant="subtitle2"
1640
- color="textPrimary"
1641
- sx={{ fontWeight: "bold", textAlign: "right" }}
1642
- >
1643
- =
1644
- </Typography>
1645
- </Grid>
1646
- <Grid size={{ xs: 3, md: 4 }}>
1647
- <Typography
1648
- variant="subtitle2"
1649
- color="textPrimary"
1650
- sx={{ fontWeight: "bold", textAlign: "right" }}
1651
- >
1652
- {this.state.isUsdt ? convertValueCrypto : (+convertValue).toFixed(2)}
1653
- </Typography>
1491
+ {(!isLoading && !loadingFrom && !loadingTo) &&
1492
+ <Grid size={{ xs: 12 }} container direction="column">
1493
+ <Grid size={{ xs: 12 }} container spacing={1}>
1494
+ <Grid size={{ xs: 1 }}>
1495
+ <Typography variant="body2" color="textSecondary"></Typography>
1496
+ </Grid>
1497
+ <Grid size={{ xs: 3, md: 4 }} >
1498
+ <Typography
1499
+ variant="body2"
1500
+ color="textSecondary"
1501
+ sx={{ textAlign: "right" }}
1502
+ >
1503
+ {traundFee}
1504
+ </Typography>
1505
+ </Grid>
1506
+ <Grid size={{ xs: 1 }}>
1507
+ <Typography variant="body2" color="textSecondary">
1508
+ {fromCurrencyValue}
1509
+ </Typography>
1510
+ </Grid>
1511
+ <Grid size={{ xs: 1 }}>
1512
+ <Typography variant="body2" color="textSecondary">{" "}</Typography>
1513
+ </Grid>
1514
+ <Grid size="grow">
1515
+ <Typography
1516
+ variant="body2"
1517
+ color="textSecondary"
1518
+ sx={{ fontWeight: "bold", textAlign: "left", marginLeft: "10px" }}
1519
+ >
1520
+ {content.calculator.comision}
1521
+ </Typography>
1522
+ </Grid>
1654
1523
  </Grid>
1655
- <Grid size={{ xs: 1}}>
1656
- <Typography
1657
- variant="subtitle2"
1658
- color="textPrimary"
1659
- sx={{ fontWeight: "bold" }}
1660
- >
1661
- {this.state.isUsdt ? 'USD' : fromCurrencyValue}
1662
- </Typography>
1524
+ {this.state.isCountryFromPayPal &&
1525
+ <Grid size={{ xs: 12 }} container spacing={1}>
1526
+ <Grid size={{ xs: 1 }}>
1527
+ <Typography variant="body2" color="textSecondary"></Typography>
1528
+ </Grid>
1529
+ <Grid size={{ xs: 3, md: 4 }} >
1530
+ <Typography
1531
+ variant="body2"
1532
+ color="textSecondary"
1533
+ sx={{ textAlign: "right" }}
1534
+ >
1535
+ {paypalFee}
1536
+ </Typography>
1537
+ </Grid>
1538
+ <Grid size={{ xs: 1 }}>
1539
+ <Typography variant="body2" color="textSecondary">
1540
+ {fromCurrencyValue}
1541
+ </Typography>
1542
+ </Grid>
1543
+ <Grid size={{ xs: 1 }}>
1544
+ <Typography variant="body2" color="textSecondary">{" "}</Typography>
1545
+ </Grid>
1546
+ <Grid size="grow">
1547
+ <Typography
1548
+ variant="body2"
1549
+ color="textSecondary"
1550
+ sx={{ fontWeight: "bold", textAlign: "left", marginLeft: "10px" }}
1551
+ >
1552
+ {content.calculator.paypal_fee}
1553
+ </Typography>
1554
+ </Grid>
1555
+ </Grid>
1556
+ }
1557
+ {this.state.isUsdt &&
1558
+ <Grid size={{ xs: 12 }} container spacing={1}>
1559
+ <Grid size={{ xs: 1 }}>
1560
+ <Typography variant="body2" color="textSecondary"></Typography>
1561
+ </Grid>
1562
+ <Grid size={{ xs: 3, md: 4 }}>
1563
+ <Typography
1564
+ variant="body2"
1565
+ color="textSecondary"
1566
+ sx={{ textAlign: "right" }}
1567
+ >
1568
+ {networkFee}
1569
+ </Typography>
1570
+ </Grid>
1571
+ <Grid size={{ xs: 1 }}>
1572
+ <Typography variant="body2" color="textSecondary">
1573
+ {fromCurrencyValue}
1574
+ </Typography>
1575
+ </Grid>
1576
+ <Grid size={{ xs: 1 }}>
1577
+ <Typography variant="body2" color="textSecondary">{" "}</Typography>
1578
+ </Grid>
1579
+ <Grid size="grow">
1580
+ <Typography
1581
+ variant="body2"
1582
+ color="textSecondary"
1583
+ sx={{ fontWeight: "bold", textAlign: "left", marginLeft: "10px" }}
1584
+ >
1585
+ {content.calculator.tron_network_fee}
1586
+ </Typography>
1587
+ </Grid>
1588
+ </Grid>
1589
+ }
1590
+ <Grid size={{ xs: 10 }}>
1591
+ <Divider ></Divider>
1663
1592
  </Grid>
1664
- <Grid size="grow">
1665
- <Typography variant="subtitle2" color="textPrimary" sx={{ fontWeight: "bold", textAlign: "left", marginLeft: "10px" }}>{content.calculator.receiver}</Typography>
1593
+ {taxSender > 0 &&
1594
+ <>
1595
+ <Grid size={{ xs: 12 }} container spacing={1}>
1596
+ <Grid size={{ xs: 1 }}>
1597
+ <Typography
1598
+ variant="subtitle2"
1599
+ color="textPrimary"
1600
+ sx={{ fontWeight: "bold", textAlign: "right" }}
1601
+ >
1602
+ -
1603
+ </Typography>
1604
+ </Grid>
1605
+ <Grid size={{ xs: 3, md: 4 }}>
1606
+ <Typography
1607
+ variant="subtitle2"
1608
+ color="textPrimary"
1609
+ sx={{ fontWeight: "bold", textAlign: "right" }}
1610
+ >
1611
+ {taxSender}
1612
+ </Typography>
1613
+ </Grid>
1614
+ <Grid size={{ xs: 1 }}>
1615
+ <Typography
1616
+ variant="subtitle2"
1617
+ color="textPrimary"
1618
+ sx={{ fontWeight: "bold" }}
1619
+ >
1620
+ {fromCurrencyValue}
1621
+ </Typography>
1622
+ </Grid>
1623
+ <Grid size={{ xs: 1 }}>
1624
+ <Typography variant="subtitle2" color="textPrimary">{" "}</Typography>
1625
+ </Grid>
1626
+ <Grid size="grow">
1627
+ <Typography
1628
+ variant="subtitle2"
1629
+ color="textPrimary"
1630
+ sx={{ fontWeight: "bold", textAlign: "left", marginLeft: "10px" }}
1631
+ >
1632
+ {fromCurrencyValue == "COP" ? content?.calculator.tax_co : content?.calculator.tax_pe}
1633
+ </Typography>
1634
+ </Grid>
1635
+ </Grid>
1636
+ <Grid size={{ xs: 12 }} container spacing={1}>
1637
+ <Grid size={{ xs: 1 }}>
1638
+ <Typography
1639
+ variant="subtitle2"
1640
+ color="textPrimary"
1641
+ sx={{ fontWeight: "bold", textAlign: "right" }}
1642
+ >
1643
+ =
1644
+ </Typography>
1645
+ </Grid>
1646
+ <Grid size={{ xs: 3, md: 4 }}>
1647
+ <Typography
1648
+ variant="subtitle2"
1649
+ color="textPrimary"
1650
+ sx={{ fontWeight: "bold", textAlign: "right" }}
1651
+ >
1652
+ {this.state.isUsdt ? convertValueCrypto : (+convertValue).toFixed(2)}
1653
+ </Typography>
1654
+ </Grid>
1655
+ <Grid size={{ xs: 1 }}>
1656
+ <Typography
1657
+ variant="subtitle2"
1658
+ color="textPrimary"
1659
+ sx={{ fontWeight: "bold" }}
1660
+ >
1661
+ {this.state.isUsdt ? 'USD' : fromCurrencyValue}
1662
+ </Typography>
1663
+ </Grid>
1664
+ <Grid size="grow">
1665
+ <Typography variant="subtitle2" color="textPrimary" sx={{ fontWeight: "bold", textAlign: "left", marginLeft: "10px" }}>{content.calculator.receiver}</Typography>
1666
+ </Grid>
1667
+ <Grid size="grow">
1668
+ <Typography
1669
+ variant="subtitle2"
1670
+ color="textPrimary"
1671
+ sx={{ fontWeight: "bold", textAlign: "left", marginLeft: "10px" }}
1672
+ >
1673
+ {content.calculator.we_receive}
1674
+ </Typography>
1675
+ </Grid>
1676
+ </Grid>
1677
+ </>
1678
+ }
1679
+ {this.state.showTotalFees &&
1680
+ <Grid size={{ xs: 12 }} container spacing={1}>
1681
+ <Grid size={{ xs: 1 }}>
1682
+ <Typography
1683
+ variant="subtitle2"
1684
+ color="textPrimary"
1685
+ sx={{ fontWeight: "bold", textAlign: "right" }}
1686
+ >
1687
+ -
1688
+ </Typography>
1689
+ </Grid>
1690
+ <Grid size={{ xs: 3, md: 4 }}>
1691
+ <Typography
1692
+ variant="subtitle2"
1693
+ color="textPrimary"
1694
+ sx={{ fontWeight: "bold", textAlign: "right" }}
1695
+ >
1696
+ {totalFees}
1697
+ </Typography>
1698
+ </Grid>
1699
+ <Grid size={{ xs: 1 }}>
1700
+ <Typography
1701
+ variant="subtitle2"
1702
+ color="textPrimary"
1703
+ sx={{ fontWeight: "bold" }}
1704
+ >
1705
+ {fromCurrencyValue}
1706
+ </Typography>
1707
+ </Grid>
1708
+ <Grid size={{ xs: 1 }}>
1709
+ <Typography variant="body2" color="textSecondary">{" "}</Typography>
1710
+ </Grid>
1711
+ <Grid size="grow">
1712
+ <Typography
1713
+ variant="subtitle2"
1714
+ color="textPrimary"
1715
+ sx={{ fontWeight: "bold", textAlign: "left", marginLeft: "10px" }}
1716
+ >
1717
+ {content.calculator.total_fees}
1718
+ </Typography>
1719
+ </Grid>
1720
+ </Grid>
1721
+ }
1722
+ <Grid size={{ xs: 12 }} container spacing={1}>
1723
+ <Grid size={{ xs: 1 }}>
1724
+ <Typography
1725
+ variant="subtitle2"
1726
+ color="textPrimary"
1727
+ sx={{ fontWeight: "bold", textAlign: "right" }}
1728
+ >
1729
+ {this.state.exchangeRateLabel}
1730
+ </Typography>
1731
+ </Grid>
1732
+ <Grid size={{ xs: 3, md: 4 }} >
1733
+ <Typography
1734
+ variant="subtitle2"
1735
+ color="textPrimary"
1736
+ sx={{ fontWeight: "bold", textAlign: "right" }}
1737
+ >
1738
+ {exchangeRate}
1739
+ </Typography>
1740
+ </Grid>
1741
+ <Grid size={{ xs: 1 }}>
1742
+ <Typography
1743
+ variant="subtitle2"
1744
+ color="textPrimary"
1745
+ sx={{ fontWeight: "bold" }}
1746
+ >
1747
+ {this.state.isUsdt ? 'USDT' : toCurrencyValue}
1748
+ </Typography>
1749
+ </Grid>
1750
+ <Grid size={{ xs: 1 }}>
1751
+ <Typography variant="body2" color="textSecondary">{" "}</Typography>
1752
+ </Grid>
1753
+ <Grid size="grow">
1754
+ <Typography
1755
+ variant="subtitle2"
1756
+ color="textPrimary"
1757
+ sx={{ fontWeight: "bold", textAlign: "left", marginLeft: "10px" }}
1758
+ >
1759
+ {content.calculator.exchange_rate}
1760
+ </Typography>
1761
+ </Grid>
1666
1762
  </Grid>
1667
- <Grid size="grow">
1668
- <Typography
1669
- variant="subtitle2"
1670
- color="textPrimary"
1671
- sx={{ fontWeight: "bold", textAlign: "left", marginLeft: "10px" }}
1672
- >
1673
- {content.calculator.we_receive}
1674
- </Typography>
1763
+ <Grid size={{ xs: 12 }} container spacing={1}>
1764
+ <Grid size={{ xs: 1 }}>
1765
+ <Typography
1766
+ variant="subtitle2"
1767
+ color="textPrimary"
1768
+ sx={{ fontWeight: "bold", textAlign: "right" }}
1769
+ >
1770
+ =
1771
+ </Typography>
1772
+ </Grid>
1773
+ <Grid size={{ xs: 3, md: 4 }} >
1774
+ <Typography
1775
+ variant="subtitle2"
1776
+ color="textPrimary"
1777
+ sx={{ fontWeight: "bold", textAlign: "right" }}
1778
+ >
1779
+ {this.state.isUsdt ? convertValueCrypto : (+receivedValue + taxReceiver).toFixed(2)}
1780
+ </Typography>
1781
+ </Grid>
1782
+ <Grid size={{ xs: 1 }}>
1783
+ <Typography
1784
+ variant="subtitle2"
1785
+ color="textPrimary"
1786
+ sx={{ fontWeight: "bold" }}
1787
+ >
1788
+ {this.state.isUsdt ? 'USD' : toCurrencyValue}
1789
+ </Typography>
1790
+ </Grid>
1791
+ <Grid size={{ xs: 1 }}>
1792
+ <Typography variant="body2" color="textSecondary">{" "}</Typography>
1793
+ </Grid>
1794
+ <Grid size="grow">
1795
+ <Typography
1796
+ variant="subtitle2"
1797
+ color="textPrimary"
1798
+ sx={{ fontWeight: "bold", textAlign: "left", marginLeft: "10px" }}
1799
+ >
1800
+ {content.calculator.converted_amount}
1801
+ </Typography>
1802
+ </Grid>
1675
1803
  </Grid>
1676
- </Grid>
1677
- </>
1678
- }
1679
- {this.state.showTotalFees &&
1680
- <Grid size={{ xs: 12}} container spacing={1}>
1681
- <Grid size={{ xs: 1}}>
1682
- <Typography
1683
- variant="subtitle2"
1684
- color="textPrimary"
1685
- sx={{ fontWeight: "bold", textAlign: "right" }}
1686
- >
1687
- -
1688
- </Typography>
1689
- </Grid>
1690
- <Grid size={{ xs: 3, md: 4 }}>
1691
- <Typography
1692
- variant="subtitle2"
1693
- color="textPrimary"
1694
- sx={{ fontWeight: "bold", textAlign: "right" }}
1695
- >
1696
- {totalFees}
1697
- </Typography>
1698
- </Grid>
1699
- <Grid size={{ xs: 1}}>
1700
- <Typography
1701
- variant="subtitle2"
1702
- color="textPrimary"
1703
- sx={{ fontWeight: "bold" }}
1704
- >
1705
- {fromCurrencyValue}
1706
- </Typography>
1707
- </Grid>
1708
- <Grid size={{ xs: 1}}>
1709
- <Typography variant="body2" color="textSecondary">{" "}</Typography>
1710
- </Grid>
1711
- <Grid size="grow">
1712
- <Typography
1713
- variant="subtitle2"
1714
- color="textPrimary"
1715
- sx={{ fontWeight: "bold", textAlign: "left", marginLeft: "10px" }}
1716
- >
1717
- {content.calculator.total_fees}
1718
- </Typography>
1719
- </Grid>
1720
- </Grid>
1721
- }
1722
- <Grid size={{ xs: 12}} container spacing={1}>
1723
- <Grid size={{ xs: 1}}>
1724
- <Typography
1725
- variant="subtitle2"
1726
- color="textPrimary"
1727
- sx={{ fontWeight: "bold", textAlign: "right" }}
1728
- >
1729
- {this.state.exchangeRateLabel}
1730
- </Typography>
1731
- </Grid>
1732
- <Grid size={{ xs: 3, md: 4 }} >
1733
- <Typography
1734
- variant="subtitle2"
1735
- color="textPrimary"
1736
- sx={{ fontWeight: "bold", textAlign: "right" }}
1737
- >
1738
- {exchangeRate}
1739
- </Typography>
1740
- </Grid>
1741
- <Grid size={{ xs: 1}}>
1742
- <Typography
1743
- variant="subtitle2"
1744
- color="textPrimary"
1745
- sx={{ fontWeight: "bold" }}
1746
- >
1747
- {this.state.isUsdt ? 'USDT' : toCurrencyValue}
1748
- </Typography>
1749
- </Grid>
1750
- <Grid size={{ xs: 1}}>
1751
- <Typography variant="body2" color="textSecondary">{" "}</Typography>
1752
- </Grid>
1753
- <Grid size="grow">
1754
- <Typography
1755
- variant="subtitle2"
1756
- color="textPrimary"
1757
- sx={{ fontWeight: "bold", textAlign: "left", marginLeft: "10px" }}
1758
- >
1759
- {content.calculator.exchange_rate}
1760
- </Typography>
1761
- </Grid>
1762
- </Grid>
1763
- <Grid size={{ xs: 12}} container spacing={1}>
1764
- <Grid size={{ xs: 1}}>
1765
- <Typography
1766
- variant="subtitle2"
1767
- color="textPrimary"
1768
- sx={{ fontWeight: "bold", textAlign: "right" }}
1769
- >
1770
- =
1771
- </Typography>
1772
- </Grid>
1773
- <Grid size={{ xs: 3, md: 4 }} >
1774
- <Typography
1775
- variant="subtitle2"
1776
- color="textPrimary"
1777
- sx={{ fontWeight: "bold", textAlign: "right" }}
1778
- >
1779
- {this.state.isUsdt ? convertValueCrypto : (+receivedValue + taxReceiver).toFixed(2)}
1780
- </Typography>
1781
- </Grid>
1782
- <Grid size={{ xs: 1}}>
1783
- <Typography
1784
- variant="subtitle2"
1785
- color="textPrimary"
1786
- sx={{ fontWeight: "bold" }}
1787
- >
1788
- {this.state.isUsdt ? 'USD' : toCurrencyValue}
1789
- </Typography>
1790
- </Grid>
1791
- <Grid size={{ xs: 1}}>
1792
- <Typography variant="body2" color="textSecondary">{" "}</Typography>
1793
- </Grid>
1794
- <Grid size="grow">
1795
- <Typography
1796
- variant="subtitle2"
1797
- color="textPrimary"
1798
- sx={{ fontWeight: "bold", textAlign: "left", marginLeft: "10px" }}
1799
- >
1800
- {content.calculator.converted_amount}
1801
- </Typography>
1802
- </Grid>
1803
- </Grid>
1804
1804
 
1805
- {taxReceiver > 0 &&
1806
- <Grid size={{ xs: 12}} container spacing={1}>
1807
- <Grid size={{ xs: 1}}>
1808
- <Typography
1809
- variant="subtitle2"
1810
- color="textPrimary"
1811
- sx={{ fontWeight: "bold", textAlign: "right" }}
1812
- >
1813
- -
1814
- </Typography>
1815
- </Grid>
1816
- <Grid size={{ xs: 3, md: 4 }} >
1817
- <Typography
1818
- variant="subtitle2"
1819
- color="textPrimary"
1820
- sx={{ fontWeight: "bold", textAlign: "right" }}
1821
- >
1822
- {(+taxReceiver).toFixed(2)}
1823
- </Typography>
1805
+ {taxReceiver > 0 &&
1806
+ <Grid size={{ xs: 12 }} container spacing={1}>
1807
+ <Grid size={{ xs: 1 }}>
1808
+ <Typography
1809
+ variant="subtitle2"
1810
+ color="textPrimary"
1811
+ sx={{ fontWeight: "bold", textAlign: "right" }}
1812
+ >
1813
+ -
1814
+ </Typography>
1815
+ </Grid>
1816
+ <Grid size={{ xs: 3, md: 4 }} >
1817
+ <Typography
1818
+ variant="subtitle2"
1819
+ color="textPrimary"
1820
+ sx={{ fontWeight: "bold", textAlign: "right" }}
1821
+ >
1822
+ {(+taxReceiver).toFixed(2)}
1823
+ </Typography>
1824
+ </Grid>
1825
+ <Grid size={{ xs: 1 }}>
1826
+ <Typography
1827
+ variant="subtitle2"
1828
+ color="textPrimary"
1829
+ sx={{ fontWeight: "bold" }}
1830
+ >
1831
+ {toCurrencyValue}
1832
+ </Typography>
1833
+ </Grid>
1834
+ <Grid size={{ xs: 1 }}>
1835
+ <Typography variant="body2" color="textSecondary">{" "}</Typography>
1836
+ </Grid>
1837
+ <Grid size="grow">
1838
+ <Typography
1839
+ variant="subtitle2"
1840
+ color="textPrimary"
1841
+ sx={{ fontWeight: "bold", textAlign: "left", marginLeft: "10px" }}
1842
+ >
1843
+ {toCurrencyValue == "COP" ? content?.calculator.tax_co : content?.calculator.tax_pe}
1844
+ </Typography>
1845
+ </Grid>
1846
+ </Grid>
1847
+ }
1824
1848
  </Grid>
1825
- <Grid size={{ xs: 1}}>
1849
+ }
1850
+ <br></br>
1851
+ <Grid container direction="column" >
1852
+ <Grid>
1826
1853
  <Typography
1827
- variant="subtitle2"
1828
- color="textPrimary"
1829
- sx={{ fontWeight: "bold" }}
1854
+ sx={classes.labelAmount}
1855
+ gutterBottom
1856
+ variant="subtitle1"
1857
+ component="div"
1830
1858
  >
1831
- {toCurrencyValue}
1859
+ {content.landing.receiver_content}
1832
1860
  </Typography>
1833
1861
  </Grid>
1834
- <Grid size={{ xs: 1}}>
1835
- <Typography variant="body2" color="textSecondary">{" "}</Typography>
1836
- </Grid>
1837
- <Grid size="grow">
1838
- <Typography
1839
- variant="subtitle2"
1840
- color="textPrimary"
1841
- sx={{ fontWeight: "bold", textAlign: "left", marginLeft: "10px" }}
1862
+ <Grid size={{ xs: 12 }} container>
1863
+ <Grid size={{ xs: 8, md: 9 }}
1842
1864
  >
1843
- {toCurrencyValue == "COP" ? content?.calculator.tax_co : content?.calculator.tax_pe}
1844
- </Typography>
1845
- </Grid>
1846
- </Grid>
1847
- }
1848
- </Grid>
1849
- }
1850
- <br></br>
1851
- <Grid container direction="column" >
1852
- <Grid>
1853
- <Typography
1854
- sx={classes.labelAmount}
1855
- gutterBottom
1856
- variant="subtitle1"
1857
- component="div"
1858
- >
1859
- {content.landing.receiver_content}
1860
- </Typography>
1861
- </Grid>
1862
- <Grid size={{ xs: 12}} container>
1863
- <Grid size={{ xs: 8, md:9}}
1864
- >
1865
- <Paper sx={classes.inputAmount}>
1866
- <InputBase
1867
- id="receiver"
1868
- sx={classes.inputAmountText}
1869
- //type="number"
1870
- required
1871
- value={receivedValue}
1872
- disabled={true}
1873
- startAdornment={
1874
- <InputAdornment
1875
- position="start"
1876
- >
1877
- <span>{loadingTo && <CircularProgress size={18} />}</span>
1878
- </InputAdornment>
1879
- }
1880
- endAdornment={
1881
- <InputAdornment
1882
- position="end"
1883
- >
1884
- <span sx={{
1885
- fontSize: "10px",
1886
- fontWeight: "500",
1887
- paddingTop: "15px",
1888
- paddingRight: "5px"
1889
- }}>
1890
- {
1891
- (toCountryValue == "AR" &&
1892
- paymentMethods.length &&
1893
- paymentMethods[0].isWallet &&
1894
- !loadingTo &&
1895
- !loadingFrom) ? `(${paymentMethods[0].amount} ARS)` : ''
1865
+ <Paper sx={classes.inputAmount}>
1866
+ <InputBase
1867
+ id="receiver"
1868
+ sx={classes.inputAmountText}
1869
+ //type="number"
1870
+ required
1871
+ value={receivedValue}
1872
+ disabled={true}
1873
+ startAdornment={
1874
+ <InputAdornment
1875
+ position="start"
1876
+ >
1877
+ <span>{loadingTo && <CircularProgress size={18} />}</span>
1878
+ </InputAdornment>
1896
1879
  }
1897
- </span>
1898
- </InputAdornment>
1899
- }
1900
- slotProps={{
1901
- input: { min: minFromValue, max: maxFromValue }
1902
- }}
1903
- onChange={this.handleReceived}
1904
- />
1905
- </Paper>
1906
- </Grid>
1907
- <Grid size={{ xs: 4, md:3}}
1908
- >
1909
- <Autocomplete
1910
- disabled={loadingTo || loadingFrom}
1911
- options={countries.filter((country) => {
1912
- if (
1913
- calculator &&
1914
- calculator[fromCountryValue] &&
1915
- calculator[fromCountryValue].active &&
1916
- calculator[fromCountryValue].countryTo[
1917
- country.code
1918
- ] &&
1919
- calculator[fromCountryValue].countryTo[country.code]
1920
- .active
1921
- ) {
1922
- return country;
1923
- }
1924
- })}
1925
- sx={{
1926
- fontSize: 14,
1927
- "& > span": {
1928
- marginRight: 10,
1929
- fontSize: 18,
1930
- },
1931
- }}
1932
- disableClearable
1933
- value={
1934
- countries.filter(
1935
- (country) => country.code == toCountryValue
1936
- )[0]
1937
- }
1938
- autoHighlight
1939
- getOptionLabel={(option) => `${option.currency}`}
1940
- renderOption={(props, option) => (
1941
- <Box component="li" {...props}>
1942
- <span style={{ marginRight: "5px" }}>
1943
- <FlagsHelpers code={option.code == "PE-USD" ? "PE" : option.code} />
1944
- </span>
1945
- {option.currency}
1946
- </Box>
1947
- )}
1948
- renderInput={(params) => (
1949
- <Paper variant="outlined" sx={classes.rootFlags}>
1950
- <TextField
1951
- {...params}
1952
- variant="standard"
1953
- slotProps={{
1954
- input: {
1955
- ...params.InputProps,
1956
- startAdornment: (
1957
- <FlagsHelpers
1958
- code={this.state.toCountryValue == "PE-USD" ?
1959
- "PE" : this.state.toCountryValue
1960
- }>
1961
- </FlagsHelpers>
1962
- ),
1963
- disableUnderline: true,
1880
+ endAdornment={
1881
+ <InputAdornment
1882
+ position="end"
1883
+ >
1884
+ <span sx={{
1885
+ fontSize: "10px",
1886
+ fontWeight: "500",
1887
+ paddingTop: "15px",
1888
+ paddingRight: "5px"
1889
+ }}>
1890
+ {
1891
+ (toCountryValue == "AR" &&
1892
+ paymentMethods.length &&
1893
+ paymentMethods[0].isWallet &&
1894
+ !loadingTo &&
1895
+ !loadingFrom) ? `(${paymentMethods[0].amount} ARS)` : ''
1896
+ }
1897
+ </span>
1898
+ </InputAdornment>
1964
1899
  }
1965
- }}
1966
- />
1967
- </Paper>
1968
- )}
1969
- onChange={this.handleOnChangeToCountry}
1970
- />
1971
- </Grid>
1972
- </Grid>
1973
- <Grid size={{ xs: 12}} container>
1974
- <Grid size={{ xs: 12}}>
1975
- {!isLoading && !loadingFrom && !loadingTo && (
1976
- <FormHelperText sx={{ color: "red" }}>
1977
- {(receivedValue < minToValue &&
1978
- content.landing.min_value.replace(
1979
- "minValue",
1980
- minToValue
1981
- )) ||
1982
- (receivedValue > maxToValue &&
1983
- content.landing.max_value.replace(
1984
- "maxValue",
1985
- maxToValue
1986
- ))}
1987
- </FormHelperText>
1988
- )}
1989
- </Grid>
1990
- </Grid>
1991
- {(toCountryValue == "VE" || toCountryValue == "AR") &&
1992
- paymentMethods &&
1993
- !loadingTo &&
1994
- !loadingFrom && (
1995
- <Grid size={{ xs: 12}}>
1996
- <FormControl fullWidth>
1997
- <Select
1998
- id="demo-customized-select-native"
1999
- value="Banks"
2000
- onChange={this.changeBank}
1900
+ slotProps={{
1901
+ input: { min: minFromValue, max: maxFromValue }
1902
+ }}
1903
+ onChange={this.handleReceived}
1904
+ />
1905
+ </Paper>
1906
+ </Grid>
1907
+ <Grid size={{ xs: 4, md: 3 }}
2001
1908
  >
2002
- {paymentMethods &&
2003
- paymentMethods.map((payment, index) => {
2004
- if (payment.id == "trc20") {
2005
- return <MenuItem key={payment.name + index} value={payment.id}>
2006
- Tron TRC20 ({payment.currency})
2007
- </MenuItem>
1909
+ <Autocomplete
1910
+ disabled={loadingTo || loadingFrom}
1911
+ options={countries.filter((country) => {
1912
+ if (
1913
+ calculator &&
1914
+ calculator[fromCountryValue] &&
1915
+ calculator[fromCountryValue].active &&
1916
+ calculator[fromCountryValue].countryTo[
1917
+ country.code
1918
+ ] &&
1919
+ calculator[fromCountryValue].countryTo[country.code]
1920
+ .active
1921
+ ) {
1922
+ return country;
2008
1923
  }
2009
- return <MenuItem key={payment.name + index} value={payment.id}>
2010
- {payment.label}
2011
- </MenuItem>
2012
1924
  })}
2013
- </Select>
2014
- </FormControl>
2015
- </Grid>
2016
- )
2017
- }
2018
- </Grid>
2019
- <br></br>
2020
- {!onlySimulation &&
2021
- <>
2022
- <Grid container direction="column" spacing={0}>
2023
- {this.state.hasValidCoupon && (plus != null && plus != 'undefined' && plus != 0) &&
2024
- <Grid>
2025
- <p
2026
- sx={{
2027
- textAlign: "center",
2028
- }}
2029
- >
2030
- {content.calculator.plus
2031
- .replace("amount", plus)
2032
- .replace("currency", this.state.isUsdt ? 'USDT' : toCurrencyValue)}
2033
- </p>
2034
- </Grid>
2035
- }
2036
- <Grid>
2037
- <Typography
2038
- sx={classes.labelCoupon}
2039
- gutterBottom
2040
- variant="subtitle1"
2041
- component="div"
2042
- >
2043
- {content.landing.coupon_content}
2044
- </Typography>
2045
- </Grid>
2046
- <Grid size={{ xs: 12}} container>
2047
- <Grid size={{ xs: 5}}>
2048
- <Paper sx={classes.inputCoupon}>
2049
- <InputBase
2050
- sx={classes.inputCouponText}
2051
- value={couponValue}
2052
- disabled={loadingFrom || loadingTo}
2053
- type="text"
2054
- onChange={this.handleCoupon}
1925
+ sx={{
1926
+ fontSize: 14,
1927
+ "& > span": {
1928
+ marginRight: 10,
1929
+ fontSize: 18,
1930
+ },
1931
+ }}
1932
+ disableClearable
1933
+ value={
1934
+ countries.filter(
1935
+ (country) => country.code == toCountryValue
1936
+ )[0]
1937
+ }
1938
+ autoHighlight
1939
+ getOptionLabel={(option) => `${option.currency}`}
1940
+ renderOption={(props, option) => (
1941
+ <Box component="li" {...props}>
1942
+ <span style={{ marginRight: "5px" }}>
1943
+ <FlagsHelpers code={option.code == "PE-USD" ? "PE" : option.code} />
1944
+ </span>
1945
+ {option.currency}
1946
+ </Box>
1947
+ )}
1948
+ renderInput={(params) => (
1949
+ <Paper variant="outlined" sx={classes.rootFlags}>
1950
+ <TextField
1951
+ {...params}
1952
+ variant="standard"
1953
+ slotProps={{
1954
+ input: {
1955
+ ...params.InputProps,
1956
+ startAdornment: (
1957
+ <FlagsHelpers
1958
+ code={this.state.toCountryValue == "PE-USD" ?
1959
+ "PE" : this.state.toCountryValue
1960
+ }>
1961
+ </FlagsHelpers>
1962
+ ),
1963
+ disableUnderline: true,
1964
+ }
1965
+ }}
1966
+ />
1967
+ </Paper>
1968
+ )}
1969
+ onChange={this.handleOnChangeToCountry}
2055
1970
  />
2056
- </Paper>
1971
+ </Grid>
2057
1972
  </Grid>
2058
-
2059
- {this.state.hasValidCoupon && (plus != null && plus != 'undefined' && plus != 0) &&
2060
- <Grid size={{ xs: 2}} sx={{ paddingLeft: "3px" }}>
2061
- <Tooltip title={content.calculator.remove_coupon}>
2062
- <Button
2063
- sx={classes.buttonRemoveCoupon}
2064
- onClick={this.removeCoupon}
2065
- >
2066
- <HighlightOffOutlinedIcon
2067
- sx={{ color: "white" }} />
2068
- </Button>
2069
- </Tooltip>
1973
+ <Grid size={{ xs: 12 }} container>
1974
+ <Grid size={{ xs: 12 }}>
1975
+ {!isLoading && !loadingFrom && !loadingTo && (
1976
+ <FormHelperText sx={{ color: "red" }}>
1977
+ {(receivedValue < minToValue &&
1978
+ content.landing.min_value.replace(
1979
+ "minValue",
1980
+ minToValue
1981
+ )) ||
1982
+ (receivedValue > maxToValue &&
1983
+ content.landing.max_value.replace(
1984
+ "maxValue",
1985
+ maxToValue
1986
+ ))}
1987
+ </FormHelperText>
1988
+ )}
2070
1989
  </Grid>
1990
+ </Grid>
1991
+ {(toCountryValue == "VE" || toCountryValue == "AR") &&
1992
+ paymentMethods &&
1993
+ !loadingTo &&
1994
+ !loadingFrom && (
1995
+ <Grid size={{ xs: 12 }}>
1996
+ <FormControl fullWidth>
1997
+ <Select
1998
+ id="demo-customized-select-native"
1999
+ value="Banks"
2000
+ onChange={this.changeBank}
2001
+ >
2002
+ {paymentMethods &&
2003
+ paymentMethods.map((payment, index) => {
2004
+ if (payment.id == "trc20") {
2005
+ return <MenuItem key={payment.name + index} value={payment.id}>
2006
+ Tron TRC20 ({payment.currency})
2007
+ </MenuItem>
2008
+ }
2009
+ return <MenuItem key={payment.name + index} value={payment.id}>
2010
+ {payment.label}
2011
+ </MenuItem>
2012
+ })}
2013
+ </Select>
2014
+ </FormControl>
2015
+ </Grid>
2016
+ )
2071
2017
  }
2072
2018
  </Grid>
2073
- {!this.state.hasValidCoupon && (
2074
- <Grid size={{ xs: 12}}>
2019
+ <br></br>
2020
+ {!onlySimulation &&
2021
+ <>
2022
+ <Grid container direction="column" spacing={0}>
2023
+ {this.state.hasValidCoupon && (plus != null && plus != 'undefined' && plus != 0) &&
2024
+ <Grid>
2025
+ <p
2026
+ sx={{
2027
+ textAlign: "center",
2028
+ }}
2029
+ >
2030
+ {content.calculator.plus
2031
+ .replace("amount", plus)
2032
+ .replace("currency", this.state.isUsdt ? 'USDT' : toCurrencyValue)}
2033
+ </p>
2034
+ </Grid>
2035
+ }
2036
+ <Grid>
2037
+ <Typography
2038
+ sx={classes.labelCoupon}
2039
+ gutterBottom
2040
+ variant="subtitle1"
2041
+ component="div"
2042
+ >
2043
+ {content.landing.coupon_content}
2044
+ </Typography>
2045
+ </Grid>
2046
+ <Grid size={{ xs: 12 }} container>
2047
+ <Grid size={{ xs: 5 }}>
2048
+ <Paper sx={classes.inputCoupon}>
2049
+ <InputBase
2050
+ sx={classes.inputCouponText}
2051
+ value={couponValue}
2052
+ disabled={loadingFrom || loadingTo}
2053
+ type="text"
2054
+ onChange={this.handleCoupon}
2055
+ />
2056
+ </Paper>
2057
+ </Grid>
2058
+
2059
+ {this.state.hasValidCoupon && (plus != null && plus != 'undefined' && plus != 0) &&
2060
+ <Grid size={{ xs: 2 }} sx={{ paddingLeft: "3px" }}>
2061
+ <Tooltip title={content.calculator.remove_coupon}>
2062
+ <Button
2063
+ sx={classes.buttonRemoveCoupon}
2064
+ onClick={this.removeCoupon}
2065
+ >
2066
+ <HighlightOffOutlinedIcon
2067
+ sx={{ color: "white" }} />
2068
+ </Button>
2069
+ </Tooltip>
2070
+ </Grid>
2071
+ }
2072
+ </Grid>
2073
+ {!this.state.hasValidCoupon && (
2074
+ <Grid size={{ xs: 12 }}>
2075
+ <Typography
2076
+ sx={{
2077
+ color: "red",
2078
+ textAlign: "center",
2079
+ maxWidth: "100%",
2080
+ //paddingTop: "10px"
2081
+ }}
2082
+ >
2083
+ {
2084
+ this.state.countryError.hasErrors ?
2085
+ <>
2086
+ {this.state.countryError.value == "from" ? content.calculator.invalid_coupon_country_from : ""}
2087
+ {this.state.countryError.value == "to" ? content.calculator.invalid_coupon_country_to : ""}
2088
+ {this.state.countryError.value == "amount_from" ? content.calculator.invalid_coupon_amount_from : ""}
2089
+ {this.state.countryError.value == "" ? content.calculator.invalid_coupon_message : ""}
2090
+ </>
2091
+ : ""
2092
+ }
2093
+ </Typography>
2094
+ </Grid>
2095
+ )}
2096
+ </Grid>
2097
+ <br></br>
2098
+ <Grid size={{ xs: 12 }} sx={{ marginTop: "20px", marginBottom: "10px" }}>
2099
+ <Button
2100
+ sx={startDisabled ? classes.buttonStartDisabled : classes.buttonStart}
2101
+ variant="contained"
2102
+ disabled={startDisabled}
2103
+ onClick={this.handleSubmitForm}
2104
+ >
2105
+ <Typography sx={classes.textButtonStart}>
2106
+ {content.landing.button_start}
2107
+ </Typography>
2108
+ </Button>
2109
+ </Grid>
2110
+ <br></br>
2111
+ </>
2112
+ }
2113
+ {recalculate &&
2114
+ <Grid size={{ xs: 12 }}>
2115
+ <Typography
2116
+ sx={classes.labelUpdateTC}
2117
+ >
2118
+ <Timer locale={locale} />
2119
+ </Typography>
2120
+ </Grid>
2121
+ }
2122
+ {this.state.hasError && (
2123
+ <Grid size={{ xs: 12 }}>
2075
2124
  <Typography
2076
2125
  sx={{
2077
2126
  color: "red",
2078
2127
  textAlign: "center",
2079
2128
  maxWidth: "100%",
2080
- //paddingTop: "10px"
2129
+ paddingTop: "10px"
2081
2130
  }}
2082
2131
  >
2083
- {
2084
- this.state.countryError.hasErrors ?
2085
- <>
2086
- {this.state.countryError.value == "from" ? content.calculator.invalid_coupon_country_from : ""}
2087
- {this.state.countryError.value == "to" ? content.calculator.invalid_coupon_country_to : ""}
2088
- {this.state.countryError.value == "amount_from" ? content.calculator.invalid_coupon_amount_from : ""}
2089
- {this.state.countryError.value == "" ? content.calculator.invalid_coupon_message : ""}
2090
- </>
2091
- : ""
2092
- }
2132
+ {content.error_general}
2093
2133
  </Typography>
2094
2134
  </Grid>
2095
2135
  )}
2096
- </Grid>
2097
- <br></br>
2098
- <Grid size={{ xs: 12}} sx={{ marginTop: "20px", marginBottom: "10px" }}>
2099
- <Button
2100
- sx={startDisabled ? classes.buttonStartDisabled : classes.buttonStart}
2101
- variant="contained"
2102
- disabled={startDisabled}
2103
- onClick={this.handleSubmitForm}
2104
- >
2105
- <Typography sx={classes.textButtonStart}>
2106
- {content.landing.button_start}
2136
+ <Grid size={{ xs: 12 }} sx={{ marginTop: "45px" }}>
2137
+ <Divider></Divider>
2138
+ </Grid>
2139
+ <Grid size={{ xs: 12 }} container
2140
+ direction="row"
2141
+ justifyContent="center"
2142
+ alignItems="center"
2143
+ sx={{ paddingBottom: "10px" }}>
2144
+ <Typography
2145
+ variant="subtitle1"
2146
+ >
2147
+ <span style={{ fontSize: "10px", textAlign: "center" }}>Powered by&nbsp;</span>
2148
+ <span style={{ fontWeight: "bold", textAlign: "center", fontSize: "12px", }}>Orquezta</span>
2107
2149
  </Typography>
2108
- </Button>
2150
+ </Grid>
2109
2151
  </Grid>
2110
- <br></br>
2111
- </>
2112
- }
2113
- {recalculate &&
2114
- <Grid size={{ xs: 12}}>
2115
- <Typography
2116
- sx={classes.labelUpdateTC}
2117
- >
2118
- <Timer locale={locale} />
2119
- </Typography>
2120
- </Grid>
2121
- }
2122
- {this.state.hasError && (
2123
- <Grid size={{ xs: 12}}>
2124
- <Typography
2125
- sx={{
2126
- color: "red",
2127
- textAlign: "center",
2128
- maxWidth: "100%",
2129
- paddingTop: "10px"
2130
- }}
2131
- >
2132
- {content.error_general}
2133
- </Typography>
2134
- </Grid>
2135
- )}
2136
- <Grid size={{ xs: 12}} sx={{ marginTop: "45px" }}>
2137
- <Divider></Divider>
2138
- </Grid>
2139
- <Grid size={{ xs: 12}} container
2140
- direction="row"
2141
- justifyContent="center"
2142
- alignItems="center"
2143
- sx={{ paddingBottom: "10px" }}>
2144
- <Typography
2145
- variant="subtitle1"
2146
- >
2147
- <span style={{ fontSize: "10px", textAlign: "center" }}>Powered by&nbsp;</span>
2148
- <span style={{ fontWeight: "bold", textAlign: "center", fontSize: "12px", }}>Orquezta</span>
2149
- </Typography>
2150
- </Grid>
2151
- </Grid>
2152
- </Paper>
2153
- </Fragment>
2154
- );
2155
- }
2152
+ </Paper>
2153
+ </Fragment>
2154
+ );
2155
+ }
2156
2156
  }
2157
2157
 
2158
2158
  export default Calculator;