@jetthai/cuora 1.1.13-4 → 1.1.15-1

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.
@@ -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,7 +15,7 @@ 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
 
@@ -31,152 +28,15 @@ export default function (request) {
31
28
  invoke: {
32
29
  src: 'fetchInitData',
33
30
  onDone: {
34
- target: 'checking',
35
- actions: ['setInitData', 'preset'],
31
+ target: 'loaded',
32
+ actions: 'setInitData',
36
33
  },
37
34
  onError: {
38
35
  target: 'fail',
39
36
  },
40
37
  },
41
38
  },
42
- checking: {
43
- always: [{ target: 'promotionApplyMode', cond: 'isPromotionApplyMode' }, { target: 'defaultMode' }],
44
- },
45
- promotionApplyMode: {
46
- initial: 'loaded',
47
- states: {
48
- loaded: {
49
- entry: 'reset',
50
- on: {
51
- SELECT_QRCODE: {
52
- actions: 'setQrcode',
53
- },
54
- SELECT_AMOUNT: [
55
- {
56
- target: 'submittable',
57
- actions: 'addAmount',
58
- cond: (context, event) => context.grandTotalEnable === 1,
59
- },
60
- {
61
- target: 'submittable',
62
- actions: 'setAmount',
63
- },
64
- ],
65
- KEY_IN: {
66
- actions: 'setAmount',
67
- },
68
- },
69
- },
70
- submittable: {
71
- on: {
72
- SELECT_AMOUNT: [
73
- {
74
- actions: 'addAmount',
75
- cond: (context, event) => context.grandTotalEnable === 1,
76
- },
77
- {
78
- actions: 'setAmount',
79
- },
80
- ],
81
- KEY_IN: {
82
- actions: 'setAmount',
83
- },
84
- CONFIRM: {
85
- target: 'debouncing',
86
- },
87
- BACK: {
88
- target: 'loaded',
89
- },
90
- },
91
- },
92
- debouncing: {
93
- on: {
94
- SELECT_AMOUNT: [
95
- {
96
- target: 'debouncing',
97
- actions: 'addAmount',
98
- cond: (context, event) => context.grandTotalEnable === 1,
99
- },
100
- {
101
- target: 'debouncing',
102
- actions: 'setAmount',
103
- },
104
- ],
105
- KEY_IN: {
106
- target: 'debouncing',
107
- actions: 'setAmount',
108
- },
109
- BACK: {
110
- target: 'loaded',
111
- },
112
- },
113
- after: {
114
- 1000: {
115
- target: 'calculating',
116
- },
117
- },
118
- },
119
- calculable: {
120
- entry: 'clearCalculation',
121
- on: {
122
- SELECT_AMOUNT: [
123
- {
124
- target: 'debouncing',
125
- actions: 'addAmount',
126
- cond: (context, event) => context.grandTotalEnable === 1,
127
- },
128
- {
129
- target: 'debouncing',
130
- actions: 'setAmount',
131
- },
132
- ],
133
- KEY_IN: {
134
- target: 'debouncing',
135
- actions: 'setAmount',
136
- },
137
- CALCULATE: {
138
- target: 'debouncing',
139
- },
140
- BACK: {
141
- target: 'loaded',
142
- },
143
- },
144
- },
145
- calculating: {
146
- invoke: {
147
- src: 'fetchCalculation',
148
- onDone: {
149
- target: 'submitting',
150
- actions: 'setCalculation',
151
- },
152
- onError: {
153
- target: 'calculable',
154
- },
155
- },
156
- },
157
- submitting: {
158
- invoke: {
159
- src: 'submitDeposit',
160
- onDone: {
161
- target: 'submitted',
162
- actions: 'setResult',
163
- },
164
- onError: {
165
- target: 'submittable',
166
- },
167
- },
168
- },
169
- submitted: {
170
- on: {
171
- SELECT_QRCODE: {
172
- target: 'loaded',
173
- actions: 'setQrcode',
174
- },
175
- },
176
- },
177
- },
178
- },
179
- defaultMode: {
39
+ loaded: {
180
40
  entry: 'reset',
181
41
  on: {
182
42
  SELECT_QRCODE: {
@@ -217,7 +77,7 @@ export default function (request) {
217
77
  actions: 'setAmount',
218
78
  },
219
79
  BACK: {
220
- target: 'defaultMode',
80
+ target: 'loaded',
221
81
  },
222
82
  },
223
83
  after: {
@@ -249,7 +109,7 @@ export default function (request) {
249
109
  target: 'debouncing',
250
110
  },
251
111
  BACK: {
252
- target: 'defaultMode',
112
+ target: 'loaded',
253
113
  },
254
114
  },
255
115
  },
@@ -286,7 +146,7 @@ export default function (request) {
286
146
  target: 'submitting',
287
147
  },
288
148
  BACK: {
289
- target: 'defaultMode',
149
+ target: 'loaded',
290
150
  },
291
151
  CLEAR_CALCULATION: {
292
152
  target: 'debouncing',
@@ -309,7 +169,7 @@ export default function (request) {
309
169
  submitted: {
310
170
  on: {
311
171
  SELECT_QRCODE: {
312
- target: 'defaultMode',
172
+ target: 'loaded',
313
173
  actions: 'setQrcode',
314
174
  },
315
175
  },
@@ -325,11 +185,11 @@ export default function (request) {
325
185
  }
326
186
  }),
327
187
  setInitData: assign((context, event) => {
328
- const { paymentDetail } = event.data
329
- const qrcodes = paymentDetail.filter((element) => element.category === context.currentCategory)
188
+ const paymentDetails = event.data
189
+ const qrcodes = paymentDetails.filter((element) => element.category === context.currentCategory)
330
190
 
331
191
  return {
332
- paymentDetail,
192
+ paymentDetails,
333
193
  qrcodes,
334
194
  selectedQrcode: qrcodes[0],
335
195
  currentMethod: qrcodes[0].method,
@@ -337,12 +197,6 @@ export default function (request) {
337
197
  grandTotalEnable: qrcodes[0].grandTotalEnable,
338
198
  }
339
199
  }),
340
- preset: assign((context, event) => {
341
- const { siteConfig } = event.data
342
- return {
343
- siteConfig,
344
- }
345
- }),
346
200
  setQrcode: assign((context, event) => {
347
201
  return {
348
202
  selectedQrcode: event.data,
@@ -373,19 +227,9 @@ export default function (request) {
373
227
  }
374
228
  }),
375
229
  },
376
- guards: {
377
- isPromotionApplyMode: (context, event) => {
378
- return context.siteConfig?.promotionApplyMode === '1'
379
- },
380
- },
381
230
  services: {
382
231
  fetchInitData: async (context, event) => {
383
- const [{ config }, paymentDetail = []] = await Promise.all([
384
- request.send(common.getConfig({ appSecret })),
385
- request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' })),
386
- ])
387
- const siteConfig = JSON.parse(window.atob(config))
388
- return { siteConfig, paymentDetail }
232
+ return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
389
233
  },
390
234
  fetchCalculation: async (context, event) => {
391
235
  const { currentMethod, selectedAmount } = context
@@ -5,7 +5,7 @@ export default function (request) {
5
5
  return createMachine(
6
6
  {
7
7
  id: 'favorite',
8
- type: 'parallel',
8
+ initial: 'fetching',
9
9
  context: {
10
10
  list: [],
11
11
  },
@@ -21,31 +21,36 @@ export default function (request) {
21
21
  },
22
22
  },
23
23
  },
24
- adding: {
25
- initial: 'disable',
24
+ operation: {
25
+ type: 'parallel',
26
26
  states: {
27
- disable: {},
28
- enable: {
29
- invoke: {
30
- src: 'add',
31
- onDone: {},
32
- onError: {
33
- actions: 'removeFromList',
27
+ adding: {
28
+ initial: 'disable',
29
+ states: {
30
+ disable: {},
31
+ enable: {
32
+ invoke: {
33
+ src: 'add',
34
+ onDone: {},
35
+ onError: {
36
+ actions: 'removeFromList',
37
+ },
38
+ },
34
39
  },
35
40
  },
36
41
  },
37
- },
38
- },
39
- removing: {
40
- initial: 'disable',
41
- states: {
42
- disable: {},
43
- enable: {
44
- invoke: {
45
- src: 'remove',
46
- onDone: {},
47
- onError: {
48
- actions: 'addToList',
42
+ removing: {
43
+ initial: 'disable',
44
+ states: {
45
+ disable: {},
46
+ enable: {
47
+ invoke: {
48
+ src: 'remove',
49
+ onDone: {},
50
+ onError: {
51
+ actions: 'addToList',
52
+ },
53
+ },
49
54
  },
50
55
  },
51
56
  },
@@ -54,12 +59,12 @@ export default function (request) {
54
59
  },
55
60
  on: {
56
61
  ADD: {
57
- target: 'adding.enable',
62
+ target: 'operation.adding.enable',
58
63
  actions: 'addToList',
59
64
  cond: 'isNotExist',
60
65
  },
61
66
  REMOVE: {
62
- target: 'removing.enable',
67
+ target: 'operation.removing.enable',
63
68
  actions: 'removeFromList',
64
69
  cond: 'isExist',
65
70
  },
@@ -33,7 +33,6 @@ import leaderboard from './leaderboard.js'
33
33
  import auth_otp_v2 from './auth_otp_v2.js'
34
34
  import auth_otp_v3 from './auth_otp_v3.js'
35
35
  import vip_table from './vip_table.js'
36
- import promotions from './promotions.js'
37
36
 
38
37
  export default {
39
38
  ...activity,
@@ -72,5 +71,4 @@ export default {
72
71
  auth_otp_v2,
73
72
  auth_otp_v3,
74
73
  vip_table,
75
- promotions,
76
74
  }
@@ -1,139 +0,0 @@
1
- import { assign, createMachine } from 'xstate'
2
- import payment from '../api/payment.js'
3
- import user from '../api/user.js'
4
-
5
- export default function (request) {
6
- return createMachine(
7
- {
8
- id: 'promotions',
9
- initial: 'loading',
10
- context: {
11
- noBonus: {
12
- promotionsNo: 'No Bonus',
13
- title: 'No Bonus',
14
- adSmallUrl: [
15
- {
16
- url: '~/assets/images/deposit/deposit_img_nobonus_normal.png',
17
- name: 'No Bonus',
18
- },
19
- ],
20
- descrip: 'no_bonus',
21
- minimumAmount: 0,
22
- turnoverLimitMultiple: 1,
23
- promotionDetail: [],
24
- withdrawLimitDetail: [],
25
- limitGameDetail: [],
26
- },
27
- oldTargetTurnoverLimit: 0,
28
- newTargetTurnoverLimit: 0,
29
- promotionsList: [],
30
- selectedPromo: {},
31
- joinedPromotion: null,
32
- },
33
- states: {
34
- loading: {
35
- invoke: {
36
- src: 'fetchInitData',
37
- onDone: {
38
- target: 'loaded',
39
- actions: 'setInitData',
40
- },
41
- onError: {
42
- target: 'fail',
43
- },
44
- },
45
- },
46
- loaded: {
47
- on: {
48
- SELECT_PROMO: {
49
- actions: ['reset', 'setSelectedPromo'],
50
- },
51
- SET_AMOUNT: {
52
- actions: 'setAmount',
53
- },
54
- JOIN: {
55
- target: 'check',
56
- cond: 'isValidAmount',
57
- },
58
- },
59
- },
60
- check: {
61
- entry: 'preset',
62
- on: {
63
- CONFIRM: {
64
- target: 'joinning',
65
- },
66
- BACK: {
67
- target: 'loaded',
68
- },
69
- },
70
- },
71
- joinning: {
72
- invoke: {
73
- src: 'applyPromotion',
74
- onDone: {
75
- target: 'joined',
76
- },
77
- onError: {
78
- target: 'fail',
79
- },
80
- },
81
- },
82
- joined: {},
83
- fail: {},
84
- },
85
- },
86
- {
87
- actions: {
88
- setInitData: assign((context, event) => {
89
- const { userInfo, promotionsList } = event.data
90
- const { noBonus } = context
91
- return {
92
- promotionsList,
93
- userInfo,
94
- selectedPromo: noBonus,
95
- }
96
- }),
97
- setSelectedPromo: assign((context, event) => {
98
- return {
99
- selectedPromo: event.data,
100
- }
101
- }),
102
- setAmount: assign((context, event) => {
103
- return {
104
- amount: event.data,
105
- }
106
- }),
107
- reset: assign((context, event) => {
108
- return {
109
- amount: null,
110
- }
111
- }),
112
- preset: assign((context, event) => {
113
- const { userInfo, selectedPromo, amount } = context
114
- const { turnoverLimitMultiple } = selectedPromo
115
- return {
116
- oldTargetTurnoverLimit: userInfo.target_withdraw_limit,
117
- newTargetTurnoverLimit: parseFloat(`${amount}`) * parseFloat(`${turnoverLimitMultiple}`),
118
- }
119
- }),
120
- },
121
- guards: {
122
- isValidAmount: (context, event) => {
123
- const { selectedPromo, amount } = context
124
- return selectedPromo.minimumAmount <= amount
125
- },
126
- },
127
- services: {
128
- fetchInitData: async (context, event) => {
129
- const [userInfo, promotionsList] = await Promise.all([request.send(user.getUserInfo()), request.send(payment.getPromotionsList())])
130
- return { userInfo, promotionsList }
131
- },
132
- applyPromotion: async (context, event) => {
133
- const { selectedPromo, amount } = context
134
- return await request.send(payment.applyPromotions({ promotionsNo: selectedPromo.promotionsNo, amount: parseFloat(amount) }))
135
- },
136
- },
137
- }
138
- )
139
- }