@jetthai/cuora 1.0.307-dev-2 → 1.1.0

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.
Files changed (111) hide show
  1. package/CHANGELOG.md +3 -854
  2. package/README.md +0 -6
  3. package/dist/bundle.mjs +18461 -0
  4. package/package.json +9 -6
  5. package/rollup.config.js +16 -0
  6. package/src/api/activity.js +2 -43
  7. package/src/api/auth.js +7 -22
  8. package/src/api/common.js +1 -3
  9. package/src/api/game.js +7 -20
  10. package/src/api/mailbox.js +5 -9
  11. package/src/api/payment.js +19 -167
  12. package/src/api/user.js +0 -7
  13. package/src/machine/activity/activity.js +26 -111
  14. package/src/machine/activity/{friend_invite_friends_activity.js → affiliate_invite_friends_activity.js} +41 -70
  15. package/src/machine/activity/continue_deposit_activity.js +2 -11
  16. package/src/machine/activity/deposit_activity.js +4 -13
  17. package/src/machine/activity/diamond_shop_activity_vn.js +89 -54
  18. package/src/machine/activity/fafafa_activity.js +19 -34
  19. package/src/machine/activity/index.js +4 -22
  20. package/src/machine/activity/invite_friends_activity.js +14 -14
  21. package/src/machine/activity/ranking_activity.js +2 -11
  22. package/src/machine/activity/sign_in_activity.js +14 -21
  23. package/src/machine/activity/specify_bets_activity.js +3 -25
  24. package/src/machine/activity/specify_turnover_activity.js +3 -25
  25. package/src/machine/activity/time_bomb_activity.js +2 -11
  26. package/src/machine/auth.js +21 -146
  27. package/src/machine/auth_otp.js +201 -0
  28. package/src/machine/auth_otp_v2.js +4 -10
  29. package/src/machine/auth_otp_v3.js +3 -11
  30. package/src/machine/bank_binding.js +12 -112
  31. package/src/machine/common.js +25 -113
  32. package/src/machine/deposit/crypto.js +29 -50
  33. package/src/machine/deposit/crypto_button.js +39 -174
  34. package/src/machine/deposit/deposit_fc.js +5 -8
  35. package/src/machine/deposit/direct.js +16 -111
  36. package/src/machine/deposit/index.js +2 -43
  37. package/src/machine/deposit/loadcard_vn.js +43 -191
  38. package/src/machine/deposit/manual_vn.js +60 -182
  39. package/src/machine/deposit/qrcode_v2.js +52 -285
  40. package/src/machine/deposit/qrcode_vn.js +206 -0
  41. package/src/machine/game.js +285 -0
  42. package/src/machine/game_favorite.js +123 -0
  43. package/src/machine/game_favorite_v2.js +28 -74
  44. package/src/machine/game_search.js +244 -0
  45. package/src/machine/game_search_v2.js +24 -64
  46. package/src/machine/game_v2.js +356 -0
  47. package/src/machine/inbox.js +34 -259
  48. package/src/machine/index.js +17 -26
  49. package/src/machine/leaderboard.js +8 -31
  50. package/src/machine/reward.js +7 -74
  51. package/src/machine/setting.js +2 -5
  52. package/src/machine/side_v2.js +28 -33
  53. package/src/machine/user_sign_up.js +17 -117
  54. package/src/machine/{withdraw/withdraw_crypto.js → withdraw_crypto.js} +69 -220
  55. package/src/machine/{withdraw/withdraw_fc.js → withdraw_fc.js} +2 -2
  56. package/src/machine/{withdraw/withdraw_amb.js → withdraw_vn.js} +78 -146
  57. package/src/request/request.js +5 -10
  58. package/src/util/constant.js +1 -19
  59. package/src/util/deviceToken.js +8 -18
  60. package/src/util/index.js +1 -2
  61. package/src/util/storage.js +22 -22
  62. package/.husky/pre-commit +0 -4
  63. package/.prettierignore +0 -1
  64. package/src/lib/fingerprint.js +0 -9779
  65. package/src/machine/activity/activity_cash.js +0 -159
  66. package/src/machine/activity/cash_rain_activity.js +0 -153
  67. package/src/machine/activity/diamond_shop_activity_cash.js +0 -179
  68. package/src/machine/activity/instant_rebate_activity.js +0 -195
  69. package/src/machine/activity/jackpot.js +0 -74
  70. package/src/machine/activity/otp_verified_activity.js +0 -74
  71. package/src/machine/activity/roulette_activity_v2.js +0 -90
  72. package/src/machine/activity/sign_in_monthly_activity.js +0 -65
  73. package/src/machine/activity/vip_card_activity.js +0 -140
  74. package/src/machine/bank_binding_amb.js +0 -145
  75. package/src/machine/deposit/amb.js +0 -92
  76. package/src/machine/deposit/crypto_bank.js +0 -317
  77. package/src/machine/deposit/crypto_bank_cash.js +0 -287
  78. package/src/machine/deposit/crypto_cash.js +0 -255
  79. package/src/machine/deposit/crypto_qrcode.js +0 -148
  80. package/src/machine/deposit/crypto_qrcode_cash.js +0 -131
  81. package/src/machine/deposit/crypto_way.js +0 -239
  82. package/src/machine/deposit/crypto_way_cash.js +0 -256
  83. package/src/machine/deposit/direct_cash.js +0 -217
  84. package/src/machine/deposit/float.js +0 -366
  85. package/src/machine/deposit/krway.js +0 -151
  86. package/src/machine/deposit/loadcard_cash.js +0 -207
  87. package/src/machine/deposit/manual_cash.js +0 -356
  88. package/src/machine/deposit/qrcode_cash.js +0 -217
  89. package/src/machine/deposit/usdt.js +0 -144
  90. package/src/machine/deposit/usdt_cash.js +0 -138
  91. package/src/machine/deposit/vpay.js +0 -359
  92. package/src/machine/game_info.js +0 -57
  93. package/src/machine/game_search_cash.js +0 -390
  94. package/src/machine/game_v2_1.js +0 -662
  95. package/src/machine/honor_board.js +0 -118
  96. package/src/machine/honor_board_cash.js +0 -89
  97. package/src/machine/navbar.js +0 -57
  98. package/src/machine/promotions.js +0 -171
  99. package/src/machine/reward_cash.js +0 -219
  100. package/src/machine/roulette_v2.js +0 -276
  101. package/src/machine/side_cash.js +0 -110
  102. package/src/machine/user_photo.js +0 -65
  103. package/src/machine/withdraw/index.js +0 -23
  104. package/src/machine/withdraw/withdraw_crypto2.js +0 -540
  105. package/src/machine/withdraw/withdraw_crypto_cash.js +0 -319
  106. package/src/machine/withdraw/withdraw_krway.js +0 -220
  107. package/src/machine/withdraw/withdraw_manual.js +0 -610
  108. package/src/machine/withdraw/withdraw_manual_cash.js +0 -303
  109. package/src/machine/withdraw/withdraw_vn.js +0 -546
  110. package/src/machine/withdraw/withdraw_vn2.js +0 -561
  111. package/src/util/math.js +0 -4
