@jetthai/cuora 1.1.353-dev-19 → 1.1.353

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.
@@ -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) => {
@@ -1,27 +0,0 @@
1
- export default {
2
- // 未登入排名資料
3
- getTournament: ({ activityNo, cycle, round, site }) => ({
4
- url: 'tournament/detail',
5
- method: 'post',
6
- params: { activityNo, cycle, round, site },
7
- isPublic: true,
8
- }),
9
- // 登入後排名預設期數資料
10
- getRankingOptions: ({ activityNo }) => ({
11
- url: 'ranking/detail/option',
12
- method: 'get',
13
- params: { activityNo },
14
- isPublic: true,
15
- }),
16
- // 登入後排名資料
17
- getRankingDetail: ({ activityNo, cycle, round }) => ({
18
- url: 'ranking/detail',
19
- method: 'post',
20
- params: { activityNo, cycle, round },
21
- }),
22
- getRankingGames: ({ activityNo }) => ({
23
- url: 'hot-game/ranking',
24
- method: 'get',
25
- params: { activityNo },
26
- }),
27
- }
@@ -1,216 +0,0 @@
1
- import { createMachine, assign } from 'xstate'
2
- import ranking from '../api/ranking.js'
3
-
4
- export default function (request) {
5
- const cycleMapping = ['DAILY', 'WEEKLY', 'MONTHLY']
6
-
7
- function roundProcess(rounds) {
8
- const roundArrays = rounds.map((round) => Array.from({ length: round }, (_, i) => i + 1))
9
- return roundArrays.reduce((acc, roundArray, index) => {
10
- acc[cycleMapping[index]] = roundArray.reverse()
11
- return acc
12
- }, {})
13
- }
14
-
15
- function transGameData(item) {
16
- if (!item) return {}
17
- item.providerId = item.provider
18
- return item
19
- }
20
-
21
- return createMachine(
22
- {
23
- id: 'ranking',
24
- initial: 'idle',
25
- context: {
26
- auth: false,
27
- site: '',
28
- activityNo: '',
29
- // api options 回傳的資料
30
- currentRound: [],
31
- cycle: '',
32
- round: 0,
33
- rule: '',
34
- // api detail 資料
35
- description: '',
36
- descriptionUrl: [],
37
- // api detail 排名資料
38
- playerRanking: {},
39
- gameRanking: [],
40
- topRanking: [],
41
- settleStatus: false,
42
- // 前端這邊用的選單資料 { cycle, round }
43
- options: {},
44
- },
45
- states: {
46
- idle: {
47
- on: {
48
- SET_ACTIVITY: {
49
- target: 'loading',
50
- },
51
- SET_OPTIONS: {
52
- target: 'setting',
53
- },
54
- },
55
- },
56
- loading: {
57
- entry: 'setActivity',
58
- always: [{ target: 'getRankingOptions' }],
59
- },
60
- setting: {
61
- entry: 'setOptions',
62
- always: [{ target: 'getRankingDetail', cond: 'hasAuth' }, { target: 'getTournament' }],
63
- },
64
- // 取得排名選單資料
65
- getRankingOptions: {
66
- invoke: {
67
- src: 'fetchRankingOptions',
68
- onDone: {
69
- target: 'decideNextAfterOptions',
70
- actions: 'setRankingOptions',
71
- },
72
- onError: {
73
- target: 'idle',
74
- },
75
- },
76
- },
77
- // 取得排名選單資料後的跳轉
78
- decideNextAfterOptions: {
79
- always: [
80
- // 有登入且為冠軍: 先拿遊戲排行榜再拿排行榜資料
81
- { target: 'getRankingGames', cond: 'canGetGameRanking' },
82
- // 有登入但不為冠軍活動: 直接拿排行榜資料
83
- { target: 'getRankingDetail', cond: 'hasAuth' },
84
- // 未登入; 拿未登入的排行榜資料
85
- { target: 'getTournament' },
86
- ],
87
- },
88
- // 未登入時取得排名資料
89
- getTournament: {
90
- invoke: {
91
- src: 'fetchTournament',
92
- onDone: {
93
- target: 'idle',
94
- actions: 'setRanking',
95
- },
96
- onError: {
97
- target: 'idle',
98
- },
99
- },
100
- },
101
- // 登入後取得排名資料
102
- getRankingDetail: {
103
- invoke: {
104
- src: 'fetchRankingDetail',
105
- onDone: {
106
- target: 'idle',
107
- actions: 'setRanking',
108
- },
109
- onError: {
110
- target: 'idle',
111
- },
112
- },
113
- },
114
- getRankingGames: {
115
- invoke: {
116
- src: 'fetchRankingGames',
117
- onDone: {
118
- target: 'getRankingDetail',
119
- actions: 'setRankingGames',
120
- },
121
- onError: {
122
- target: 'idle',
123
- },
124
- },
125
- },
126
- },
127
- },
128
- {
129
- actions: {
130
- setActivity: assign((context, event) => {
131
- return {
132
- site: event.data?.site,
133
- auth: !!request.getToken(),
134
- activityNo: event.data?.activityNo,
135
- }
136
- }),
137
- setRanking: assign((context, event) => {
138
- const topRanking = event.data?.topRanking?.map((rank) => transGameData(rank)) || []
139
- return {
140
- description: event.data?.description,
141
- descriptionUrl: event.data?.descriptionUrl,
142
- topRanking: topRanking,
143
- playerRanking: transGameData(event.data?.playerRanking) || {},
144
- settleStatus: !!topRanking[0]?.settleStatus,
145
- }
146
- }),
147
- setRankingGames: assign((context, event) => {
148
- const gameRanking = event.data?.map((rank) => transGameData(rank))
149
- return {
150
- gameRanking: gameRanking || [],
151
- }
152
- }),
153
- setRankingOptions: assign((context, event) => {
154
- const cycle = event.data?.cycle
155
- const currentRound = event.data?.currentRound || []
156
- // 取得結算週期選單列表
157
- const cycleOptions = cycleMapping.slice(0, currentRound.length)
158
- // 取得每週期的歷史期數選單列表
159
- const roundOptions = roundProcess(currentRound)
160
- // 如果是月結算,則加入全部選項
161
- if (cycle === 'MONTHLY') {
162
- cycleOptions.push('ALL')
163
- roundOptions.ALL = roundOptions.MONTHLY
164
- }
165
- return {
166
- ...event.data,
167
- options: { cycle: cycleOptions, round: roundOptions },
168
- // 初始固定顯示 DAILY
169
- cycle: event.data?.rule !== 'NORMAL' ? 'DAILY' : cycle,
170
- round: currentRound[0],
171
- }
172
- }),
173
- setOptions: assign((context, event) => {
174
- const { cycle, round } = context
175
- // 處理變更 cycle,如果沒有輸入或沒有變更就不更新
176
- if (event.data?.cycle && cycle !== event.data?.cycle) {
177
- const { currentRound } = context
178
- const cycleForRound = event.data?.cycle === 'ALL' ? 'MONTHLY' : event.data?.cycle
179
- const cycleIndex = cycleMapping.indexOf(cycleForRound)
180
- return { cycle: event.data?.cycle, round: currentRound[cycleIndex] }
181
- }
182
- if (event.data?.round && round !== event.data?.round) {
183
- return { round: event.data?.round }
184
- }
185
- return {}
186
- }),
187
- },
188
- guards: {
189
- hasAuth: (context) => context.auth,
190
- canGetGameRanking: (context) => context.auth && context.rule === 'CHAMPION',
191
- },
192
- services: {
193
- fetchTournament: async (context) => {
194
- const { activityNo, cycle, round, site } = context
195
- const { data } = await request.send(ranking.getTournament({ activityNo, cycle, round, site }))
196
- return data
197
- },
198
- fetchRankingOptions: async (context) => {
199
- const { activityNo } = context
200
- const { data } = await request.send(ranking.getRankingOptions({ activityNo }))
201
- return data
202
- },
203
- fetchRankingDetail: async (context, event) => {
204
- const { activityNo, cycle, round } = context
205
- const { data } = await request.send(ranking.getRankingDetail({ activityNo, cycle, round }))
206
- return data
207
- },
208
- fetchRankingGames: async (context) => {
209
- const { activityNo } = context
210
- const { data } = await request.send(ranking.getRankingGames({ activityNo }))
211
- return data
212
- },
213
- },
214
- }
215
- )
216
- }