@jetthai/cuora 1.1.341-rank-6 → 1.1.342

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,17 +2,7 @@
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.341-rank-6](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-5...v1.1.341-rank-6) (2025-03-13)
6
-
7
- ### [1.1.341-rank-5](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-4...v1.1.341-rank-5) (2025-03-13)
8
-
9
- ### [1.1.341-rank-4](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-3...v1.1.341-rank-4) (2025-03-12)
10
-
11
- ### [1.1.341-rank-3](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-2...v1.1.341-rank-3) (2025-03-10)
12
-
13
- ### [1.1.341-rank-2](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-1...v1.1.341-rank-2) (2025-03-06)
14
-
15
- ### [1.1.341-rank-1](https://github.com/jetthai/cuora-module/compare/v1.1.341...v1.1.341-rank-1) (2025-03-05)
5
+ ### [1.1.342](https://github.com/jetthai/cuora-module/compare/v1.1.341...v1.1.342) (2025-03-10)
16
6
 
17
7
  ### [1.1.341](https://github.com/jetthai/cuora-module/compare/v1.1.340...v1.1.341) (2025-02-25)
18
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.341-rank-6",
3
+ "version": "1.1.342",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
package/src/api/index.js CHANGED
@@ -6,6 +6,5 @@ import mailbox from './mailbox.js'
6
6
  import payment from './payment.js'
7
7
  import user from './user.js'
8
8
  import form from './form.js'
9
- import ranking from './ranking.js'
10
9
 
11
- export default { activity, auth, common, game, mailbox, payment, user, form, ranking }
10
+ export default { activity, auth, common, game, mailbox, payment, user, form }
@@ -40,11 +40,13 @@ export default function (request) {
40
40
  gameCode: null,
41
41
  name: null,
42
42
  },
43
+ walletMode: null,
43
44
  lang: 'en_US',
44
45
  isMobile: new UAParser().getResult().device.type,
45
46
  gameURL: null,
46
47
  gameToken: null,
47
48
  gameHtml: null,
49
+ gameWalletType: null,
48
50
  switchGame: null,
49
51
  isPlaying: false,
50
52
  ...oldContext,
@@ -80,7 +82,7 @@ export default function (request) {
80
82
  },
81
83
  ENTER_GAME: {
82
84
  target: 'connecting',
83
- actions: ['setGameInfo', 'setLang'],
85
+ actions: ['setGameInfo', 'setLang', 'setWalletMode'],
84
86
  },
85
87
  MENU_ENTER_GAME: {
86
88
  target: 'connecting',
@@ -449,6 +451,9 @@ export default function (request) {
449
451
  gameURL: (context, event) => {
450
452
  return event.data.gameURL
451
453
  },
454
+ gameWalletType: (context, event) => {
455
+ return event.data.gameWalletType
456
+ },
452
457
  }),
