@jetthai/cuora 1.1.77-cash → 1.1.77-cash-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.1.77-cash-2](https://github.com/jetthai/cuora-module/compare/v1.1.77-cash-1...v1.1.77-cash-2) (2023-04-18)
6
+
7
+ ### [1.1.77-cash-1](https://github.com/jetthai/cuora-module/compare/v1.1.77-cash...v1.1.77-cash-1) (2023-04-16)
8
+
5
9
  ### [1.1.77-cash](https://github.com/jetthai/cuora-module/compare/v1.1.66-1...v1.1.77-cash) (2023-04-14)
6
10
 
7
11
  ### [1.1.77](https://github.com/jetthai/cuora-module/compare/v1.1.76...v1.1.77) (2023-04-13)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.77-cash",
3
+ "version": "1.1.77-cash-2",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -31,13 +31,7 @@ export default function (request) {
31
31
  },
32
32
  },
33
33
  },
34
- idle: {
35
- on: {
36
- SET_ACTIVITY_NO: {
37
- // todo - deprecated
38
- },
39
- },
40
- },
34
+ idle: {},
41
35
  checking: {
42
36
  always: [{ target: 'loading', cond: 'hasActivityNo' }],
43
37
  },
@@ -58,6 +52,9 @@ export default function (request) {
58
52
  EXCHANGE: {
59
53
  target: 'exchanging',
60
54
  },
55
+ SELECT: {
56
+ actions: ['selectProduct', 'count'],
57
+ },
61
58
  ADD_TO_CART: {
62
59
  actions: ['addProduct', 'count'],
63
60
  },
@@ -145,6 +142,11 @@ export default function (request) {
145
142
  unclaimedRewardList: [],
146
143
  }
147
144
  }),
