@jetthai/cuora 1.1.341-rank-1 → 1.1.341-rank-2

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,6 +2,8 @@
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-2](https://github.com/jetthai/cuora-module/compare/v1.1.341-rank-1...v1.1.341-rank-2) (2025-03-06)
6
+
5
7
  ### [1.1.341-rank-1](https://github.com/jetthai/cuora-module/compare/v1.1.341...v1.1.341-rank-1) (2025-03-05)
6
8
 
7
9
  ### [1.1.341](https://github.com/jetthai/cuora-module/compare/v1.1.340...v1.1.341) (2025-02-25)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.341-rank-1",
3
+ "version": "1.1.341-rank-2",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -18,4 +18,9 @@ export default {
18
18
  method: 'post',
19
19
  params: { activityNo, cycle, round },
20
20
  }),
21
+ getRankingGames: ({ activityNo }) => ({
22
+ url: 'hot-game/ranking',
23
+ method: 'get',
24
+ params: { activityNo },
25
+ }),
21
26
  }
@@ -2,12 +2,12 @@ import { createMachine, assign } from 'xstate'
2
2
  import ranking from '../api/ranking.js'
3
3
 
4
4
  export default function (request) {
5
- const rateMapping = ['DAILY', 'WEEKLY', 'MONTHLY']
5
+ const cycleMapping = ['DAILY', 'WEEKLY', 'MONTHLY']
6
6
 
7
7
  function roundProcess(rounds) {
8
8
  const roundArrays = rounds.map((round) => Array.from({ length: round }, (_, i) => i + 1))
9
9
  return roundArrays.reduce((acc, roundArray, index) => {
10
- acc[rateMapping[index]] = roundArray.reverse()
10
+ acc[cycleMapping[index]] = roundArray.reverse()
11
11
  return acc
12
12
  }, {})
13
13
  }
@@ -23,12 +23,13 @@ export default function (request) {
23
23
  currentRound: [],
24
24
  cycle: '',
25
25
  round: 0,
26
- // api detail 資料
27
26
  rule: '',
27
+ // api detail 資料
28
28
  description: '',
29
29
  descriptionUrl: [],
30
30
  // api detail 排名資料
31
31
  playerRanking: {},
32
+ gameRanking: [],
32
33
  topRanking: [],
33
34
  // 前端這邊用的選單資料 { cycle, round }
34
35
  options: {},
@@ -83,7 +84,7 @@ export default function (request) {
83
84
  invoke: {
84
85
  src: 'fetchRankingDetail',
85
86
  onDone: {
86
- target: 'idle',
87
+ target: 'getRankingGames',
87
88
  actions: 'setRanking',
88
89
  },
89
90
  onError: {
@@ -91,6 +92,18 @@ export default function (request) {
91
92
  },
92
93
  },
93
94
  },
95
+ getRankingGames: {
96
+ invoke: {
97
+ src: 'fetchRankingGames',
98
+ onDone: {
99
+ target: 'idle',
100
+ actions: 'setRankingGames',
101
+ },
102
+ onError: {
103
+ target: 'idle',
104
+ },
105
+ },
106
+ },
94
107
  },
95
108
  },
96
109
  {
@@ -103,18 +116,22 @@ export default function (request) {
103
116
  }),
104
117
  setRanking: assign((context, event) => {
105
118
  return {
106
- rule: event.data?.rule,
107
119
  description: event.data?.description,
108
120
  descriptionUrl: event.data?.descriptionUrl,
109
121
  topRanking: event.data?.topRanking || [],
110
122
  playerRanking: event.data?.playerRanking || {},
111
123
  }
112
124
  }),
125
+ setRankingGames: assign((context, event) => {
126
+ return {
127
+ gameRanking: event.data || [],
128
+ }
129
+ }),
113
130
  setRankingOptions: assign((context, event) => {
114
131
  const cycle = event.data?.cycle
115
132
  const currentRound = event.data?.currentRound || []
116
133
  // 取得結算週期選單列表
117
- const cycleOptions = rateMapping.slice(0, currentRound.length)
134
+ const cycleOptions = cycleMapping.slice(0, currentRound.length)
118
135
  // 如果是月結算,則加入全部選項
119
136
  if (cycle === 'MONTHLY') cycleOptions.push('ALL')
120
137
  // 取得每週期的歷史期數選單列表
@@ -130,7 +147,8 @@ export default function (request) {
130
147
  // 處理變更 cycle,如果沒有輸入或沒有變更就不更新
131
148
  if (event.data?.cycle && cycle !== event.data?.cycle) {
132
149
  const { currentRound } = context
133
- const cycleIndex = rateMapping.indexOf(event.data?.cycle)
150
+ const cycleForRound = event.data?.cycle === 'ALL' ? 'MONTHLY' : event.data?.cycle
151
+ const cycleIndex = cycleMapping.indexOf(cycleForRound)
134
152
  return { cycle: event.data?.cycle, round: currentRound[cycleIndex] }
135
153
  }
136
154
  if (event.data?.round && round !== event.data?.round) {
@@ -158,6 +176,11 @@ export default function (request) {
158
176
  const { data } = await request.send(ranking.getRankingDetail({ activityNo, cycle, round }))
159
177
  return data
160
178
  },
179
+ fetchRankingGames: async (context) => {
180
+ const { activityNo } = context
181
+ const { data } = await request.send(ranking.getRankingGames({ activityNo }))
182
+ return data
183
+ },
161
184
  },
162
185
  }
163
186
  )