453
458
  clearGameInfo: assign((context, event) => {
454
459
  return { game: { providerId: null, gameId: null, gameTypeId: null, mappingId: null } }
@@ -464,6 +469,9 @@ export default function (request) {
464
469
  const { providerId, gameId, gameTypeId, mappingId, portrait, gameCode, name } = context.switchGame
465
470
  return { game: { providerId, gameId, gameTypeId, mappingId, portrait: portrait ? 1 : 0, gameCode, name } }
466
471
  }),
472
+ setWalletMode: assign((context, event) => {
473
+ return { walletMode: event.data.walletMode }
474
+ }),
467
475
  setLang: assign((context, event) => {
468
476
  const lang = event.data.locale.replace('-', '_')
469
477
  return { lang }
@@ -605,7 +613,7 @@ export default function (request) {
605
613
  },
606
614
  connectGame: async (context, event) => {
607
615
  const returnProviders = ['RSG', 'KP', 'EPICWIN', 'AMBSLOT', 'SEXY_VENUS', 'SEXY_SEXYBCRT', 'PG', 'NPG']
608
- const { lang, isMobile } = context
616
+ const { lang, isMobile, walletMode } = context
609
617
  const { providerId, gameId, gameTypeId, mappingId } = context.game
610
618
  const params = {
611
619
  provider_id: providerId,
@@ -615,10 +623,11 @@ export default function (request) {
615
623
  is_demo: false,
616
624
  is_mobile: isMobile === 'mobile' ? 'y' : null,
617
625
  lang,
626
+ selected_wallet_type: walletMode,
618
627
  return_url: returnProviders.includes(providerId) ? `${window.location.origin}${context.base}return` : window.location.href, // For providers to return.
619
628
  }
620
- const { type, redirect_url, gameToken, gameHtml } = await request.send(api.playGame(params))
621
- return { type, gameToken, gameHtml, gameURL: redirect_url }
629
+ const { type, redirect_url, gameToken, gameHtml, wallet_type } = await request.send(api.playGame(params))
630
+ return { type, gameToken, gameHtml, gameURL: redirect_url, gameWalletType: wallet_type }
622
631
  },
623
632
  disconnectGame: async (context, event) => {
624
633
  const uid_site = event.data
@@ -39,7 +39,6 @@ import honor_board from './honor_board.js'
39
39
  import user_photo from './user_photo.js'
40
40
  import navbar from './navbar.js'
41
41
  import websocket from './websocket.js'
42
- import dragon_tiger_ranking from './dragon_tiger_ranking.js'
43
42
 
44
43
  export default {
45
44
  ...activity,
@@ -83,5 +82,4 @@ export default {
83
82
  navbar,
84
83
  ...withdraw,
85
84
  websocket,
86
- dragon_tiger_ranking,
87
85
  }
@@ -1,26 +0,0 @@
1
- export default {
2
- // 未登入排名資料
3
- getTournament: ({ activityNo }) => ({
4
- url: 'tournament/detail',
5
- method: 'get',
6
- params: { activityNo },
7
- isPublic: true,
8
- }),
9
- // 登入後排名預設期數資料
10
- getRankingOptions: ({ activityNo }) => ({
11
- url: 'ranking/detail/option',
12
- method: 'get',
13
- params: { activityNo },
14
- }),
15
- // 登入後排名資料
16
- getRankingDetail: ({ activityNo, cycle, round }) => ({
17
- url: 'ranking/detail',
18
- method: 'post',
19
- params: { activityNo, cycle, round },
20
- }),
21
- getRankingGames: ({ activityNo }) => ({
22
- url: 'hot-game/ranking',
23
- method: 'get',
24
- params: { activityNo },
25
- }),
26
- }
@@ -1,202 +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: 'dragon_tiger_ranking',
24
- initial: 'idle',
25
- context: {
26
- auth: false,
27
- activityNo: '',
28
- // api options 回傳的資料
29
- currentRound: [],
30
- cycle: '',
31
- round: 0,
32
- rule: '',
33
- // api detail 資料
34
- description: '',
35
- descriptionUrl: [],
36
- // api detail 排名資料
37
- playerRanking: {},
38
- gameRanking: [],
39
- topRanking: [],
40
- settleStatus: false,
41
- // 前端這邊用的選單資料 { cycle, round }
42
- options: {},
43
- },
44
- states: {
45
- idle: {
46
- on: {
47
- SET_ACTIVITY: {
48
- target: 'loading',
49
- },
50
- SET_OPTIONS: {
51
- target: 'setting',
52
- },
53
- },
54
- },
55
- loading: {
56
- entry: 'setActivity',
57
- always: [{ target: 'getRankingOptions', cond: 'hasAuth' }, { target: 'getTournament' }],
58
- },
59
- setting: {
60
- entry: 'setOptions',
61
- always: [{ target: 'getRankingDetail' }],
62
- },
63
- // 未登入時取得排名資料
64
- getTournament: {
65
- invoke: {
66
- src: 'fetchTournament',
67
- onDone: {
68
- target: 'idle',
69
- actions: 'setRanking',
70
- },
71
- onError: {
72
- target: 'idle',
73
- },
74
- },
75
- },
76
- // 登入後取得排名選單資料
77
- getRankingOptions: {
78
- invoke: {
79
- src: 'fetchRankingOptions',
80
- onDone: {
81
- target: 'getRankingGames',
82
- actions: 'setRankingOptions',
83
- },
84
- onError: {
85
- target: 'idle',
86
- },
87
- },
88
- },
89
- // 登入後取得排名資料
90
- getRankingDetail: {
91
- invoke: {
92
- src: 'fetchRankingDetail',
93
- onDone: {
94
- target: 'idle',
95
- actions: 'setRanking',
96
- },
97
- onError: {
98
- target: 'idle',
99
- },
100
- },
101
- },
102
- getRankingGames: {
103
- invoke: {
104
- src: 'fetchRankingGames',
105
- onDone: {
106
- target: 'getRankingDetail',
107
- actions: 'setRankingGames',
108
- },
109
- onError: {
110
- target: 'idle',
111
- },
112
- },
113
- },
114
- },
115
- },
116
- {
117
- actions: {
118
- setActivity: assign((context, event) => {
119
- return {
120
- auth: !!request.getToken(),
121
- activityNo: event.data?.activityNo,
122
- }
123
- }),
124
- setRanking: assign((context, event) => {
125
- const topRanking = event.data?.topRanking?.map((rank) => transGameData(rank)) || []
126
- return {
127
- description: event.data?.description,
128
- descriptionUrl: event.data?.descriptionUrl,
129
- topRanking: topRanking,
130
- playerRanking: transGameData(event.data?.playerRanking) || {},
131
- settleStatus: !!topRanking[0]?.settleStatus,
132
- }
133
- }),
134
- setRankingGames: assign((context, event) => {
135
- const gameRanking = event.data?.map((rank) => transGameData(rank))
136
- return {
137
- gameRanking: gameRanking || [],
138
- }
139
- }),
140
- setRankingOptions: assign((context, event) => {
141
- const cycle = event.data?.cycle
142
- const currentRound = event.data?.currentRound || []
143
- // 取得結算週期選單列表
144
- const cycleOptions = cycleMapping.slice(0, currentRound.length)
145
- // 取得每週期的歷史期數選單列表
146
- const roundOptions = roundProcess(currentRound)
147
- // 如果是月結算,則加入全部選項
148
- if (cycle === 'MONTHLY') {
149
- cycleOptions.push('ALL')
150
- roundOptions.ALL = roundOptions.MONTHLY
151
- }
152
- return {
153
- ...event.data,
154
- options: { cycle: cycleOptions, round: roundOptions },
155
- // 初始固定顯示 DAILY
156
- cycle: event.data?.rule !== 'NORMAL' ? 'DAILY' : cycle,
157
- round: currentRound[0],
158
- }
159
- }),
160
- setOptions: assign((context, event) => {
161
- const { cycle, round } = context
162
- // 處理變更 cycle,如果沒有輸入或沒有變更就不更新
163
- if (event.data?.cycle && cycle !== event.data?.cycle) {
164
- const { currentRound } = context
165
- const cycleForRound = event.data?.cycle === 'ALL' ? 'MONTHLY' : event.data?.cycle
166
- const cycleIndex = cycleMapping.indexOf(cycleForRound)
167
- return { cycle: event.data?.cycle, round: currentRound[cycleIndex] }
168
- }
169
- if (event.data?.round && round !== event.data?.round) {
170
- return { round: event.data?.round }
171
- }
172
- return {}
173
- }),
174
- },
175
- guards: {
176
- hasAuth: (context) => context.auth,
177
- },
178
- services: {
179
- fetchTournament: async (context) => {
180
- const { activityNo } = context
181
- const { data } = await request.send(ranking.getTournament({ activityNo }))
182
- return data
183
- },
184
- fetchRankingOptions: async (context) => {
185
- const { activityNo } = context
186
- const { data } = await request.send(ranking.getRankingOptions({ activityNo }))
187
- return data
188
- },
189
- fetchRankingDetail: async (context, event) => {
190
- const { activityNo, cycle, round } = context
191
- const { data } = await request.send(ranking.getRankingDetail({ activityNo, cycle, round }))
192
- return data
193
- },
194
- fetchRankingGames: async (context) => {
195
- const { activityNo } = context
196
- const { data } = await request.send(ranking.getRankingGames({ activityNo }))
197
- return data
198
- },
199
- },
200
- }
201
- )
202
- }