145
+ selectProduct: assign((context, event) => {
146
+ return {
147
+ exchangeList: [event.data],
148
+ }
149
+ }),
148
150
  addProduct: assign((context, event) => {
149
151
  return {
150
152
  exchangeList: [...context.exchangeList, event.data],
@@ -1,6 +1,7 @@
1
1
  import manual_vn from './manual_vn.js'
2
2
  import loadcard_vn from './loadcard_vn.js'
3
3
  import qrcode_v2 from './qrcode_v2.js'
4
+ import qrcode_v_cash from './qrcode_v_cash.js'
4
5
  import deposit_fc from './deposit_fc.js'
5
6
  import crypto from './crypto.js'
6
7
  import crypto_button from './crypto_button.js'
@@ -14,6 +15,7 @@ export default {
14
15
  manual_vn,
15
16
  loadcard_vn,
16
17
  qrcode_v2,
18
+ qrcode_v_cash,
17
19
  deposit_fc,
18
20
  crypto,
19
21
  crypto_button,
@@ -27,7 +27,7 @@ export default function (request) {
27
27
  grandTotalEnable: 1,
28
28
 
29
29
  // use for wallet mode 3 & 4
30
- promotion: undefined,
30
+ promotion: null,
31
31
  bonusPreviewData: [],
32
32
  },
33
33
  states: {
@@ -153,10 +153,6 @@ export default function (request) {
153
153
  BACK: {
154
154
  target: 'loaded',
155
155
  },
156
- INPUT: {
157
- target: 'debouncing',
158
- actions: 'setAmount',
159
- },
160
156
  },
161
157
  },
162
158
  debouncing: {
@@ -182,10 +178,6 @@ export default function (request) {
182
178
  actions: 'setAmount',
183
179
  },
184
180
  ],
185
- INPUT: {
186
- target: 'debouncing',
187
- actions: 'setAmount',
188
- },
189
181
  BACK: {
190
182
  target: 'loaded',
191
183
  },
@@ -193,7 +185,6 @@ export default function (request) {
193
185
  after: {
194
186
  1000: {
195
187
  target: 'calculating',
196
- cond: (context, event) => context.selectedAmount >= context.selectedQrcode.minimum,
197
188
  },
198
189
  },
199
190
  },
@@ -286,14 +277,6 @@ export default function (request) {
286
277
  target: 'debouncing',
287
278
  actions: 'clearCalculation',
288
279
  },
289
- INPUT: {
290
- target: 'debouncing',
291
- actions: 'setAmount',
292
- },
293
- SELECT_QRCODE: {
294
- target: 'debouncing',
295
- actions: 'setQrcode',
296
- },
297
280
  },
298
281
  },
299
282
  submitting: {
@@ -376,7 +359,7 @@ export default function (request) {
376
359
  }
377
360
  }),
378
361
  addAmount: assign((context, event) => {
379
- return { selectedAmount: parseFloat(context.selectedAmount || 0) + parseFloat(event.data) }
362
+ return { selectedAmount: (context.selectedAmount || 0) + event.data }
380
363
  }),
381
364
  setAmount: assign((context, event) => {
382
365
  return { selectedAmount: event.data }
@@ -0,0 +1,274 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import payment from '../../api/payment.js'
3
+ import common from '../../api/common.js'
4
+ import { api } from '../../index.js'
5
+
6
+ const noBonus = {
7
+ promotionsNo: 'none',
8
+ activityTypeName: 'promotion',
9
+ minimumAmount: 0,
10
+ maximumAmount: -1,
11
+ turnoverLimitMultiple: 1,
12
+ template: 'Template_no_bonus',
13
+ promotionDetail: [],
14
+ attendEnable: true,
15
+ withdrawLimitDetail: [
16
+ {
17
+ greaterEqualThen: 0,
18
+ lessEqualThen: -1,
19
+ maxWithdrawAmount: -1,
20
+ turnoverLimitMultiple: 1,
21
+ },
22
+ ],
23
+ limitGameDetail: [],
24
+ }
25
+
26
+ export default function (request) {
27
+ const { appSecret } = request.config
28
+ return createMachine(
29
+ {
30
+ id: 'qrcode_v_cash',
31
+ initial: 'loading',
32
+ context: {
33
+ siteConfig: null,
34
+ qrcodes: null,
35
+ options: null,
36
+
37
+ selectedQrcode: null,
38
+ selectedAmount: null,
39
+
40
+ calculation: null,
41
+
42
+ paymentDetail: [],
43
+ currentCategory: 'qrcode',
44
+
45
+ result: null,
46
+
47
+ promotion: undefined,
48
+ bonusPreviewData: [],
49
+ promotions: [noBonus],
50
+ },
51
+ states: {
52
+ loading: {
53
+ invoke: {
54
+ src: 'fetchInitData',
55
+ onDone: {
56
+ target: 'debouncing',
57
+ actions: 'setInitData',
58
+ },
59
+ onError: {
60
+ target: 'fail',
61
+ },
62
+ },
63
+ },
64
+ fail: {},
65
+ debouncing: {
66
+ on: {
67
+ SET_PROMOTION: {
68
+ target: 'debouncing',
69
+ actions: 'setPromotion',
70
+ },
71
+ SELECT_QRCODE: {
72
+ target: 'debouncing',
73
+ actions: 'setQrcode',
74
+ },
75
+ SELECT_AMOUNT: {
76
+ target: 'debouncing',
77
+ actions: 'setAmount',
78
+ },
79
+ INPUT_AMOUNT: {
80
+ target: 'debouncing',
81
+ actions: 'inputAmount',
82
+ },
83
+ },
84
+ after: {
85
+ 1000: {
86
+ target: 'calculating',
87
+ cond: (context, event) => {
88
+ const { selectedQrcode, selectedAmount } = context
89
+ if (selectedQrcode && selectedAmount) {
90
+ return selectedQrcode.minimum <= selectedAmount && selectedAmount <= selectedQrcode.maximum
91
+ } else {
92
+ return false
93
+ }
94
+ },
95
+ },
96
+ },
97
+ },
98
+ calculating: {
99
+ invoke: {
100
+ src: 'fetchCalculation',
101
+ onDone: {
102
+ target: 'calculated',
103
+ actions: 'setCalculation',
104
+ },
105
+ onError: {
106
+ target: 'calculated',
107
+ },
108
+ },
109
+ },
110
+ calculated: {
111
+ on: {
112
+ SET_PROMOTION: {
113
+ target: 'debouncing',
114
+ actions: 'setPromotion',
115
+ },
116
+ SELECT_QRCODE: {
117
+ target: 'debouncing',
118
+ actions: 'setQrcode',
119
+ },
120
+ SELECT_AMOUNT: {
121
+ target: 'debouncing',
122
+ actions: 'setAmount',
123
+ },
124
+ INPUT_AMOUNT: {
125
+ target: 'debouncing',
126
+ actions: 'inputAmount',
127
+ },
128
+ CONFIRM: {
129
+ target: 'submitting',
130
+ },
131
+ },
132
+ },
133
+ submitting: {
134
+ invoke: {
135
+ src: 'submitDeposit',
136
+ onDone: {
137
+ target: 'submitted',
138
+ actions: 'setResult',
139
+ },
140
+ onError: {
141
+ target: 'calculated',
142
+ },
143
+ },
144
+ },
145
+ submitted: {},
146
+ },
147
+ },
148
+ {
149
+ actions: {
150
+ setInitData: assign((context, event) => {
151
+ const { siteConfig, paymentDetail, promotions } = event.data
152
+ const promotion = promotions[0]
153
+ const qrcodes = paymentDetail
154
+ .filter((element) => element.category === context.currentCategory)
155
+ .map((qrcode) => {
156
+ qrcode.disabled = promotion.promotionsNo !== 'none' && qrcode.charge > 0
157
+ return qrcode
158
+ })
159
+
160
+ const selectedQrcode = qrcodes.find((qrcode) => !qrcode.disabled)
161
+
162
+ return {
163
+ siteConfig,
164
+ paymentDetail,
165
+ promotions,
166
+ promotion,
167
+ qrcodes,
168
+ selectedQrcode,
169
+ options: selectedQrcode?.optional,
170
+ selectedAmount: Math.max(promotion.minimumAmount, selectedQrcode?.minimum, 0),
171
+ }
172
+ }),
173
+ setBonusPreview: assign((context, event) => {
174
+ return {
175
+ bonusPreviewData: event.data.bonus,
176
+ }
177
+ }),
178
+ setPromotion: assign((context, event) => {
179
+ const promotion = event.data
180
+ const qrcodes = context.qrcodes.map((qrcode) => {
181
+ qrcode.disabled = promotion.promotionsNo !== 'none' && qrcode.charge > 0
182
+ return qrcode
183
+ })
184
+
185
+ const selectedQrcode = qrcodes.find((qrcode) => !qrcode.disabled)
186
+
187
+ return {
188
+ promotion,
189
+ qrcodes,
190
+ selectedQrcode,
191
+ options: selectedQrcode?.optional,
192
+ selectedAmount: Math.max(promotion.minimumAmount, selectedQrcode?.minimum, 0),
193
+ calculation: null,
194
+ }
195
+ }),
196
+ setQrcode: assign((context, event) => {
197
+ const selectedQrcode = event.data
198
+ return {
199
+ selectedQrcode,
200
+ options: selectedQrcode.optional,
201
+ selectedAmount: context.promotion.minimumAmount || 0,
202
+ calculation: null,
203
+ }
204
+ }),
205
+ setAmount: assign((context, event) => {
206
+ if (context.selectedQrcode?.grandTotalEnable === 1) {
207
+ return { selectedAmount: parseFloat(context.selectedAmount || 0) + parseFloat(event.data) }
208
+ } else {
209
+ return { selectedAmount: event.data }
210
+ }
211
+ }),
212
+ inputAmount: assign((context, event) => {
213
+ return { selectedAmount: event.data }
214
+ }),
215
+ setCalculation: assign((context, event) => {
216
+ return {
217
+ calculation: event.data,
218
+ }
219
+ }),
220
+ clearCalculation: assign((context, event) => {
221
+ return {
222
+ calculation: null,
223
+ }
224
+ }),
225
+ setResult: assign((context, event) => {
226
+ return {
227
+ result: event.data,
228
+ }
229
+ }),
230
+ },
231
+ guards: {},
232
+ services: {
233
+ fetchInitData: async (context, event) => {
234
+ const [{ config }, paymentDetail = [], promotions] = await Promise.all([
235
+ request.send(common.getConfig({ appSecret })),
236
+ request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' })),
237
+ request.send(api.payment.getPromotionsList()),
238
+ ])
239
+ const siteConfig = JSON.parse(window.atob(config))
240
+ return { siteConfig, paymentDetail, promotions: [noBonus, ...promotions] }
241
+ },
242
+ fetchBonusPreview: async (context, event) => {
243
+ const { selectedQrcode, promotion } = context
244
+ return await request.send(
245
+ payment.getBonusPreview({
246
+ method: selectedQrcode.method,
247
+ promotionsNo: promotion?.activityNo,
248
+ })
249
+ )
250
+ },
251
+ fetchCalculation: async (context, event) => {
252
+ const { selectedQrcode, selectedAmount, promotion } = context
253
+ return await request.send(
254
+ payment.getDepositExpectedResult({
255
+ method: selectedQrcode.method,
256
+ amount: selectedAmount,
257
+ promotionsNo: promotion?.activityNo,
258
+ })
259
+ )
260
+ },
261
+ submitDeposit: async (context, event) => {
262
+ const { selectedQrcode, selectedAmount, promotion } = context
263
+ return await request.send(
264
+ payment.submitDepositTransaction({
265
+ method: selectedQrcode.method,
266
+ amount: selectedAmount,
267
+ promotionsNo: promotion?.activityNo,
268
+ })
269
+ )
270
+ },
271
+ },
272
+ }
273
+ )
274
+ }
@@ -1,5 +1,6 @@
1
1
  import { assign, createMachine } from 'xstate'
2
2
  import user from '../api/user.js'
3
+ import payment from '../api/payment.js'
3
4
 
4
5
  export default function (request) {
5
6
  return createMachine(
@@ -8,6 +9,7 @@ export default function (request) {
8
9
  initial: 'fetching',
9
10
  context: {
10
11
  userInfo: {},
12
+ bankList: [],
11
13
  },
12
14
  states: {
13
15
  fetching: {
@@ -47,13 +49,17 @@ export default function (request) {
47
49
  actions: {
48
50
  setUserInfo: assign((context, event) => {
49
51
  return {
50
- userInfo: event.data,
52
+ userInfo: event.data.userInfo,
53
+ bankList: event.data.bankList,
51
54
  }
52
55
  }),
53
56
  },
54
57
  services: {
55
58
  fetchUserInfo: async (context, event) => {
56
- return await request.send(user.getUserInfo())
59
+ const paymentDetail = await request.send(payment.getPaymentDetail({ transferType: 'WITHDRAW' }))
60
+ const method = paymentDetail.find((payment) => payment.category === 'manual').method
61
+ const [bankList, userInfo] = await Promise.all([request.send(payment.getBankList(method)), request.send(user.getUserInfo())])
62
+ return { bankList, userInfo }
57
63
  },
58
64
  updateUserInfo: async (context, event) => {
59
65
  return await request.send(user.updateUserInfo(event.data))