@jetthai/cuora 1.1.299 → 1.1.300-dev-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,12 @@
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.300-dev-2](https://github.com/jetthai/cuora-module/compare/v1.1.300-dev-1...v1.1.300-dev-2) (2024-08-30)
6
+
7
+ ### [1.1.300-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.300...v1.1.300-dev-1) (2024-08-28)
8
+
9
+ ### [1.1.300](https://github.com/jetthai/cuora-module/compare/v1.1.299...v1.1.300) (2024-08-27)
10
+
5
11
  ### [1.1.299](https://github.com/jetthai/cuora-module/compare/v1.1.297...v1.1.299) (2024-08-27)
6
12
 
7
13
  ### [1.1.297](https://github.com/jetthai/cuora-module/compare/v1.1.296...v1.1.297) (2024-08-20)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.299",
3
+ "version": "1.1.300-dev-2",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
package/src/api/common.js CHANGED
@@ -4,4 +4,5 @@ export default {
4
4
  feeds: ({ appSecret }) => ({ url: 'feeds', method: 'get', params: { appSecret }, isPublic: true }),
5
5
  broadcast: () => ({ url: 'broadcast', method: 'get', isPublic: true }),
6
6
  getAnnouncements: ({ appSecret }) => ({ url: 'getAnnouncements', params: { appSecret }, method: 'get', isPublic: true }),
7
+ getNavbar: ({ appSecret } = {}) => ({ url: 'getNavbarSetting', params: { appSecret }, method: 'get', isPublic: true }),
7
8
  }
@@ -74,14 +74,12 @@ export default function (request) {
74
74
  },
75
75
  checking: {
76
76
  always: [
77
- { target: 'claimAmountLimitReached', cond: 'isClaimAmountLimitReached' },
78
77
  { target: 'claimExhausted', cond: 'isClaimExhausted' },
79
78
  { target: 'insufficientAmount', cond: 'isInsufficientAmount' },
80
79
  { target: 'claimEnable', cond: 'isClaimEnable' },
81
80
  { target: 'cantEstimate' },
82
81
  ],
83
82
  },
84
- claimAmountLimitReached: {},
85
83
  claimExhausted: {},
86
84
  insufficientAmount: {},
87
85
  claimEnable: {
@@ -163,10 +161,6 @@ export default function (request) {
163
161
  return parseInt(`${currentTime}`) - parseInt(`${lastEstimateTime}`) > fiveMinutes
164
162
  }
165
163
  },
166
- isClaimAmountLimitReached: (context, event) => {
167
- const { collectAvailable } = context
168
- return !collectAvailable
169
- },
170
164
  isClaimExhausted: (context, event) => {
171
165
  const { collectAvailable, remainingCount, dailyRedemptionLimit } = context
172
166
  return !collectAvailable && parseInt(`${remainingCount}`) === parseInt(`${dailyRedemptionLimit}`)
@@ -14,6 +14,7 @@ export default function (request) {
14
14
  batch: null,
15
15
  loadable: false,
16
16
  isLastPage: false,
17
+ pageLoading: true,
17
18
  room: null,
18
19
  index: -1,
19
20
  content: {
@@ -64,6 +65,11 @@ export default function (request) {
64
65
  target: 'routing',
65
66
  actions: 'setLoadable',
66
67
  },
68
+ // 載入下一頁
69
+ NEXT_PAGE: {
70
+ target: 'routing',
71
+ actions: 'setLoadable',
72
+ },
67
73
  SET_ROOM: {
68
74
  cond: 'isDifferentRoom',
69
75
  actions: ['setRoom', 'resetContent'],
@@ -101,7 +107,10 @@ export default function (request) {
101
107
  invoke: {
102
108
  src: 'getPageContent',
103
109
  onDone: {
104
- target: 'routing',
110
+ // 原本的: 形成迴圈直到hasNxet條件不成立
111
+ // target: 'routing',
112
+ // 現在: 載完一個頁面就切成loaded狀態
113
+ target: 'loaded',
105
114
  actions: ['appendContent', 'setLastPage'],
106
115
  },
107
116
  onError: {
@@ -112,13 +121,23 @@ export default function (request) {
112
121
  LOAD: { actions: 'setLoadable' },
113
122
  },
114
123
  },
124
+ // 已將當前頁載入完成
125
+ loaded: {
126
+ after: {
127
+ 0: {
128
+ target: 'idle',
129
+ actions: 'setPageLoadingDone',
130
+ },
131
+ },
132
+ },
115
133
  routing: {
116
134
  always: [
117
135
  {
118
136
  target: 'loading',
119
137
  cond: 'hasNext',
138
+ actions: 'setPageLoading',
120
139
  },
121
- { target: 'idle' },
140
+ { target: 'idle', actions: 'setPageLoadingDone' },
122
141
  ],
123
142
  },
124
143
  updating: {
@@ -320,6 +339,7 @@ export default function (request) {
320
339
  }),
321
340
  setLastPage: assign((context, event) => {
322
341
  const { index, content } = context
342
+ // 最後一頁
323
343
  return {
324
344
  isLastPage: index >= content?.totalPage - 1,
325
345
  }
@@ -429,12 +449,25 @@ export default function (request) {
429
449
  const lang = event.data.locale.replace('-', '_')
430
450
  return { lang }
431
451
  }),
452
+ setPageLoadingDone: assign((context, event) => {
453
+ // const { index } = context
454
+ // console.log('*載入完成:當前頁碼', index)
455
+ return {
456
+ pageLoading: true,
457
+ }
458
+ }),
459
+ setPageLoading: assign((context, event) => {
460
+ return {
461
+ pageLoading: false,
462
+ }
463
+ }),
432
464
  ...oldActions,
433
465
  },
434
466
  guards: {
435
467
  isDifferentRoom: (context, event) => context.room?.categoryId !== event.data?.categoryId,
436
468
  hasNext: (context, event) => {
437
469
  const { loadable, isLastPage } = context
470
+ // 是否有下一頁
438
471
  return loadable && !isLastPage
439
472
  },
440
473
  hasRoom: (context, event) => context.room?.categoryId,
@@ -35,6 +35,7 @@ import promotions from './promotions.js'
35
35
  import roulette_v2 from './roulette_v2.js'
36
36
  import honor_board_cash from './honor_board_cash.js'
37
37
  import user_photo from './user_photo.js'
38
+ import navbar from './navbar.js'
38
39
 
39
40
  export default {
40
41
  ...activity,
@@ -73,5 +74,6 @@ export default {
73
74
  roulette_v2,
74
75
  honor_board_cash,
75
76
  user_photo,
77
+ navbar,
76
78
  ...withdraw,
77
79
  }
@@ -0,0 +1,57 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import common from '../api/common.js'
3
+
4
+ export default function (request) {
5
+ const { appSecret } = request.config
6
+ return createMachine(
7
+ {
8
+ id: 'navbar',
9
+ initial: 'fetching',
10
+ context: {
11
+ navbar: null,
12
+ },
13
+ states: {
14
+ fetching: {
15
+ invoke: {
16
+ src: 'fetchNavbar',
17
+ onDone: {
18
+ target: 'idle',
19
+ actions: 'setNavbar',
20
+ },
21
+ onError: {
22
+ target: 'idle',
23
+ },
24
+ },
25
+ },
26
+ idle: {},
27
+ },
28
+ },
29
+ {
30
+ actions: {
31
+ setNavbar: assign((context, event) => {
32
+ const { navbarConfig } = event.data
33
+ return {
34
+ navbar: navbarConfig.settings,
35
+ }
36
+ }),
37
+ },
38
+ services: {
39
+ fetchNavbar: async (context, event) => {
40
+ const navbar = await request.send(common.getNavbar({ appSecret }))
41
+ const base64Url = navbar.config.split('.')[0]
42
+ const base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/')
43
+ const decodeResult = decodeURIComponent(
44
+ window
45
+ .atob(base64)
46
+ .split('')
47
+ .map((c) => {
48
+ return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
49
+ })
50
+ .join('')
51
+ )
52
+ return { navbarConfig: JSON.parse(decodeResult) }
53
+ },
54
+ },
55
+ }
56
+ )
57
+ }
@@ -143,7 +143,21 @@ export default function (request) {
143
143
  }
144
144
  }),
145
145
  setSignUpEmail: assign((context, event) => {
146
- const { email, nick_name, password, channel, subchannel, bankCode, bankAccount, holderName, branch, branchCode, affiliateCode } = event.data
146
+ const {
147
+ email,
148
+ nick_name,
149
+ password,
150
+ channel,
151
+ subchannel,
152
+ bankCode,
153
+ bankAccount,
154
+ holderName,
155
+ branch,
156
+ branchCode,
157
+ affiliateCode,
158
+ countryCode,
159
+ phone,
160
+ } = event.data
147
161
  return {
148
162
  signUpData: {
149
163
  provider: 'email',
@@ -156,6 +170,8 @@ export default function (request) {
156
170
  branch,
157
171
  branchCode,
158
172
  affiliateCode,
173
+ countryCode,
174
+ phone,
159
175
  },
160
176
  channel,
161
177
  subchannel,