@jetthai/cuora 1.1.270-dev-5 → 1.1.270-fix

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.
@@ -50,9 +50,6 @@ export default function (request, context) {
50
50
  SUBMIT: {
51
51
  target: 'submitting',
52
52
  },
53
- SUBMIT_CRYPTO: {
54
- target: 'submitting_crypto',
55
- },
56
53
  },
57
54
  },
58
55
  submitting: {
@@ -74,25 +71,6 @@ export default function (request, context) {
74
71
  },
75
72
  },
76
73
  },
77
- submitting_crypto: {
78
- invoke: {
79
- src: 'submitWithdrawCrypto',
80
- onDone: [
81
- {
82
- target: 'otp',
83
- actions: 'setOtp',
84
- cond: 'isOtpRequired',
85
- },
86
- {
87
- target: 'submitted',
88
- actions: 'setProcessing',
89
- },
90
- ],
91
- onError: {
92
- target: 'calculated',
93
- },
94
- },
95
- },
96
74
  submitted: {},
97
75
  otp: {
98
76
  type: 'parallel',
@@ -175,12 +153,25 @@ export default function (request, context) {
175
153
  {
176
154
  actions: {
177
155
  setInitData: assign((context, event) => {
178
- const { currentPayment, paymentInfo, withdrawRule, processing } = event.data
179
- const userBanks = [...paymentInfo.bankList, ...paymentInfo.cryptoList, ...paymentInfo.ewalletList]
156
+ const { currentPayment, banks, paymentInfo, withdrawRule, processing } = event.data
157
+
158
+ const withdrawBanks = (paymentInfo?.bankInfo || [])
159
+ .map((item) => {
160
+ const matchedBank = banks.find((bank) => bank.bankCode === item.bankCode)
161
+ return matchedBank ? { ...item, ...matchedBank } : null
162
+ })
163
+ .filter(Boolean)
164
+
165
+ const userBanks = (withdrawBanks || []).map((bank) => {
166
+ bank.displayText = `${bank.bankCode} - ${bank.accountNumber}`
167
+ bank.imageUrl = banks.find((item) => item.bankCode === bank.bankCode)?.imageUrl
168
+ return bank
169
+ })
180
170
 
181
171
  return {
182
172
  currentPayment,
183
173
  processing,
174
+ banks,
184
175
  paymentInfo,
185
176
  withdrawRule,
186
177
  userBanks,
@@ -243,17 +234,18 @@ export default function (request, context) {
243
234
  },
244
235
  services: {
245
236
  fetchInitData: async (context, event) => {
246
- const { paymentDetail = [] } = context
247
- const currentPayment = paymentDetail.find((element) => element.category === 'manual' && element.transferType === 'withdraw')
237
+ const currentPayment = context.paymentDetail.find((element) => element.category === 'manual' && element.transferType === 'withdraw')
248
238
 
249
- const [paymentInfo, withdrawRule, orders] = await Promise.all([
250
- request.send(payment.getBindingPaymentInfo()),
239
+ const [banks, paymentInfo, withdrawRule, orders] = await Promise.all([
240
+ request.send(payment.getWithdrawBankList()),
241
+ request.send(payment.getPaymentInfo()),
251
242
  request.send(payment.getDoubleWalletWithdrawRule({ walletType: 'CASH' })),
252
243
  request.send(payment.getPendingOrder({ transferType: 'WITHDRAW' })),
253
244
  ])
254
245
 
255
246
  return {
256
247
  currentPayment,
248
+ banks,
257
249
  paymentInfo,
258
250
  withdrawRule,
259
251
  processing: orders[0],
@@ -268,23 +260,8 @@ export default function (request, context) {
268
260
  amount: selectedAmount,
269
261
  applyerBankCode: selectedUserBank.bankCode,
270
262
  applyerAccountNumber: selectedUserBank.accountNumber,
271
- applyerIfscCode: selectedUserBank.ifscCode,
272
263
  branch: branchTemp,
273
- applyerHolderName: selectedUserBank.holderName,
274
- })
275
- )
276
- },
277
- submitWithdrawCrypto: async (context, event) => {
278
- const { currentPayment, selectedUserBank, selectedAmount } = context
279
- const branchTemp = ['GCASH', 'PAYM', 'PIX'].includes(selectedUserBank.bankCode) ? '' : selectedUserBank.branch
280
- return await request.send(
281
- payment.submitWithdrawTransactionCrypto({
282
- method: currentPayment.method,
283
- amount: selectedAmount,
284
- cryptoCurrency: selectedUserBank.cryptoCurrency,
285
- cryptoNetwork: selectedUserBank.cryptoNetwork,
286
- targetAddress: selectedUserBank.cryptoAddress,
287
- applyerHolderName: selectedUserBank.holderName,
264
+ holderName: selectedUserBank.holderName,
288
265
  })
289
266
  )
290
267
  },
@@ -1,57 +0,0 @@
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 { gameCode } = context
7
- return createMachine(
8
- {
9
- id: 'game_info',
10
- initial: 'fetching',
11
- context: {
12
- gameInfo: {},
13
- },
14
- states: {
15
- fetching: {
16
- invoke: {
17
- src: 'fetchGameInfo',
18
- onDone: {
19
- target: 'idle',
20
- actions: 'setGameInfo',
21
- },
22
- onError: {
23
- target: 'idle',
24
- },
25
- },
26
- },
27
- idle: {
28
- // on: {
29
- // SET_GAME_CODE: {
30
- // actions: 'setGameCode',
31
- // },
32
- // },
33
- },
34
- },
35
- },
36
- {
37
- actions: {
38
- setGameInfo: assign((context, event) => {
39
- return {
40
- gameInfo: event.data.data,
41
- }
42
- }),
43
- // setGameCode: assign((context, event) => {
44
- // return {
45
- // gameCode: event.data.data,
46
- // }
47
- // }),
48
- },
49
- services: {
50
- // 取得遊戲資訊
51
- fetchGameInfo: async (context, event) => {
52
- return await request.send(game.getGameInfo({ appSecret, gameCode }))
53
- },
54
- },
55
- }
56
- )
57
- }
@@ -1,65 +0,0 @@
1
- import { assign, createMachine } from 'xstate'
2
- import user from '../api/user.js'
3
-
4
- export default function (request) {
5
- return createMachine(
6
- {
7
- id: 'user_photo',
8
- initial: 'fetching',
9
- context: {
10
- userPhotoList: {},
11
- },
12
- states: {
13
- fetching: {
14
- invoke: {
15
- src: 'fetchUserPhotoList',
16
- onDone: {
17
- target: 'idle',
18
- actions: 'setUserPhotoList',
19
- },
20
- onError: {
21
- target: 'idle',
22
- },
23
- },
24
- },
25
- idle: {
26
- on: {
27
- UPDATE_USER_PHOTO: {
28
- target: 'updating',
29
- },
30
- },
31
- },
32
- updating: {
33
- invoke: {
34
- src: 'updateUserPhoto',
35
- onDone: {
36
- target: 'idle',
37
- },
38
- onError: {
39
- target: 'idle',
40
- },
41
- },
42
- },
43
- },
44
- },
45
- {
46
- actions: {
47
- setUserPhotoList: assign((context, event) => {
48
- return {
49
- userPhotoList: event.data.data,
50
- }
51
- }),
52
- },
53
- services: {
54
- // 取得使用者頭像列表
55
- fetchUserPhotoList: async (context, event) => {
56
- return await request.send(user.getUserPhotoList())
57
- },
58
- // 更新使用者頭像
59
- updateUserPhoto: async (context, event) => {
60
- return await request.send(user.updateUserPhoto(event.data))
61
- },
62
- },
63
- }
64
- )
65
- }