@jetthai/cuora 1.1.362 → 1.1.364-dev-5

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.
@@ -3,13 +3,11 @@ import ranking from '../api/ranking.js'
3
3
 
4
4
  export default function (request) {
5
5
  const cycleMapping = ['DAILY', 'WEEKLY', 'MONTHLY']
6
- const limit = { DAILY: 56, WEEKLY: 8, MONTHLY: 2, ALL: 2 }
7
6
 
8
- function roundProcess(rounds, cycles) {
7
+ function roundProcess(rounds) {
9
8
  const roundArrays = rounds.map((round) => Array.from({ length: round }, (_, i) => i + 1))
10
9
  return roundArrays.reduce((acc, roundArray, index) => {
11
- const max = limit[cycles[index]] || rounds[index] // 若沒限制則取全部
12
- acc[cycles[index]] = roundArray.reverse().slice(0, max)
10
+ acc[cycleMapping[index]] = roundArray.reverse()
13
11
  return acc
14
12
  }, {})
15
13
  }
@@ -26,7 +24,6 @@ export default function (request) {
26
24
  initial: 'idle',
27
25
  context: {
28
26
  auth: false,
29
- site: '',
30
27
  activityNo: '',
31
28
  // api options 回傳的資料
32
29
  currentRound: [],
@@ -57,43 +54,32 @@ export default function (request) {
57
54
  },
58
55
  loading: {
59
56
  entry: 'setActivity',
60
- always: [{ target: 'getRankingOptions' }],
57
+ always: [{ target: 'getRankingOptions', cond: 'hasAuth' }, { target: 'getTournament' }],
61
58
  },
62
59
  setting: {
63
60
  entry: 'setOptions',
64
- always: [{ target: 'getRankingDetail', cond: 'hasAuth' }, { target: 'getTournament' }],
61
+ always: [{ target: 'getRankingDetail' }],
65
62
  },
66
- // 取得排名選單資料
67
- getRankingOptions: {
63
+ // 未登入時取得排名資料
64
+ getTournament: {
68
65
  invoke: {
69
- src: 'fetchRankingOptions',
66
+ src: 'fetchTournament',
70
67
  onDone: {
71
- target: 'decideNextAfterOptions',
72
- actions: 'setRankingOptions',
68
+ target: 'idle',
69
+ actions: 'setRanking',
73
70
  },
74
71
  onError: {
75
72
  target: 'idle',
76
73
  },
77
74
  },
78
75
  },
79
- // 取得排名選單資料後的跳轉
80
- decideNextAfterOptions: {
81
- always: [
82
- // 有登入且為冠軍: 先拿遊戲排行榜再拿排行榜資料
83
- { target: 'getRankingGames', cond: 'canGetGameRanking' },
84
- // 有登入但不為冠軍活動: 直接拿排行榜資料
85
- { target: 'getRankingDetail', cond: 'hasAuth' },
86
- // 未登入; 拿未登入的排行榜資料
87
- { target: 'getTournament' },
88
- ],
89
- },
90
- // 未登入時取得排名資料
91
- getTournament: {
76
+ // 登入後取得排名選單資料
77
+ getRankingOptions: {
92
78
  invoke: {
93
- src: 'fetchTournament',
79
+ src: 'fetchRankingOptions',
94
80
  onDone: {
95
- target: 'idle',
96
- actions: 'setRanking',
81
+ target: 'getRankingGames',
82
+ actions: 'setRankingOptions',
97
83
  },
98
84
  onError: {
99
85
  target: 'idle',
@@ -131,7 +117,6 @@ export default function (request) {
131
117
  actions: {
132
118
  setActivity: assign((context, event) => {
133
119
  return {
134
- site: event.data?.site,
135
120
  auth: !!request.getToken(),
136
121
  activityNo: event.data?.activityNo,
137
122
  }
@@ -153,14 +138,14 @@ export default function (request) {
153
138
  }
154
139
  }),
155
140
  setRankingOptions: assign((context, event) => {
156
- const isChampion = event.data?.rule === 'CHAMPION'
157
141
  const cycle = event.data?.cycle
158
142
  const currentRound = event.data?.currentRound || []
159
143
  // 取得結算週期選單列表
160
- const cycleOptions = isChampion ? cycleMapping.slice(0, currentRound.length) : [cycle]
161
- const roundOptions = roundProcess(currentRound, cycleOptions)
162
- // 如果是冠軍龍虎月結算,則加入全部選項
163
- if (cycle === 'MONTHLY' && isChampion) {
144
+ const cycleOptions = cycleMapping.slice(0, currentRound.length)
145
+ // 取得每週期的歷史期數選單列表
146
+ const roundOptions = roundProcess(currentRound)
147
+ // 如果是月結算,則加入全部選項
148
+ if (cycle === 'MONTHLY') {
164
149
  cycleOptions.push('ALL')
165
150
  roundOptions.ALL = roundOptions.MONTHLY
166
151
  }
@@ -168,7 +153,7 @@ export default function (request) {
168
153
  ...event.data,
169
154
  options: { cycle: cycleOptions, round: roundOptions },
170
155
  // 初始固定顯示 DAILY
171
- cycle: isChampion ? 'DAILY' : cycle,
156
+ cycle: event.data?.rule !== 'NORMAL' ? 'DAILY' : cycle,
172
157
  round: currentRound[0],
173
158
  }
174
159
  }),
@@ -189,12 +174,11 @@ export default function (request) {
189
174
  },
190
175
  guards: {
191
176
  hasAuth: (context) => context.auth,
192
- canGetGameRanking: (context) => context.auth && context.rule === 'CHAMPION',
193
177
  },
194
178
  services: {
195
179
  fetchTournament: async (context) => {
196
- const { activityNo, cycle, round, site } = context
197
- const { data } = await request.send(ranking.getTournament({ activityNo, cycle, round, site }))
180
+ const { activityNo } = context
181
+ const { data } = await request.send(ranking.getTournament({ activityNo }))
198
182
  return data
199
183
  },
200
184
  fetchRankingOptions: async (context) => {
@@ -18,7 +18,6 @@ export default function (request) {
18
18
  rewardType: null,
19
19
  isPlaying: false,
20
20
  callback: () => {},
21
- orderColumn: 'createTime',
22
21
  },
23
22
  states: {
24
23
  timer: {
@@ -38,7 +37,7 @@ export default function (request) {
38
37
  },
39
38
  pending: {
40
39
  after: {
41
- 20000: [{ target: 'loading', cond: 'isNotInGame' }, { target: 'pending' }],
40
+ 20000: { target: 'loading', cond: 'isNotInGame' },
42
41
  },
43
42
  },
44
43
  },
@@ -57,10 +56,6 @@ export default function (request) {
57
56
  target: 'fetching',
58
57
  actions: 'setRewardData',
59
58
  },
60
- FETCH_OTHER_REWARD: {
61
- target: 'fetchingOtherReward',
62
- actions: 'setOrderColumn',
63
- },
64
59
  RECEIVE_REWARD: {
65
60
  target: 'receiving',
66
61
  actions: ['setCallback', 'setRewardType'],
@@ -86,18 +81,6 @@ export default function (request) {
86
81
  },
87
82
  },
88
83
  },
89
- fetchingOtherReward: {
90
- invoke: {
91
- src: 'fetchOtherRewardList',
92
- onDone: {
93
- target: 'idle',
94
- actions: 'setOtherRewardList',
95
- },
96
- onError: {
97
- target: 'idle',
98
- },
99
- },
100
- },
101
84
  pending: {
102
85
  on: {
103
86
  RECEIVE_REWARD: {
@@ -153,11 +136,6 @@ export default function (request) {
153
136
  rewardList: event.data[2]?.data || [],
154
137
  }
155
138
  }),
156
- setOtherRewardList: assign((context, event) => {
157
- return {
158
- otherRewardList: event.data[0]?.data,
159
- }
160
- }),
161
139
  setRewardData: assign((context, event) => {
162
140
  const { activityNo, receiveNo } = event.data
163
141
  return {
@@ -170,11 +148,6 @@ export default function (request) {
170
148
  callback: event.data?.callback || (() => {}),
171
149
  }
172
150
  }),
173
- setOrderColumn: assign((context, event) => {
174
- return {
175
- orderColumn: event.data?.orderColumn || 'createTime',
176
- }
177
- }),
178
151
  setRewardType: assign((context, event) => {
179
152
  return {
180
153
  rewardType: event.data?.rewardType,
@@ -205,27 +178,12 @@ export default function (request) {
205
178
  },
206
179
  services: {
207
180
  fetchRewardList: async (context, event) => {
208
- const orderColumn = context.orderColumn
209
181
  const getRewardAPI = request.send(activity.getRewardList({ count: 30, appSecret }))
210
182
  const getPointsRewardAPI = request.send(activity.getRewardList({ rewardType: 'POINTS', count: 30, appSecret }))
211
- const getOtherRewardAPI = request.send(activity.getRewardList({ rewardType: 'CASH,FREE,PRIZE', count: 30, appSecret, orderColumn }))
183
+ const getOtherRewardAPI = request.send(activity.getRewardList({ rewardType: 'CASH,FREE,PRIZE', count: 30, appSecret }))
212
184
  const [otherRewardList, pointsRewardList, rewardList] = await Promise.all([getOtherRewardAPI, getPointsRewardAPI, getRewardAPI])
213
185
  return [otherRewardList, pointsRewardList, rewardList]
214
186
  },
215
- fetchOtherRewardList: async (context, event) => {
216
- const orderColumn = context.orderColumn
217
-
218
- const getOtherRewardAPI = request.send(
219
- activity.getRewardList({
220
- rewardType: 'CASH,FREE,PRIZE',
221
- count: 30,
222
- appSecret,
223
- orderColumn,
224
- })
225
- )
226
- const [otherRewardList] = await Promise.all([getOtherRewardAPI])
227
- return [otherRewardList]
228
- },
229
187
  fetchWithdrawRulePreview: async (context, event) => {
230
188
  const { receiveNo } = context
231
189
  const data = await request.send(payment.getWithdrawRulePreview({ applyType: 'activity', applyNo: receiveNo, amount: null }))
@@ -16,8 +16,8 @@ export default function (request) {
16
16
  activityNo: null,
17
17
  receiveNo: null,
18
18
  withdrawRule: {},
19
+ isPlaying: false,
19
20
  callback: () => {},
20
- orderColumn: 'createTime',
21
21
  },
22
22
  states: {
23
23
  timer: {
@@ -47,7 +47,7 @@ export default function (request) {
47
47
  },
48
48
  pending: {
49
49
  after: {
50
- 20000: { target: 'loading' },
50
+ 20000: [{ target: 'loading', cond: 'isNotInGame' }, { target: 'pending' }],
51
51
  },
52
52
  },
53
53
  },
@@ -66,10 +66,6 @@ export default function (request) {
66
66
  target: 'fetching',
67
67
  actions: 'setRewardData',
68
68
  },
69
- FETCH_OTHER_REWARD: {
70
- target: 'fetchingOtherReward',
71
- actions: 'setOrderColumn',
72
- },
73
69
  RECEIVE_REWARD: {
74
70
  target: 'receiving',
75
71
  actions: 'setCallback',
@@ -78,6 +74,9 @@ export default function (request) {
78
74
  target: 'allPointsReceiving',
79
75
  actions: 'setCallback',
80
76
  },
77
+ SET_IS_PLAYING: {
78
+ actions: 'setIsPlaying',
79
+ },
81
80
  },
82
81
  },
83
82
  fetching: {
@@ -92,18 +91,6 @@ export default function (request) {
92
91
  },
93
92
  },
94
93
  },
95
- fetchingOtherReward: {
96
- invoke: {
97
- src: 'fetchOtherRewardList',
98
- onDone: {
99
- target: 'idle',
100
- actions: 'setOtherRewardList',
101
- },
102
- onError: {
103
- target: 'idle',
104
- },
105
- },
106
- },
107
94
  pending: {
108
95
  on: {
109
96
  RECEIVE_REWARD: {
@@ -160,6 +147,11 @@ export default function (request) {
160
147
  },
161
148
  },
162
149
  {
150
+ guards: {
151
+ isNotInGame: (context, event) => {
152
+ return !context.isPlaying
153
+ },
154
+ },
163
155
  actions: {
164
156
  setAuth: assign((context, event) => {
165
157
  return { auth: !!event.data }
@@ -171,11 +163,6 @@ export default function (request) {
171
163
  rewardList: event.data[2]?.data || [],
172
164
  }
173
165
  }),
174
- setOtherRewardList: assign((context, event) => {
175
- return {
176
- otherRewardList: event.data[0]?.data,
177
- }
178
- }),
179
166
  setRewardData: assign((context, event) => {
180
167
  const { activityNo, receiveNo } = event.data
181
168
  return {
@@ -188,11 +175,6 @@ export default function (request) {
188
175
  callback: event.data?.callback || (() => {}),
189
176
  }
190
177
  }),
191
- setOrderColumn: assign((context, event) => {
192
- return {
193
- orderColumn: event.data?.orderColumn || 'createTime',
194
- }
195
- }),
196
178
  doCallback: (context, event) => {
197
179
  context.callback()
198
180
  },
@@ -201,11 +183,15 @@ export default function (request) {
201
183
  withdrawRule: event.data,
202
184
  }
203
185
  }),
186
+ setIsPlaying: assign((context, event) => {
187
+ return {
188
+ isPlaying: event.data,
189
+ }
190
+ }),
204
191
  },
205
192
  services: {
206
193
  fetchRewardList: async (context, event) => {
207
194
  const getRewardAPI = request.send(activity.getRewardList({ count: 30, appSecret }))
208
- const orderColumn = context.orderColumn
209
195
  const getPointsRewardAPI = request.send(
210
196
  activity.getRewardList({
211
197
  rewardType: 'POINTS',
@@ -218,26 +204,11 @@ export default function (request) {
218
204
  rewardType: 'CASH,FREE,PRIZE',
219
205
  count: 30,
220
206
  appSecret,
221
- orderColumn,
222
207
  })
223
208
  )
224
209
  const [otherRewardList, pointsRewardList, rewardList] = await Promise.all([getOtherRewardAPI, getPointsRewardAPI, getRewardAPI])
225
210
  return [otherRewardList, pointsRewardList, rewardList]
226
211
  },
227
- fetchOtherRewardList: async (context, event) => {
228
- const orderColumn = context.orderColumn
229
-
230
- const getOtherRewardAPI = request.send(
231
- activity.getRewardList({
232
- rewardType: 'CASH,FREE,PRIZE',
233
- count: 30,
234
- appSecret,
235
- orderColumn,
236
- })
237
- )
238
- const [otherRewardList] = await Promise.all([getOtherRewardAPI])
239
- return [otherRewardList]
240
- },
241
212
  fetchWithdrawRulePreview: async (context, event) => {
242
213
  const { receiveNo } = context
243
214
  const data = await request.send(
@@ -17,9 +17,6 @@ export default function () {
17
17
  idle: {},
18
18
  },
19
19
  on: {
20
- DEFAULT_SETTING: {
21
- actions: 'setSetting',
22
- },
23
20
  MODIFY_SETTING: {
24
21
  actions: 'saveSetting',
25
22
  },
@@ -32,10 +29,6 @@ export default function () {
32
29
  const setting = JSON.parse(localStorage.getItem('setting')) || { sound: soundPlay, music: musicPlay }
33
30
  return { ...setting }
34
31
  }),
35
- setSetting: assign((context, event) => {
36
- const { sound, music, locale } = event.data
37
- return { sound, music, locale }
38
- }),
39
32
  saveSetting: assign((context, event) => {
40
33
  const { sound, music, locale } = event.data
41
34
  localStorage.setItem('setting', JSON.stringify({ sound, music, locale }))
@@ -147,6 +147,7 @@ export default function (request) {
147
147
  },
148
148
  SET_ATTACHMENT_TYPE: {
149
149
  actions: 'setAttachmentType',
150
+ cond: 'isNewWalletMode',
150
151
  },
151
152
  POOL: {
152
153
  target: 'pooling',
@@ -322,7 +323,7 @@ export default function (request) {
322
323
  balance,
323
324
  siteConfig,
324
325
  userInfo,
325
- attachmentType: 'withdraw',
326
+ attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
326
327
  }
327
328
  }),
328
329
  updateWithdrawCondition: assign((context, event) => {
@@ -433,6 +434,7 @@ export default function (request) {
433
434
  isOtpRequired: (context, event) => {
434
435
  return event.data?.status === 'otp-verifying'
435
436
  },
437
+ isNewWalletMode: (context, event) => context.siteConfig.walletMode > 0,
436
438
  },
437
439
  services: {
438
440
  fetchInitData: async (context, event) => {
@@ -355,7 +355,7 @@ export default function (request) {
355
355
  const methods = siteConfig?.paymentMethods?.withdraw || []
356
356
  return {
357
357
  methods,
358
- attachmentType: 'withdraw',
358
+ attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
359
359
  }
360
360
  }),
361
361
  setMode: assign((context, event) => {
@@ -397,8 +397,9 @@ export default function (request) {
397
397
  return { bindingPaymentList, bindingPaymentInfo, boundBanks: combinedData, currentBank: combinedData[0] }
398
398
  }),
399
399
  preset: assign((context, event) => {
400
+ const { siteConfig } = context
400
401
  return {
401
- attachmentType: 'withdraw',
402
+ attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
402
403
  }
403
404
  }),
404
405
  setMode: assign((context, event) => {
@@ -579,7 +580,7 @@ export default function (request) {
579
580
  payment.submitWithdrawTransactionManual({
580
581
  method,
581
582
  amount,
582
- applyerBankCode: currentBank.bankCode || currentBank.walletCode,
583
+ applyerBankCode: currentBank.bankCode,
583
584
  applyerAccountNumber: currentBank.accountNumber,
584
585
  applyerIfscCode: currentBank.ifscCode,
585
586
  branch: branchTemp,
@@ -266,7 +266,7 @@ export default function (request, context) {
266
266
  payment.submitWithdrawTransactionVN({
267
267
  method: currentPayment.method,
268
268
  amount: selectedAmount,
269
- applyerBankCode: selectedUserBank.bankCode || selectedUserBank.walletCode,
269
+ applyerBankCode: selectedUserBank.bankCode,
270
270
  applyerAccountNumber: selectedUserBank.accountNumber,
271
271
  applyerIfscCode: selectedUserBank.ifscCode,
272
272
  branch: branchTemp,
@@ -193,6 +193,7 @@ export default function (request) {
193
193
  },
194
194
  SET_ATTACHMENT_TYPE: {
195
195
  actions: 'setAttachmentType',
196
+ cond: 'isNewWalletMode',
196
197
  },
197
198
  SUBMIT: [
198
199
  {
@@ -358,7 +359,7 @@ export default function (request) {
358
359
  balance,
359
360
  siteConfig,
360
361
  userInfo,
361
- attachmentType: 'withdraw',
362
+ attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
362
363
  }
363
364
  }),
364
365
  updateWithdrawCondition: assign((context, event) => {
@@ -452,6 +453,7 @@ export default function (request) {
452
453
  isOtpRequired: (context, event) => {
453
454
  return event.data?.status === 'otp-verifying'
454
455
  },
456
+ isNewWalletMode: (context, event) => context.siteConfig.walletMode > 0,
455
457
  isNotWithdrawMinDepositAmount: (context, event) => {
456
458
  const { withdrawCheck } = context
457
459
  return !withdrawCheck?.passDepositeLimit
@@ -373,7 +373,7 @@ export default function (request) {
373
373
  const methods = siteConfig?.paymentMethods?.withdraw || []
374
374
  return {
375
375
  methods,
376
- attachmentType: 'withdraw',
376
+ attachmentType: siteConfig.walletMode > 0 ? 'withdraw' : null,
377
377
  }
378
378
  }),
379
379
  setMode: assign((context, event) => {