@@ -1,15 +1,12 @@
1
1
  import { assign, createMachine } from 'xstate'
2
2
  import payment from '../../api/payment.js'
3
- import common from '../../api/common.js'
4
3
 
5
4
  export default function (request) {
6
- const { appSecret } = request.config
7
5
  return createMachine(
8
6
  {
9
7
  id: 'qrcode',
10
8
  initial: 'loading',
11
9
  context: {
12
- siteConfig: null,
13
10
  qrcodes: null,
14
11
  options: null,
15
12
 
@@ -18,24 +15,18 @@ export default function (request) {
18
15
 
19
16
  calculation: null,
20
17
 
21
- paymentDetail: [],
18
+ paymentDetails: [],
22
19
  currentCategory: 'qrcode',
23
20
  currentMethod: null,
24
21
 
25
22
  result: null,
26
-
27
- grandTotalEnable: 1,
28
-
29
- // use for wallet mode 3 & 4
30
- promotion: null,
31
- bonusPreviewData: [],
32
23
  },
33
24
  states: {
34
25
  loading: {
35
26
  invoke: {
36
27
  src: 'fetchInitData',
37
28
  onDone: {
38
- target: 'checking',
29
+ target: 'loaded',
39
30
  actions: 'setInitData',
40
31
  },
41
32
  onError: {
@@ -43,151 +34,32 @@ export default function (request) {
43
34
  },
44
35
  },
45
36
  },
46
- checking: {
47
- always: [
48
- {
49
- target: 'fetching',
50
- cond: (context, event) => {
51
- const { siteConfig = {}, promotion = {}, selectedQrcode } = context
52
- const { walletMode = '', bonusPreviewEnable = '0' } = siteConfig
53
- return !!selectedQrcode && walletMode === '4' && bonusPreviewEnable === '1' && promotion.activityNo != 'none'
54
- },
55
- },
56
- {
57
- target: 'debouncing',
58
- actions: 'setPromotionDefaultAmount',
59
- cond: (context, event) => {
60
- const { siteConfig = {}, promotion = {} } = context
61
- return siteConfig.walletMode === '3' && !!promotion?.minimumAmount
62
- },
63
- },
64
- { target: 'loaded' },
65
- ],
66
- },
67
- fetching: {
68
- invoke: {
69
- src: 'fetchBonusPreview',
70
- onDone: {
71
- target: 'loaded',
72
- actions: 'setBonusPreview',
73
- },
74
- onError: {
75
- target: 'loaded',
76
- },
77
- },
78
- },
79
- fail: {},
80
37
  loaded: {
81
38
  entry: 'reset',
82
39
  on: {
83
- SELECT_QRCODE: [
84
- {
85
- target: 'fetching',
86
- actions: 'setQrcode',
87
- cond: (context, event) => {
88
- const { siteConfig = {}, promotion = {} } = context
89
- const { walletMode = '', bonusPreviewEnable = '0' } = siteConfig
90
- return walletMode === '4' && bonusPreviewEnable === '1' && promotion.activityNo != 'none'
91
- },
92
- },
93
- {
94
- target: 'debouncing',
95
- actions: ['setQrcode', 'setPromotionDefaultAmount'],
96
- cond: (context, event) => context.siteConfig?.walletMode === '3' && context.promotion?.minimumAmount,
97
- },
98
- {
99
- actions: 'setQrcode',
100
- },
101
- ],
102
- SELECT_AMOUNT: [
103
- {
104
- target: 'debouncing',
105
- actions: 'setAmount',
106
- cond: 'isDoubleWalletMode',
107
- },
108
- {
109
- target: 'pending',
110
- actions: 'addAmount',
111
- cond: (context, event) => context.siteConfig?.walletMode === '2' && context.grandTotalEnable === 1,
112
- },
113
- {
114
- target: 'pending',
115
- actions: 'setAmount',
116
- cond: 'isFreeWalletMode',
117
- },
118
- {
119
- target: 'debouncing',
120
- actions: 'addAmount',
121
- cond: 'isGrandTotalEnable',
122
- },
123
- {
124
- target: 'debouncing',
125
- actions: 'setAmount',
126
- },
127
- ],
128
- KEY_IN: [
129
- {
130
- target: 'pending',
131
- actions: 'setAmount',
132
- cond: 'isFreeWalletMode',
133
- },
134
- {
135
- target: 'calculating',
136
- actions: 'setAmount',
137
- },
138
- ],
139
- },
140
- },
141
- pending: {
142
- on: {
143
- SELECT_AMOUNT: [
144
- {
145
- actions: 'addAmount',
146
- cond: 'isGrandTotalEnable',
147
- },
148
- {
149
- actions: 'setAmount',
150
- },
151
- ],
152
- KEY_IN: {
153
- actions: 'setAmount',
40
+ SELECT_QRCODE: {
41
+ actions: 'setQrcode',
154
42
  },
155
- CONFIRM: {
156
- target: 'calculating',
43
+ SELECT_AMOUNT: {
44
+ target: 'debouncing',
45
+ actions: 'addAmount',
157
46
  },
158
- BACK: {
159
- target: 'loaded',
47
+ KEY_IN: {
48
+ target: 'calculating',
49
+ actions: 'setAmount',
160
50
  },
161
51
  },
162
52
  },
163
53
  debouncing: {
164
54
  on: {
165
- SELECT_AMOUNT: [
166
- {
167
- target: 'debouncing',
168
- actions: 'setAmount',
169
- cond: 'isDoubleWalletMode',
170
- },
171
- {
172
- target: 'debouncing',
173
- actions: 'addAmount',
174
- cond: (context, event) => context.siteConfig?.walletMode === '2' && context.grandTotalEnable === 1,
175
- },
176
- {
177
- target: 'debouncing',
178
- actions: 'setAmount',
179
- cond: 'isFreeWalletMode',
180
- },
181
- {
182
- target: 'debouncing',
183
- actions: 'addAmount',
184
- cond: 'isGrandTotalEnable',
185
- },
186
- {
187
- target: 'debouncing',
188
- actions: 'setAmount',
189
- },
190
- ],
55
+ SELECT_AMOUNT: {
56
+ target: 'debouncing',
57
+ actions: 'addAmount',
58
+ },
59
+ KEY_IN: {
60
+ target: 'debouncing',
61
+ actions: 'setAmount',
62
+ },
191
63
  BACK: {
192
64
  target: 'loaded',
193
65
  },
@@ -198,39 +70,21 @@ export default function (request) {
198
70
  },
199
71
  },
200
72
  },
73
+ fail: {},
201
74
  calculable: {
202
75
  entry: 'clearCalculation',
203
76
  on: {
204
- SELECT_AMOUNT: [
205
- {
206
- target: 'debouncing',
207
- actions: 'setAmount',
208
- cond: 'isDoubleWalletMode',
209
- },
210
- {
211
- target: 'pending',
212
- actions: 'addAmount',
213
- cond: (context, event) => context.siteConfig?.walletMode === '2' && context.grandTotalEnable === 1,
214
- },
215
- {
216
- target: 'pending',
217
- actions: 'setAmount',
218
- cond: 'isFreeWalletMode',
219
- },
220
- {
221
- target: 'debouncing',
222
- actions: 'addAmount',
223
- cond: 'isGrandTotalEnable',
224
- },
225
- {
226
- target: 'debouncing',
227
- actions: 'setAmount',
228
- },
229
- ],
77
+ SELECT_AMOUNT: {
78
+ target: 'debouncing',
79
+ actions: 'addAmount',
80
+ },
230
81
  KEY_IN: {
231
- target: 'calculating',
82
+ target: 'debouncing',
232
83
  actions: 'setAmount',
233
84
  },
85
+ CALCULATE: {
86
+ target: 'debouncing',
87
+ },
234
88
  BACK: {
235
89
  target: 'loaded',
236
90
  },
@@ -239,17 +93,10 @@ export default function (request) {
239
93
  calculating: {
240
94
  invoke: {
241
95
  src: 'fetchCalculation',
242
- onDone: [
243
- {
244
- target: 'submitting',
245
- actions: 'setCalculation',
246
- cond: 'isFreeWalletMode',
247
- },
248
- {
249
- target: 'calculated',
250
- actions: 'setCalculation',
251
- },
252
- ],
96
+ onDone: {
97
+ target: 'calculated',
98
+ actions: 'setCalculation',
99
+ },
253
100
  onError: {
254
101
  target: 'calculable',
255
102
  },
@@ -257,29 +104,12 @@ export default function (request) {
257
104
  },
258
105
  calculated: {
259
106
  on: {
260
- SELECT_AMOUNT: [
261
- {
262
- target: 'pending',
263
- actions: 'addAmount',
264
- cond: (context, event) => context.siteConfig?.walletMode === '2' && context.grandTotalEnable === 1,
265
- },
266
- {
267
- target: 'pending',
268
- actions: 'setAmount',
269
- cond: 'isFreeWalletMode',
270
- },
271
- {
272
- target: 'debouncing',
273
- actions: 'addAmount',
274
- cond: 'isGrandTotalEnable',
275
- },
276
- {
277
- target: 'debouncing',
278
- actions: 'setAmount',
279
- },
280
- ],
107
+ SELECT_AMOUNT: {
108
+ target: 'debouncing',
109
+ actions: 'addAmount',
110
+ },
281
111
  KEY_IN: {
282
- target: 'calculating',
112
+ target: 'debouncing',
283
113
  actions: 'setAmount',
284
114
  },
285
115
  CONFIRM: {
@@ -302,35 +132,19 @@ export default function (request) {
302
132
  actions: 'setResult',
303
133
  },
304
134
  onError: {
305
- target: 'loaded',
135
+ target: 'calculated',
306
136
  },
307
137
  },
308
138
  },
309
139
  submitted: {
310
140
  on: {
311
- SELECT_QRCODE: [
312
- {
313
- target: 'fetching',
314
- actions: 'setQrcode',
315
- cond: (context, event) => {
316
- const { siteConfig = {}, promotion = {} } = context
317
- const { walletMode = '', bonusPreviewEnable = '0' } = siteConfig
318
- return walletMode === '4' && bonusPreviewEnable === '1' && promotion.activityNo != 'none'
319
- },
320
- },
321
- {
322
- target: 'loaded',
323
- actions: 'setQrcode',
324
- },
325
- ],
141
+ SELECT_QRCODE: {
142
+ target: 'loaded',
143
+ actions: 'setQrcode',
144
+ },
326
145
  },
327
146
  },
328
147
  },
329
- on: {
330
- SET_PROMOTION: {
331
- actions: 'setPromotion',
332
- },
333
- },
334
148
  },
335
149
  {
336
150
  actions: {
@@ -338,26 +152,18 @@ export default function (request) {
338
152
  return {
339
153
  selectedAmount: null,
340
154
  calculation: null,
341
- result: null,
342
155
  }
343
156
  }),
344
157
  setInitData: assign((context, event) => {
345
- const { siteConfig, paymentDetail } = event.data
346
- const qrcodes = paymentDetail.filter((element) => element.category === context.currentCategory)
347
- const selectedQrcode = qrcodes[0]
158
+ const paymentDetails = event.data
159
+ const qrcodes = paymentDetails.filter((element) => element.category === context.currentCategory)
160
+
348
161
  return {
349
- siteConfig,
350
- paymentDetail,
162
+ paymentDetails,
351
163
  qrcodes,
352
- selectedQrcode,
353
- currentMethod: selectedQrcode?.method,
354
- options: selectedQrcode?.optional,
355
- grandTotalEnable: selectedQrcode?.grandTotalEnable,
356
- }
357
- }),
358
- setBonusPreview: assign((context, event) => {
359
- return {
360
- bonusPreviewData: event.data.bonus,
164
+ selectedQrcode: qrcodes[0],
165
+ currentMethod: qrcodes[0].method,
166
+ options: qrcodes[0].optional,
361
167
  }
362
168
  }),
363
169
  setQrcode: assign((context, event) => {
@@ -365,7 +171,6 @@ export default function (request) {
365
171
  selectedQrcode: event.data,
366
172
  currentMethod: event.data.method,
367
173
  options: event.data.optional,
368
- grandTotalEnable: event.data.grandTotalEnable,
369
174
  }
370
175
  }),
371
176
  addAmount: assign((context, event) => {
@@ -389,64 +194,26 @@ export default function (request) {
389
194
  result: event.data,
390
195
  }
391
196
  }),
392
- setPromotion: assign((context, event) => {
393
- const promotion = event.data
394
- return {
395
- promotion,
396
- }
397
- }),
398
- setPromotionDefaultAmount: assign((context, event) => {
399
- return {
400
- selectedAmount: context.promotion.minimumAmount,
401
- }
402
- }),
403
- },
404
- guards: {
405
- isDoubleWalletMode: (context, event) => {
406
- return context.siteConfig?.walletMode === '4'
407
- },
408
- isFreeWalletMode: (context, event) => {
409
- return context.siteConfig?.walletMode === '2'
410
- },
411
- isGrandTotalEnable: (context, event) => {
412
- return context.grandTotalEnable === 1
413
- },
414
197
  },
415
198
  services: {
416
199
  fetchInitData: async (context, event) => {
417
- const [{ config }, paymentDetail = []] = await Promise.all([
418
- request.send(common.getConfig({ appSecret })),
419
- request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' })),
420
- ])
421
- const siteConfig = JSON.parse(window.atob(config))
422
- return { siteConfig, paymentDetail }
423
- },
424
- fetchBonusPreview: async (context, event) => {
425
- const { currentMethod, promotion } = context
426
- return await request.send(
427
- payment.getBonusPreview({
428
- method: currentMethod,
429
- promotionsNo: promotion?.activityNo,
430
- })
431
- )
200
+ return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
432
201
  },
433
202
  fetchCalculation: async (context, event) => {
434
- const { currentMethod, selectedAmount, promotion } = context
203
+ const { currentMethod, selectedAmount } = context
435
204
  return await request.send(
436
205
  payment.getDepositExpectedResult({
437
206
  method: currentMethod,
438
207
  amount: selectedAmount,
439
- promotionsNo: promotion?.activityNo,
440
208
  })
441
209
  )
442
210
  },
443
211
  submitDeposit: async (context, event) => {
444
- const { currentMethod, selectedAmount, promotion } = context
212
+ const { currentMethod, selectedAmount } = context
445
213
  return await request.send(
446
- payment.submitDepositTransaction({
214
+ payment.submitDepositTransactionQrcode({
447
215
  method: currentMethod,
448
216
  amount: selectedAmount,
449
- promotionsNo: promotion?.activityNo,
450
217
  })
451
218
  )
452
219
  },
@@ -0,0 +1,206 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import payment from '../../api/payment.js'
3
+
4
+ export default function (request) {
5
+ return createMachine(
6
+ {
7
+ id: 'qrcode',
8
+ initial: 'loading',
9
+ context: {
10
+ qrcodes: [],
11
+ options: [],
12
+
13
+ selectedQrcode: null,
14
+ selectedAmount: null,
15
+
16
+ calculation: null,
17
+
18
+ paymentDetails: [],
19
+ currentCategory: 'qrcode',
20
+ currentMethod: null,
21
+
22
+ result: null,
23
+ },
24
+ states: {
25
+ loading: {
26
+ invoke: {
27
+ src: 'fetchInitData',
28
+ onDone: {
29
+ target: 'loaded',
30
+ actions: 'setInitData',
31
+ },
32
+ onError: {
33
+ target: 'fail',
34
+ },
35
+ },
36
+ },
37
+ loaded: {
38
+ entry: 'reset',
39
+ on: {
40
+ SELECT_QRCODE: {
41
+ actions: 'setQrcode',
42
+ },
43
+ SELECT_AMOUNT: {
44
+ target: 'calculable',
45
+ actions: 'addAmount',
46
+ },
47
+ KEY_IN: {
48
+ target: 'calculable',
49
+ actions: 'setAmount',
50
+ },
51
+ },
52
+ },
53
+ fail: {},
54
+ calculable: {
55
+ entry: 'clearCalculation',
56
+ on: {
57
+ SELECT_AMOUNT: {
58
+ actions: 'addAmount',
59
+ },
60
+ KEY_IN: {
61
+ actions: 'setAmount',
62
+ },
63
+ CALCULATE: {
64
+ target: 'calculating',
65
+ },
66
+ BACK: {
67
+ target: 'loaded',
68
+ },
69
+ },
70
+ },
71
+ calculating: {
72
+ invoke: {
73
+ src: 'fetchCalculation',
74
+ onDone: {
75
+ target: 'calculated',
76
+ actions: 'setCalculation',
77
+ },
78
+ onError: {
79
+ target: 'calculable',
80
+ },
81
+ },
82
+ },
83
+ calculated: {
84
+ on: {
85
+ SELECT_AMOUNT: {
86
+ target: 'calculable',
87
+ actions: 'addAmount',
88
+ },
89
+ KEY_IN: {
90
+ target: 'calculable',
91
+ actions: 'setAmount',
92
+ },
93
+ CONFIRM: {
94
+ target: 'submitting',
95
+ },
96
+ BACK: {
97
+ target: 'loaded',
98
+ },
99
+ CLEAR_CALCULATION: {
100
+ target: 'calculable',
101
+ actions: 'clearCalculation',
102
+ },
103
+ },
104
+ },
105
+ submitting: {
106
+ invoke: {
107
+ src: 'submitDeposit',
108
+ onDone: {
109
+ target: 'submitted',
110
+ actions: 'setResult',
111
+ },
112
+ onError: {
113
+ target: 'calculated',
114
+ },
115
+ },
116
+ },
117
+ submitted: {
118
+ on: {
119
+ SELECT_QRCODE: {
120
+ target: 'loaded',
121
+ actions: 'setQrcode',
122
+ },
123
+ },
124
+ },
125
+ },
126
+ },
127
+ {
128
+ actions: {
129
+ reset: assign((context, event) => {
130
+ return {
131
+ selectedAmount: null,
132
+ calculation: null,
133
+ }
134
+ }),
135
+ setInitData: assign((context, event) => {
136
+ const paymentDetails = event.data
137
+ const qrcodes = paymentDetails.filter((element) => element.category === context.currentCategory)
138
+
139
+ return {
140
+ paymentDetails,
141
+ qrcodes,
142
+ selectedQrcode: qrcodes[0],
143
+ currentMethod: qrcodes[0].method,
144
+ options: qrcodes[0].optional,
145
+ }
146
+ }),
147
+ setQrcode: assign((context, event) => {
148
+ return {
149
+ selectedQrcode: event.data,
150
+ currentMethod: event.data.method,
151
+ options: event.data.optional,
152
+ }
153
+ }),
154
+ addAmount: assign((context, event) => {
155
+ return { selectedAmount: (context.selectedAmount || 0) + event.data }
156
+ }),
157
+ setAmount: assign((context, event) => {
158
+ return { selectedAmount: event.data }
159
+ }),
160
+ setCalculation: assign((context, event) => {
161
+ return {
162
+ calculation: event.data,
163
+ }
164
+ }),
165
+ clearCalculation: assign((context, event) => {
166
+ return {
167
+ calculation: null,
168
+ }
169
+ }),
170
+ setResult: assign((context, event) => {
171
+ return {
172
+ result: event.data,
173
+ }
174
+ }),
175
+ },
176
+ services: {
177
+ fetchInitData: async (context, event) => {
178
+ return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
179
+ },
180
+ fetchBanksList: async (context, event) => {
181
+ const { paymentDetails, currentCategory } = context
182
+ const method = paymentDetails.find((item) => item.category === currentCategory)?.method
183
+ return await request.send(payment.getBankList(method))
184
+ },
185
+ fetchCalculation: async (context, event) => {
186
+ const { currentMethod, selectedAmount } = context
187
+ return await request.send(
188
+ payment.getDepositExpectedResult({
189
+ method: currentMethod,
190
+ amount: selectedAmount,
191
+ })
192
+ )
193
+ },
194
+ submitDeposit: async (context, event) => {
195
+ const { currentMethod, selectedAmount } = context
196
+ return await request.send(
197
+ payment.submitDepositTransactionQrcode({
198
+ method: currentMethod,
199
+ amount: selectedAmount,
200
+ })
201
+ )
202
+ },
203
+ },
204
+ }
205
+ )
206
+ }