@jetthai/cuora 1.1.332 → 1.1.333-dev-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.
@@ -33,6 +33,7 @@ export default function (request) {
33
33
  email: null,
34
34
  username: null,
35
35
  password: null,
36
+ additionalUserInfo: null,
36
37
  },
37
38
  countryAbbr: null,
38
39
  userInfo: {},
@@ -271,6 +272,10 @@ export default function (request) {
271
272
  LOGIN_APP: {
272
273
  target: '.authenticationApp',
273
274
  },
275
+ LOGIN_TELEGRAM: {
276
+ target: '.authentication',
277
+ actions: 'setLoginTelegram',
278
+ },
274
279
  SET_PLAY: {
275
280
  actions: 'setPlay',
276
281
  },
@@ -353,6 +358,17 @@ export default function (request) {
353
358
  },
354
359
  }
355
360
  }),
361
+ setLoginTelegram: assign((context, event) => {
362
+ const { loginType, additionalUserInfo, isSignature } = event.data
363
+ return {
364
+ loginData: {
365
+ provider: 'telegram',
366
+ loginType,
367
+ additionalUserInfo,
368
+ isSignature,
369
+ },
370
+ }
371
+ }),
356
372
  fetchToken: assign((context, event) => {
357
373
  const token = storage.get(tokenKey)
358
374
  return {
@@ -22,6 +22,8 @@ import crypto_way from './crypto_way.js'
22
22
  import crypto_bank_cash from './crypto_bank_cash.js'
23
23
  import crypto_qrcode_cash from './crypto_qrcode_cash.js'
24
24
  import crypto_way_cash from './crypto_way_cash.js'
25
+ import virtual_bank_vn from './virtual_bank_vn.js'
26
+ import virtual_bank_cash from './virtual_bank_cash.js'
25
27
 
26
28
  export default {
27
29
  manual_vn,
@@ -48,4 +50,6 @@ export default {
48
50
  crypto_bank_cash,
49
51
  crypto_qrcode_cash,
50
52
  crypto_way_cash,
53
+ virtual_bank_vn,
54
+ virtual_bank_cash,
51
55
  }
@@ -0,0 +1,201 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import payment from '@jetthai/cuora/src/api/payment.js'
3
+ import { max } from '@jetthai/cuora/src/util/index.js'
4
+
5
+ export default function (request, context) {
6
+ const { appSecret } = request.config
7
+ const { paymentDetail = [], promotion, selectedAmount, siteConfig = {} } = context || {}
8
+
9
+ return createMachine(
10
+ {
11
+ id: 'virtual_bank_cash',
12
+ initial: 'loading',
13
+ context: {
14
+ siteConfig,
15
+ paymentDetail,
16
+ promotion,
17
+ selectedAmount,
18
+
19
+ bindingPaymentList: {},
20
+ bindingPaymentInfo: {},
21
+ virtualBanks: {},
22
+
23
+ depositTime: null,
24
+
25
+ currentCategory: 'virtualBank',
26
+ method: null,
27
+ currentPayment: null,
28
+ currentApplyerBank: null,
29
+
30
+ calculation: null,
31
+ processing: null,
32
+ },
33
+ states: {
34
+ loading: {
35
+ invoke: {
36
+ src: 'fetchInitData',
37
+ onDone: {
38
+ target: 'checking',
39
+ actions: 'setInitData',
40
+ },
41
+ },
42
+ },
43
+ checking: {
44
+ always: [
45
+ {
46
+ target: 'submitted',
47
+ cond: 'isProcessing',
48
+ },
49
+ {
50
+ target: 'debouncing',
51
+ },
52
+ ],
53
+ },
54
+ loaded: {},
55
+ debouncing: {
56
+ entry: 'clearCalculation',
57
+ after: {
58
+ 1000: [{ target: 'calculating', cond: 'isCalculable' }, { target: 'loaded' }],
59
+ },
60
+ },
61
+ calculating: {
62
+ invoke: {
63
+ src: 'fetchCalculation',
64
+ onDone: {
65
+ target: 'calculated',
66
+ actions: 'setCalculation',
67
+ },
68
+ onError: {
69
+ target: 'loaded',
70
+ },
71
+ },
72
+ },
73
+ calculated: {
74
+ on: {
75
+ SET_DEPOSIT_TIME: {
76
+ actions: 'setDepositTime',
77
+ },
78
+ SUBMIT: {
79
+ target: 'submitting',
80
+ },
81
+ },
82
+ },
83
+ submitting: {
84
+ invoke: {
85
+ src: 'submitDeposit',
86
+ onDone: {
87
+ target: 'submitted',
88
+ actions: 'setProcessing',
89
+ },
90
+ onError: {
91
+ target: 'loaded',
92
+ },
93
+ },
94
+ },
95
+ submitted: {},
96
+ },
97
+ on: {
98
+ SET_PROMOTION: {
99
+ target: 'debouncing',
100
+ actions: 'setPromotion',
101
+ internal: false,
102
+ },
103
+ INPUT_AMOUNT: {
104
+ target: 'debouncing',
105
+ actions: 'inputAmount',
106
+ internal: false,
107
+ },
108
+ },
109
+ },
110
+ {
111
+ actions: {
112
+ setInitData: assign((context, event) => {
113
+ const { currentPayment } = event.data
114
+
115
+ const processing = currentPayment?.processing?.[0]
116
+
117
+ const virtualBanks = currentPayment?.virtualBanks?.[0]
118
+
119
+ return {
120
+ currentPayment,
121
+ method: currentPayment.method,
122
+ processing,
123
+ selectedAmount: max(promotion?.minimumAmount, currentPayment?.minimum, selectedAmount, 0),
124
+ virtualBanks,
125
+ }
126
+ }),
127
+ inputAmount: assign((context, event) => {
128
+ return { selectedAmount: event.data }
129
+ }),
130
+ setCalculation: assign((context, event) => {
131
+ return {
132
+ calculation: event.data,
133
+ }
134
+ }),
135
+ setProcessing: assign((context, event) => {
136
+ return {
137
+ processing: event.data,
138
+ }
139
+ }),
140
+ clearCalculation: assign((context, event) => {
141
+ return {
142
+ calculation: null,
143
+ }
144
+ }),
145
+ setDepositTime: assign((context, event) => {
146
+ return {
147
+ depositTime: event.data,
148
+ }
149
+ }),
150
+ setPromotion: assign((context, event) => {
151
+ return {
152
+ promotion: event.data,
153
+ }
154
+ }),
155
+ },
156
+ guards: {
157
+ isCalculable: (context, event) => {
158
+ const {
159
+ selectedAmount,
160
+ currentPayment: { maximum, minimum },
161
+ } = context
162
+ return selectedAmount && minimum <= +selectedAmount && +selectedAmount <= maximum
163
+ },
164
+ isProcessing: (context, event) => {
165
+ return context.processing
166
+ },
167
+ },
168
+ services: {
169
+ fetchInitData: async (context, event) => {
170
+ const { paymentDetail = [] } = context
171
+ const currentPayment = paymentDetail.find((element) => element.category === context.currentCategory && element.transferType === 'deposit')
172
+
173
+ return {
174
+ currentPayment,
175
+ }
176
+ },
177
+ fetchCalculation: async (context, event) => {
178
+ const { method, selectedAmount, promotion } = context
179
+ return await request.send(
180
+ payment.getDepositExpectedResult({
181
+ method,
182
+ amount: selectedAmount,
183
+ promotionsNo: promotion?.promotionsNo,
184
+ })
185
+ )
186
+ },
187
+ submitDeposit: async (context, event) => {
188
+ const { method, selectedAmount, depositTime, promotion } = context
189
+ return await request.send(
190
+ payment.submitDepositTransactionBank({
191
+ method,
192
+ amount: selectedAmount,
193
+ depositTime,
194
+ promotionsNo: promotion?.promotionsNo,
195
+ })
196
+ )
197
+ },
198
+ },
199
+ }
200
+ )
201
+ }
@@ -0,0 +1,289 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import payment from '../../api/payment.js'
3
+
4
+ export default function (request) {
5
+ const { appSecret } = request.config
6
+
7
+ return createMachine(
8
+ {
9
+ id: 'virtual_bank',
10
+ initial: 'loading',
11
+ context: {
12
+ siteConfig: null,
13
+ paymentDetail: [],
14
+ virtualBanks: {},
15
+
16
+ amount: null,
17
+ depositTime: null,
18
+
19
+ currentCategory: 'virtualBank',
20
+ method: null,
21
+ currentPayment: null,
22
+
23
+ calculation: null,
24
+ processing: null,
25
+
26
+ // use for wallet mode 3
27
+ promotion: null,
28
+ },
29
+ states: {
30
+ loading: {
31
+ initial: 'init',
32
+ states: {
33
+ init: {
34
+ invoke: {
35
+ src: 'fetchPaymentDetail',
36
+ onDone: {
37
+ target: '#virtual_bank.step1',
38
+ actions: 'setInitData',
39
+ },
40
+ onError: {
41
+ target: '#virtual_bank.fail',
42
+ },
43
+ },
44
+ },
45
+ },
46
+ },
47
+ step1: {
48
+ initial: 'promotion',
49
+ states: {
50
+ promotion: {
51
+ always: [
52
+ {
53
+ target: 'idle',
54
+ cond: 'isDoubleWalletMode',
55
+ },
56
+ {
57
+ target: 'calculating',
58
+ actions: 'setPromotionDefaultAmount',
59
+ cond: 'hasMinPromotionDeposit',
60
+ },
61
+ {
62
+ target: 'idle',
63
+ },
64
+ ],
65
+ },
66
+ idle: {},
67
+ calculating: {
68
+ invoke: {
69
+ src: 'fetchCalculation',
70
+ onDone: {
71
+ target: 'idle',
72
+ actions: 'setCalculation',
73
+ },
74
+ onError: {
75
+ target: 'idle',
76
+ },
77
+ },
78
+ },
79
+ debouncing: {
80
+ after: {
81
+ 1000: [{ target: 'calculating', cond: 'isCalculable' }, { target: 'idle' }],
82
+ },
83
+ },
84
+ },
85
+ on: {
86
+ SET_AMOUNT: {
87
+ actions: ['setAmount', 'clearCalculation'],
88
+ },
89
+ CALCULATE: {
90
+ target: '.debouncing',
91
+ },
92
+ CLEAR_CALCULATION: {
93
+ target: '.debouncing',
94
+ actions: 'clearCalculation',
95
+ },
96
+ TRANSACT: {
97
+ target: 'checking',
98
+ cond: 'isCalculated',
99
+ },
100
+ },
101
+ },
102
+ checking: {
103
+ always: [
104
+ {
105
+ target: 'pending',
106
+ cond: (context, event) => {
107
+ const { siteConfig = {}, calculation, promotion } = context
108
+ const { walletMode } = siteConfig
109
+ const { promotionsNo, activityNo } = promotion
110
+ const isNoBonus = promotionsNo === 'none' || activityNo === 'none'
111
+ return walletMode === '4' && !!calculation && !isNoBonus
112
+ },
113
+ },
114
+ {
115
+ target: '#virtual_bank.step2',
116
+ },
117
+ ],
118
+ },
119
+ pending: {
120
+ on: {
121
+ CONFIRM: {
122
+ target: '#virtual_bank.step2',
123
+ },
124
+ },
125
+ },
126
+ step2: {
127
+ initial: 'idle',
128
+ states: {
129
+ idle: {},
130
+ calculating: {
131
+ invoke: {
132
+ src: 'fetchCalculation',
133
+ onDone: {
134
+ target: 'idle',
135
+ actions: 'setCalculation',
136
+ },
137
+ onError: {
138
+ target: 'idle',
139
+ },
140
+ },
141
+ },
142
+ debouncing: {
143
+ after: {
144
+ 1000: [{ target: 'calculating', cond: 'isCalculable' }, { target: 'idle' }],
145
+ },
146
+ },
147
+ submitting: {
148
+ invoke: {
149
+ src: 'submitDeposit',
150
+ onDone: {
151
+ target: '#virtual_bank.submitted',
152
+ actions: 'setProcessing',
153
+ },
154
+ onError: {
155
+ target: 'idle',
156
+ },
157
+ },
158
+ },
159
+ },
160
+ on: {
161
+ SET_AMOUNT: {
162
+ actions: ['setAmount', 'clearCalculation'],
163
+ },
164
+ CALCULATE: {
165
+ target: '.debouncing',
166
+ },
167
+ SET_DEPOSIT_TIME: {
168
+ actions: 'setDepositTime',
169
+ },
170
+ CLEAR_CALCULATION: {
171
+ target: '.debouncing',
172
+ actions: 'clearCalculation',
173
+ },
174
+ SUBMIT: {
175
+ target: '.submitting',
176
+ },
177
+ },
178
+ },
179
+ processing: {},
180
+ submitted: {},
181
+ fail: {},
182
+ },
183
+ on: {
184
+ SET_PROMOTION: {
185
+ actions: 'setPromotion',
186
+ },
187
+ },
188
+ },
189
+ {
190
+ actions: {
191
+ setInitData: assign((context, event) => {
192
+ const paymentDetail = event.data || []
193
+ const currentPayment = paymentDetail.find((element) => element.category === context.currentCategory)
194
+ const { method, processing, virtualBanks } = currentPayment || {}
195
+
196
+ return {
197
+ paymentDetail,
198
+ currentPayment,
199
+ method,
200
+ processing: processing?.[0],
201
+ virtualBanks: virtualBanks?.[0],
202
+ }
203
+ }),
204
+ setAmount: assign((context, event) => {
205
+ return {
206
+ amount: event.data,
207
+ }
208
+ }),
209
+ setCalculation: assign((context, event) => {
210
+ return {
211
+ calculation: event.data,
212
+ }
213
+ }),
214
+ setProcessing: assign((context, event) => {
215
+ return {
216
+ processing: event.data,
217
+ }
218
+ }),
219
+ clearCalculation: assign((context, event) => {
220
+ return {
221
+ calculation: null,
222
+ }
223
+ }),
224
+ setDepositTime: assign((context, event) => {
225
+ return {
226
+ depositTime: event.data,
227
+ }
228
+ }),
229
+ setPromotion: assign((context, event) => {
230
+ return {
231
+ promotion: event.data,
232
+ }
233
+ }),
234
+ setPromotionDefaultAmount: assign((context, event) => {
235
+ return {
236
+ amount: context.promotion.minimumAmount,
237
+ }
238
+ }),
239
+ },
240
+ guards: {
241
+ isDoubleWalletMode: (context, event) => {
242
+ return context.siteConfig?.walletMode === '4'
243
+ },
244
+ isCalculable: (context, event) => {
245
+ const {
246
+ amount,
247
+ currentPayment: { maximum, minimum },
248
+ } = context
249
+ return amount && minimum <= +amount && +amount <= maximum
250
+ },
251
+ isCalculated: (context, event) => {
252
+ return context.calculation
253
+ },
254
+ isProcessing: (context, event) => {
255
+ return context.processing
256
+ },
257
+ hasMinPromotionDeposit: (context, event) => {
258
+ return context.promotion?.minimumAmount
259
+ },
260
+ },
261
+ services: {
262
+ fetchPaymentDetail: async (context, event) => {
263
+ return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
264
+ },
265
+ fetchCalculation: async (context, event) => {
266
+ const { method, amount, promotion } = context
267
+ return await request.send(
268
+ payment.getDepositExpectedResult({
269
+ method,
270
+ amount,
271
+ promotionsNo: promotion?.activityNo,
272
+ })
273
+ )
274
+ },
275
+ submitDeposit: async (context, event) => {
276
+ const { method, amount, depositTime, promotion } = context
277
+ return await request.send(
278
+ payment.submitDepositTransactionBank({
279
+ method,
280
+ amount,
281
+ depositTime,
282
+ promotionsNo: promotion?.activityNo,
283
+ })
284
+ )
285
+ },
286
+ },
287
+ }
288
+ )
289
+ }
@@ -0,0 +1,46 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import game from '../api/game.js'
3
+
4
+ export default function (request, context) {
5
+ // const { appSecret } = request.config
6
+ const { providerId, seqNo, lang } = context
7
+ return createMachine(
8
+ {
9
+ id: 'game_replay',
10
+ initial: 'fetching',
11
+ context: {
12
+ gameReplayInfo: {},
13
+ },
14
+ states: {
15
+ fetching: {
16
+ invoke: {
17
+ src: 'fetchGameReplayInfo',
18
+ onDone: {
19
+ target: 'idle',
20
+ actions: 'setGameReplayInfo',
21
+ },
22
+ onError: {
23
+ target: 'idle',
24
+ },
25
+ },
26
+ },
27
+ idle: {},
28
+ },
29
+ },
30
+ {
31
+ actions: {
32
+ setGameReplayInfo: assign((context, event) => {
33
+ return {
34
+ gameReplayInfo: event.data.data,
35
+ }
36
+ }),
37
+ },
38
+ services: {
39
+ // 取得遊戲重播資訊
40
+ fetchGameReplayInfo: async (context, event) => {
41
+ return await request.send(game.getGameReplayInfo({ providerId, seqNo, lang }))
42
+ },
43
+ },
44
+ }
45
+ )
46
+ }
@@ -9,6 +9,7 @@ import game_search_cash from './game_search_cash.js'
9
9
  import game_search_v2 from './game_search_v2.js'
10
10
  import game_hot_new from './game_hot_new.js'
11
11
  import game_info from './game_info.js'
12
+ import game_replay from './game_replay.js'
12
13
  import inbox from './inbox.js'
13
14
  import merge from './merge.js'
14
15
  import payment_data from './payment_data.js'
@@ -37,6 +38,7 @@ import honor_board_cash from './honor_board_cash.js'
37
38
  import honor_board from './honor_board.js'
38
39
  import user_photo from './user_photo.js'
39
40
  import navbar from './navbar.js'
41
+ import websocket from './websocket.js'
40
42
 
41
43
  export default {
42
44
  ...activity,
@@ -49,6 +51,7 @@ export default {
49
51
  game_search_v2,
50
52
  game_hot_new,
51
53
  game_info,
54
+ game_replay,
52
55
  inbox,
53
56
  merge,
54
57
  payment_data,
@@ -78,4 +81,5 @@ export default {
78
81
  user_photo,
79
82
  navbar,
80
83
  ...withdraw,
84
+ websocket,
81
85
  }