@jetthai/cuora 1.1.15 → 1.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bundle.mjs CHANGED
@@ -3845,6 +3845,15 @@ var payment = {
3845
3845
  method: 'post',
3846
3846
  params: { transferType: 'WITHDRAW', amount },
3847
3847
  }),
3848
+ getPromotionsList: () => ({ url: `payment/v2/bankWallet/promotions`, method: 'get' }),
3849
+ applyPromotions: ({ promotionsNo, amount }) => ({
3850
+ url: `payment/v2/bankWallet/promotion/apply`,
3851
+ method: 'post',
3852
+ params: {
3853
+ promotionsNo,
3854
+ amount,
3855
+ },
3856
+ }),
3848
3857
  };
3849
3858
 
3850
3859
  var user = {
@@ -16274,11 +16283,13 @@ function manual_vn (request) {
16274
16283
  }
16275
16284
 
16276
16285
  function loadcard_vn (request) {
16286
+ const { appSecret } = request.config;
16277
16287
  return createMachine(
16278
16288
  {
16279
16289
  id: 'loadcard',
16280
16290
  initial: 'loading',
16281
16291
  context: {
16292
+ siteConfig: null,
16282
16293
  cards: [],
16283
16294
  options: [],
16284
16295
 
@@ -16289,7 +16300,7 @@ function loadcard_vn (request) {
16289
16300
 
16290
16301
  calculation: null,
16291
16302
 
16292
- paymentDetails: [],
16303
+ paymentDetail: [],
16293
16304
  currentCategory: 'loadcard',
16294
16305
  currentMethod: null,
16295
16306
  currentPayment: null,
@@ -16299,15 +16310,127 @@ function loadcard_vn (request) {
16299
16310
  invoke: {
16300
16311
  src: 'fetchInitData',
16301
16312
  onDone: {
16302
- target: 'loaded',
16303
- actions: 'setInitData',
16313
+ target: 'checking',
16314
+ actions: ['setInitData', 'preset'],
16304
16315
  },
16305
16316
  onError: {
16306
16317
  target: 'fail',
16307
16318
  },
16308
16319
  },
16309
16320
  },
16310
- loaded: {
16321
+ checking: {
16322
+ always: [{ target: 'promotionApplyMode', cond: 'isPromotionApplyMode' }, { target: 'defaultMode' }],
16323
+ },
16324
+ promotionApplyMode: {
16325
+ initial: 'loaded',
16326
+ states: {
16327
+ loaded: {
16328
+ entry: 'reset',
16329
+ on: {
16330
+ SELECT_CARD: {
16331
+ actions: 'setCard',
16332
+ },
16333
+ SELECT_AMOUNT: {
16334
+ target: 'submittable',
16335
+ actions: 'setAmount',
16336
+ },
16337
+ },
16338
+ },
16339
+ submittable: {
16340
+ on: {
16341
+ SELECT_AMOUNT: {
16342
+ actions: 'setAmount',
16343
+ },
16344
+ CONFIRM: {
16345
+ target: 'debouncing',
16346
+ },
16347
+ BACK: {
16348
+ target: 'loaded',
16349
+ },
16350
+ },
16351
+ },
16352
+ debouncing: {
16353
+ on: {
16354
+ SELECT_AMOUNT: {
16355
+ target: 'debouncing',
16356
+ actions: 'setAmount',
16357
+ },
16358
+ BACK: {
16359
+ target: 'loaded',
16360
+ },
16361
+ },
16362
+ after: {
16363
+ 1000: {
16364
+ target: 'calculating',
16365
+ },
16366
+ },
16367
+ },
16368
+ calculable: {
16369
+ entry: 'clearCalculation',
16370
+ on: {
16371
+ SELECT_AMOUNT: {
16372
+ target: 'debouncing',
16373
+ actions: 'setAmount',
16374
+ },
16375
+ CALCULATE: {
16376
+ target: 'debouncing',
16377
+ },
16378
+ BACK: {
16379
+ target: 'loaded',
16380
+ },
16381
+ },
16382
+ },
16383
+ calculating: {
16384
+ invoke: {
16385
+ src: 'fetchCalculation',
16386
+ onDone: {
16387
+ target: 'cardInfo',
16388
+ actions: 'setCalculation',
16389
+ },
16390
+ onError: {
16391
+ target: 'calculable',
16392
+ },
16393
+ },
16394
+ },
16395
+ cardInfo: {
16396
+ on: {
16397
+ INPUT_CARD_NUMBER: {
16398
+ actions: 'setCardNumber',
16399
+ },
16400
+ INPUT_SERIAL_NUMBER: {
16401
+ actions: 'setSerialNumber',
16402
+ },
16403
+ SUBMIT: {
16404
+ target: 'submitting',
16405
+ cond: 'isSubmittable',
16406
+ },
16407
+ SELECT_CARD: {
16408
+ target: 'loaded',
16409
+ actions: 'setCard',
16410
+ },
16411
+ },
16412
+ },
16413
+ submitting: {
16414
+ invoke: {
16415
+ src: 'submitDeposit',
16416
+ onDone: {
16417
+ target: 'submitted',
16418
+ },
16419
+ onError: {
16420
+ target: 'cardInfo',
16421
+ },
16422
+ },
16423
+ },
16424
+ submitted: {
16425
+ on: {
16426
+ BACK: {
16427
+ target: 'loaded',
16428
+ },
16429
+ },
16430
+ },
16431
+ },
16432
+ },
16433
+ defaultMode: {
16311
16434
  entry: 'reset',
16312
16435
  on: {
16313
16436
  SELECT_CARD: {
@@ -16326,7 +16449,7 @@ function loadcard_vn (request) {
16326
16449
  actions: 'setAmount',
16327
16450
  },
16328
16451
  BACK: {
16329
- target: 'loaded',
16452
+ target: 'defaultMode',
16330
16453
  },
16331
16454
  },
16332
16455
  after: {
@@ -16347,7 +16470,7 @@ function loadcard_vn (request) {
16347
16470
  target: 'debouncing',
16348
16471
  },
16349
16472
  BACK: {
16350
- target: 'loaded',
16473
+ target: 'defaultMode',
16351
16474
  },
16352
16475
  },
16353
16476
  },
@@ -16373,7 +16496,7 @@ function loadcard_vn (request) {
16373
16496
  target: 'cardInfo',
16374
16497
  },
16375
16498
  BACK: {
16376
- target: 'loaded',
16499
+ target: 'defaultMode',
16377
16500
  },
16378
16501
  CLEAR_CALCULATION: {
16379
16502
  target: 'debouncing',
@@ -16394,7 +16517,7 @@ function loadcard_vn (request) {
16394
16517
  cond: 'isSubmittable',
16395
16518
  },
16396
16519
  SELECT_CARD: {
16397
- target: 'loaded',
16520
+ target: 'defaultMode',
16398
16521
  actions: 'setCard',
16399
16522
  },
16400
16523
  },
@@ -16413,7 +16536,7 @@ function loadcard_vn (request) {
16413
16536
  submitted: {
16414
16537
  on: {
16415
16538
  BACK: {
16416
- target: 'loaded',
16539
+ target: 'defaultMode',
16417
16540
  },
16418
16541
  },
16419
16542
  },
@@ -16430,16 +16553,22 @@ function loadcard_vn (request) {
16430
16553
  }
16431
16554
  }),
16432
16555
  setInitData: assign((context, event) => {
16433
- const paymentDetails = event.data;
16434
- const cards = paymentDetails.filter((element) => element.category === context.currentCategory);
16556
+ const { paymentDetail } = event.data;
16557
+ const cards = paymentDetail.filter((element) => element.category === context.currentCategory);
16435
16558
  return {
16436
- paymentDetails,
16559
+ paymentDetail,
16437
16560
  cards,
16438
16561
  selectedCard: cards[0],
16439
16562
  currentMethod: cards[0].method,
16440
16563
  options: cards[0].optional,
16441
16564
  }
16442
16565
  }),
16566
+ preset: assign((context, event) => {
16567
+ const { siteConfig } = event.data;
16568
+ return {
16569
+ siteConfig,
16570
+ }
16571
+ }),
16443
16572
  setCard: assign((context, event) => {
16444
16573
  return {
16445
16574
  selectedCard: event.data,
@@ -16472,6 +16601,9 @@ function loadcard_vn (request) {
16472
16601
  }),
16473
16602
  },
16474
16603
  guards: {
16604
+ isPromotionApplyMode: (context, event) => {
16605
+ return context.siteConfig?.promotionApplyMode === '1'
16606
+ },
16475
16607
  isSubmittable: (context, event) => {
16476
16608
  const { cardNumber, serialNumber } = context;
16477
16609
  return cardNumber && serialNumber
@@ -16479,7 +16611,12 @@ function loadcard_vn (request) {
16479
16611
  },
16480
16612
  services: {
16481
16613
  fetchInitData: async (context, event) => {
16482
- return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
16614
+ const [{ config }, paymentDetail = []] = await Promise.all([
16615
+ request.send(common$1.getConfig({ appSecret })),
16616
+ request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' })),
16617
+ ]);
16618
+ const siteConfig = JSON.parse(window.atob(config));
16619
+ return { siteConfig, paymentDetail }
16483
16620
  },
16484
16621
  fetchCalculation: async (context, event) => {
16485
16622
  const { currentMethod, selectedAmount } = context;
@@ -16712,11 +16849,13 @@ function qrcode_vn (request) {
16712
16849
  }
16713
16850
 
16714
16851
  function qrcode_v2 (request) {
16852
+ const { appSecret } = request.config;
16715
16853
  return createMachine(
16716
16854
  {
16717
16855
  id: 'qrcode',
16718
16856
  initial: 'loading',
16719
16857
  context: {
16858
+ siteConfig: null,
16720
16859
  qrcodes: null,
16721
16860
  options: null,
16722
16861
 
@@ -16725,7 +16864,7 @@ function qrcode_v2 (request) {
16725
16864
 
16726
16865
  calculation: null,
16727
16866
 
16728
- paymentDetails: [],
16867
+ paymentDetail: [],
16729
16868
  currentCategory: 'qrcode',
16730
16869
  currentMethod: null,
16731
16870
 
@@ -16738,15 +16877,152 @@ function qrcode_v2 (request) {
16738
16877
  invoke: {
16739
16878
  src: 'fetchInitData',
16740
16879
  onDone: {
16741
- target: 'loaded',
16742
- actions: 'setInitData',
16880
+ target: 'checking',
16881
+ actions: ['setInitData', 'preset'],
16743
16882
  },
16744
16883
  onError: {
16745
16884
  target: 'fail',
16746
16885
  },
16747
16886
  },
16748
16887
  },
16749
- loaded: {
16888
+ checking: {
16889
+ always: [{ target: 'promotionApplyMode', cond: 'isPromotionApplyMode' }, { target: 'defaultMode' }],
16890
+ },
16891
+ promotionApplyMode: {
16892
+ initial: 'loaded',
16893
+ states: {
16894
+ loaded: {
16895
+ entry: 'reset',
16896
+ on: {
16897
+ SELECT_QRCODE: {
16898
+ actions: 'setQrcode',
16899
+ },
16900
+ SELECT_AMOUNT: [
16901
+ {
16902
+ target: 'submittable',
16903
+ actions: 'addAmount',
16904
+ cond: (context, event) => context.grandTotalEnable === 1,
16905
+ },
16906
+ {
16907
+ target: 'submittable',
16908
+ actions: 'setAmount',
16909
+ },
16910
+ ],
16911
+ KEY_IN: {
16912
+ actions: 'setAmount',
16913
+ },
16914
+ },
16915
+ },
16916
+ submittable: {
16917
+ on: {
16918
+ SELECT_AMOUNT: [
16919
+ {
16920
+ actions: 'addAmount',
16921
+ cond: (context, event) => context.grandTotalEnable === 1,
16922
+ },
16923
+ {
16924
+ actions: 'setAmount',
16925
+ },
16926
+ ],
16927
+ KEY_IN: {
16928
+ actions: 'setAmount',
16929
+ },
16930
+ CONFIRM: {
16931
+ target: 'debouncing',
16932
+ },
16933
+ BACK: {
16934
+ target: 'loaded',
16935
+ },
16936
+ },
16937
+ },
16938
+ debouncing: {
16939
+ on: {
16940
+ SELECT_AMOUNT: [
16941
+ {
16942
+ target: 'debouncing',
16943
+ actions: 'addAmount',
16944
+ cond: (context, event) => context.grandTotalEnable === 1,
16945
+ },
16946
+ {
16947
+ target: 'debouncing',
16948
+ actions: 'setAmount',
16949
+ },
16950
+ ],
16951
+ KEY_IN: {
16952
+ target: 'debouncing',
16953
+ actions: 'setAmount',
16954
+ },
16955
+ BACK: {
16956
+ target: 'loaded',
16957
+ },
16958
+ },
16959
+ after: {
16960
+ 1000: {
16961
+ target: 'calculating',
16962
+ },
16963
+ },
16964
+ },
16965
+ calculable: {
16966
+ entry: 'clearCalculation',
16967
+ on: {
16968
+ SELECT_AMOUNT: [
16969
+ {
16970
+ target: 'debouncing',
16971
+ actions: 'addAmount',
16972
+ cond: (context, event) => context.grandTotalEnable === 1,
16973
+ },
16974
+ {
16975
+ target: 'debouncing',
16976
+ actions: 'setAmount',
16977
+ },
16978
+ ],
16979
+ KEY_IN: {
16980
+ target: 'debouncing',
16981
+ actions: 'setAmount',
16982
+ },
16983
+ CALCULATE: {
16984
+ target: 'debouncing',
16985
+ },
16986
+ BACK: {
16987
+ target: 'loaded',
16988
+ },
16989
+ },
16990
+ },
16991
+ calculating: {
16992
+ invoke: {
16993
+ src: 'fetchCalculation',
16994
+ onDone: {
16995
+ target: 'submitting',
16996
+ actions: 'setCalculation',
16997
+ },
16998
+ onError: {
16999
+ target: 'calculable',
17000
+ },
17001
+ },
17002
+ },
17003
+ submitting: {
17004
+ invoke: {
17005
+ src: 'submitDeposit',
17006
+ onDone: {
17007
+ target: 'submitted',
17008
+ actions: 'setResult',
17009
+ },
17010
+ onError: {
17011
+ target: 'submittable',
17012
+ },
17013
+ },
17014
+ },
17015
+ submitted: {
17016
+ on: {
17017
+ SELECT_QRCODE: {
17018
+ target: 'loaded',
17019
+ actions: 'setQrcode',
17020
+ },
17021
+ },
17022
+ },
17023
+ },
17024
+ },
17025
+ defaultMode: {
16750
17026
  entry: 'reset',
16751
17027
  on: {
16752
17028
  SELECT_QRCODE: {
@@ -16787,7 +17063,7 @@ function qrcode_v2 (request) {
16787
17063
  actions: 'setAmount',
16788
17064
  },
16789
17065
  BACK: {
16790
- target: 'loaded',
17066
+ target: 'defaultMode',
16791
17067
  },
16792
17068
  },
16793
17069
  after: {
@@ -16819,7 +17095,7 @@ function qrcode_v2 (request) {
16819
17095
  target: 'debouncing',
16820
17096
  },
16821
17097
  BACK: {
16822
- target: 'loaded',
17098
+ target: 'defaultMode',
16823
17099
  },
16824
17100
  },
16825
17101
  },
@@ -16856,7 +17132,7 @@ function qrcode_v2 (request) {
16856
17132
  target: 'submitting',
16857
17133
  },
16858
17134
  BACK: {
16859
- target: 'loaded',
17135
+ target: 'defaultMode',
16860
17136
  },
16861
17137
  CLEAR_CALCULATION: {
16862
17138
  target: 'debouncing',
@@ -16879,7 +17155,7 @@ function qrcode_v2 (request) {
16879
17155
  submitted: {
16880
17156
  on: {
16881
17157
  SELECT_QRCODE: {
16882
- target: 'loaded',
17158
+ target: 'defaultMode',
16883
17159
  actions: 'setQrcode',
16884
17160
  },
16885
17161
  },
@@ -16895,11 +17171,11 @@ function qrcode_v2 (request) {
16895
17171
  }
16896
17172
  }),
16897
17173
  setInitData: assign((context, event) => {
16898
- const paymentDetails = event.data;
16899
- const qrcodes = paymentDetails.filter((element) => element.category === context.currentCategory);
17174
+ const { paymentDetail } = event.data;
17175
+ const qrcodes = paymentDetail.filter((element) => element.category === context.currentCategory);
16900
17176
 
16901
17177
  return {
16902
- paymentDetails,
17178
+ paymentDetail,
16903
17179
  qrcodes,
16904
17180
  selectedQrcode: qrcodes[0],
16905
17181
  currentMethod: qrcodes[0].method,
@@ -16907,6 +17183,12 @@ function qrcode_v2 (request) {
16907
17183
  grandTotalEnable: qrcodes[0].grandTotalEnable,
16908
17184
  }
16909
17185
  }),
17186
+ preset: assign((context, event) => {
17187
+ const { siteConfig } = event.data;
17188
+ return {
17189
+ siteConfig,
17190
+ }
17191
+ }),
16910
17192
  setQrcode: assign((context, event) => {
16911
17193
  return {
16912
17194
  selectedQrcode: event.data,
@@ -16937,9 +17219,19 @@ function qrcode_v2 (request) {
16937
17219
  }
16938
17220
  }),
16939
17221
  },
17222
+ guards: {
17223
+ isPromotionApplyMode: (context, event) => {
17224
+ return context.siteConfig?.promotionApplyMode === '1'
17225
+ },
17226
+ },
16940
17227
  services: {
16941
17228
  fetchInitData: async (context, event) => {
16942
- return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
17229
+ const [{ config }, paymentDetail = []] = await Promise.all([
17230
+ request.send(common$1.getConfig({ appSecret })),
17231
+ request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' })),
17232
+ ]);
17233
+ const siteConfig = JSON.parse(window.atob(config));
17234
+ return { siteConfig, paymentDetail }
16943
17235
  },
16944
17236
  fetchCalculation: async (context, event) => {
16945
17237
  const { currentMethod, selectedAmount } = context;
@@ -17833,11 +18125,13 @@ function crypto (request) {
17833
18125
  }
17834
18126
 
17835
18127
  function crypto_button (request) {
18128
+ const { appSecret } = request.config;
17836
18129
  return createMachine(
17837
18130
  {
17838
18131
  id: 'crypro_button',
17839
18132
  initial: 'loading',
17840
18133
  context: {
18134
+ siteConfig: null,
17841
18135
  paymentDetails: [],
17842
18136
 
17843
18137
  channels: [],
@@ -17861,17 +18155,127 @@ function crypto_button (request) {
17861
18155
  states: {
17862
18156
  loading: {
17863
18157
  invoke: {
17864
- src: 'fetchPayments',
18158
+ src: 'fetchInitData',
17865
18159
  onDone: {
17866
- target: 'loaded',
17867
- actions: 'setCryptos',
18160
+ target: 'checking',
18161
+ actions: ['setInitData', 'preset'],
17868
18162
  },
17869
18163
  onError: {
17870
18164
  target: 'fail',
17871
18165
  },
17872
18166
  },
17873
18167
  },
17874
- loaded: {
18168
+ checking: {
18169
+ always: [{ target: 'promotionApplyMode', cond: 'isPromotionApplyMode' }, { target: 'defaultMode' }],
18170
+ },
18171
+ promotionApplyMode: {
18172
+ initial: 'loaded',
18173
+ states: {
18174
+ loaded: {
18175
+ entry: 'reset',
18176
+ on: {
18177
+ SET_CHANNEL: {
18178
+ actions: 'setChannel',
18179
+ },
18180
+ SET_CRYPTO: {
18181
+ actions: 'setCrypto',
18182
+ },
18183
+ SET_NETWORK: {
18184
+ actions: 'setNetwork',
18185
+ },
18186
+ SET_ADDRESS: {
18187
+ actions: 'setAddress',
18188
+ },
18189
+ CONFIRM: {
18190
+ target: 'selecting',
18191
+ cond: 'isConfirmable',
18192
+ },
18193
+ },
18194
+ },
18195
+ selecting: {
18196
+ entry: 'reset',
18197
+ on: {
18198
+ SELECT_AMOUNT: [
18199
+ {
18200
+ actions: 'addAmount',
18201
+ cond: (context, event) => context.grandTotalEnable === 1,
18202
+ },
18203
+ {
18204
+ actions: 'setAmount',
18205
+ },
18206
+ ],
18207
+ KEY_IN: {
18208
+ actions: 'setAmount',
18209
+ },
18210
+ SUBMIT: {
18211
+ target: 'debouncing',
18212
+ },
18213
+ BACK: {
18214
+ target: 'loaded',
18215
+ },
18216
+ CLEAR_ALL: {
18217
+ actions: 'reset',
18218
+ },
18219
+ },
18220
+ },
18221
+ debouncing: {
18222
+ on: {
18223
+ SELECT_AMOUNT: [
18224
+ {
18225
+ target: 'debouncing',
18226
+ actions: 'addAmount',
18227
+ cond: (context, event) => context.grandTotalEnable === 1,
18228
+ },
18229
+ {
18230
+ target: 'debouncing',
18231
+ actions: 'setAmount',
18232
+ },
18233
+ ],
18234
+ KEY_IN: {
18235
+ target: 'debouncing',
18236
+ actions: 'setAmount',
18237
+ },
18238
+ BACK: {
18239
+ target: 'loaded',
18240
+ },
18241
+ CLEAR_ALL: {
18242
+ actions: 'reset',
18243
+ },
18244
+ },
18245
+ after: {
18246
+ 1000: {
18247
+ target: 'calculating',
18248
+ },
18249
+ },
18250
+ },
18251
+ calculating: {
18252
+ invoke: {
18253
+ src: 'fetchCalculation',
18254
+ onDone: {
18255
+ target: 'submitting',
18256
+ actions: 'setCalculation',
18257
+ },
18258
+ onError: {
18259
+ target: 'selecting',
18260
+ actions: 'reset',
18261
+ },
18262
+ },
18263
+ },
18264
+ submitting: {
18265
+ invoke: {
18266
+ src: 'submitDeposit',
18267
+ onDone: {
18268
+ target: '#crypro_button.submitted',
18269
+ actions: 'setResult',
18270
+ },
18271
+ onError: {
18272
+ target: 'selecting',
18273
+ },
18274
+ },
18275
+ },
18276
+ },
18277
+ },
18278
+ defaultMode: {
17875
18279
  on: {
17876
18280
  SET_CHANNEL: {
17877
18281
  actions: 'setChannel',
@@ -17911,7 +18315,7 @@ function crypto_button (request) {
17911
18315
  actions: 'setAmount',
17912
18316
  },
17913
18317
  BACK: {
17914
- target: 'loaded',
18318
+ target: 'defaultMode',
17915
18319
  },
17916
18320
  },
17917
18321
  },
@@ -18006,8 +18410,9 @@ function crypto_button (request) {
18006
18410
  calculation: null,
18007
18411
  }
18008
18412
  }),
18009
- setCryptos: assign((context, event) => {
18010
- const cryptos = event.data?.map?.((crypto) => ({ ...crypto, label: crypto.channel, value: crypto.method, icon: crypto.channel })) || [];
18413
+ setInitData: assign((context, event) => {
18414
+ const { paymentDetail } = event.data;
18415
+ const cryptos = paymentDetail?.map?.((crypto) => ({ ...crypto, label: crypto.channel, value: crypto.method, icon: crypto.channel })) || [];
18011
18416
  const currentPayment = cryptos.find((element) => element.category === context.currentCategory);
18012
18417
  const channels = cryptos.map((item, i) => ({ ...item, label: `Channel ${padStart_1(String(i + 1), 2, '0')}`, icon: 'channel' }));
18013
18418
  const defaultNetworks =
@@ -18031,6 +18436,12 @@ function crypto_button (request) {
18031
18436
  options,
18032
18437
  }
18033
18438
  }),
18439
+ preset: assign((context, event) => {
18440
+ const { siteConfig } = event.data;
18441
+ return {
18442
+ siteConfig,
18443
+ }
18444
+ }),
18034
18445
  setChannel: assign((context, event) => {
18035
18446
  const { cryptos } = context;
18036
18447
  const selectedCrypto = cryptos.find((crypto) => crypto.method === event.data.value);
@@ -18110,6 +18521,9 @@ function crypto_button (request) {
18110
18521
  }),
18111
18522
  },
18112
18523
  guards: {
18524
+ isPromotionApplyMode: (context, event) => {
18525
+ return context.siteConfig?.promotionApplyMode === '1'
18526
+ },
18113
18527
  isConfirmable: (context, event) => {
18114
18528
  const { selectedCrypto, selectedNetwork } = context;
18115
18529
  return selectedCrypto && selectedNetwork
@@ -18120,8 +18534,13 @@ function crypto_button (request) {
18120
18534
  },
18121
18535
  },
18122
18536
  services: {
18123
- fetchPayments: async (context, event) => {
18124
- return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
18537
+ fetchInitData: async (context, event) => {
18538
+ const [{ config }, paymentDetail = []] = await Promise.all([
18539
+ request.send(common$1.getConfig({ appSecret })),
18540
+ request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' })),
18541
+ ]);
18542
+ const siteConfig = JSON.parse(window.atob(config));
18543
+ return { siteConfig, paymentDetail }
18125
18544
  },
18126
18545
  fetchCalculation: async (context, event) => {
18127
18546
  const { selectedCrypto, selectedAmount } = context;
@@ -19693,6 +20112,142 @@ function vip_table (request) {
19693
20112
  )
19694
20113
  }
19695
20114
 
20115
+ function promotions (request) {
20116
+ return createMachine(
20117
+ {
20118
+ id: 'promotions',
20119
+ initial: 'loading',
20120
+ context: {
20121
+ noBonus: {
20122
+ promotionsNo: 'No Bonus',
20123
+ title: 'No Bonus',
20124
+ adSmallUrl: [
20125
+ {
20126
+ url: '~/assets/images/deposit/deposit_img_nobonus_normal.png',
20127
+ name: 'No Bonus',
20128
+ },
20129
+ ],
20130
+ descrip: 'no_bonus',
20131
+ minimumAmount: 0,
20132
+ turnoverLimitMultiple: 1,
20133
+ promotionDetail: [],
20134
+ withdrawLimitDetail: [],
20135
+ limitGameDetail: [],
20136
+ },
20137
+ oldTargetTurnoverLimit: 0,
20138
+ newTargetTurnoverLimit: 0,
20139
+ promotionsList: [],
20140
+ selectedPromo: {},
20141
+ joinedPromotion: null,
20142
+ },
20143
+ states: {
20144
+ loading: {
20145
+ invoke: {
20146
+ src: 'fetchInitData',
20147
+ onDone: {
20148
+ target: 'loaded',
20149
+ actions: 'setInitData',
20150
+ },
20151
+ onError: {
20152
+ target: 'fail',
20153
+ },
20154
+ },
20155
+ },
20156
+ loaded: {
20157
+ on: {
20158
+ SELECT_PROMO: {
20159
+ actions: ['reset', 'setSelectedPromo'],
20160
+ },
20161
+ SET_AMOUNT: {
20162
+ actions: 'setAmount',
20163
+ },
20164
+ JOIN: {
20165
+ target: 'check',
20166
+ cond: 'isValidAmount',
20167
+ },
20168
+ },
20169
+ },
20170
+ check: {
20171
+ entry: 'preset',
20172
+ on: {
20173
+ CONFIRM: {
20174
+ target: 'joinning',
20175
+ },
20176
+ BACK: {
20177
+ target: 'loaded',
20178
+ },
20179
+ },
20180
+ },
20181
+ joinning: {
20182
+ invoke: {
20183
+ src: 'applyPromotion',
20184
+ onDone: {
20185
+ target: 'joined',
20186
+ },
20187
+ onError: {
20188
+ target: 'fail',
20189
+ },
20190
+ },
20191
+ },
20192
+ joined: {},
20193
+ fail: {},
20194
+ },
20195
+ },
20196
+ {
20197
+ actions: {
20198
+ setInitData: assign((context, event) => {
20199
+ const { userInfo, promotionsList } = event.data;
20200
+ const { noBonus } = context;
20201
+ return {
20202
+ promotionsList,
20203
+ userInfo,
20204
+ selectedPromo: noBonus,
20205
+ }
20206
+ }),
20207
+ setSelectedPromo: assign((context, event) => {
20208
+ return {
20209
+ selectedPromo: event.data,
20210
+ }
20211
+ }),
20212
+ setAmount: assign((context, event) => {
20213
+ return {
20214
+ amount: event.data,
20215
+ }
20216
+ }),
20217
+ reset: assign((context, event) => {
20218
+ return {
20219
+ amount: null,
20220
+ }
20221
+ }),
20222
+ preset: assign((context, event) => {
20223
+ const { userInfo, selectedPromo, amount } = context;
20224
+ const { turnoverLimitMultiple } = selectedPromo;
20225
+ return {
20226
+ oldTargetTurnoverLimit: userInfo.target_withdraw_limit,
20227
+ newTargetTurnoverLimit: parseFloat(`${amount}`) * parseFloat(`${turnoverLimitMultiple}`),
20228
+ }
20229
+ }),
20230
+ },
20231
+ guards: {
20232
+ isValidAmount: (context, event) => {
20233
+ const { selectedPromo, amount } = context;
20234
+ return selectedPromo.minimumAmount <= amount
20235
+ },
20236
+ },
20237
+ services: {
20238
+ fetchInitData: async (context, event) => {
20239
+ const [userInfo, promotionsList] = await Promise.all([request.send(user.getUserInfo()), request.send(payment.getPromotionsList())]);
20240
+ return { userInfo, promotionsList }
20241
+ },
20242
+ applyPromotion: async (context, event) => {
20243
+ const { selectedPromo, amount } = context;
20244
+ return await request.send(payment.applyPromotions({ promotionsNo: selectedPromo.promotionsNo, amount: parseFloat(amount) }))
20245
+ },
20246
+ },
20247
+ }
20248
+ )
20249
+ }
20250
+
19696
20251
  var index$1 = {
19697
20252
  ...activity,
19698
20253
  auth,
@@ -19730,6 +20285,7 @@ var index$1 = {
19730
20285
  auth_otp_v2,
19731
20286
  auth_otp_v3,
19732
20287
  vip_table,
20288
+ promotions,
19733
20289
  };
19734
20290
 
19735
20291
  // const pickBy = require('lodash/pickBy')