@jetthai/cuora 1.1.305-dev-6 → 1.1.305

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,20 +2,6 @@
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.305-dev-6](https://github.com/jetthai/cuora-module/compare/v1.1.305-dev-5...v1.1.305-dev-6) (2024-09-13)
6
-
7
- ### [1.1.305-dev-5](https://github.com/jetthai/cuora-module/compare/v1.1.305-dev-4...v1.1.305-dev-5) (2024-09-13)
8
-
9
- ### [1.1.305-dev-4](https://github.com/jetthai/cuora-module/compare/v1.1.305-dev-3...v1.1.305-dev-4) (2024-09-13)
10
-
11
- ### [1.1.305-dev-3](https://github.com/jetthai/cuora-module/compare/v1.1.305-dev-2...v1.1.305-dev-3) (2024-09-12)
12
-
13
- ### [1.1.305-dev-2](https://github.com/jetthai/cuora-module/compare/v1.1.305-dev-1...v1.1.305-dev-2) (2024-09-11)
14
-
15
- ### [1.1.305-dev-1](https://github.com/jetthai/cuora-module/compare/v1.1.305-dev...v1.1.305-dev-1) (2024-09-11)
16
-
17
- ### [1.1.305-dev](https://github.com/jetthai/cuora-module/compare/v1.1.305...v1.1.305-dev) (2024-09-11)
18
-
19
5
  ### [1.1.305](https://github.com/jetthai/cuora-module/compare/v1.1.304...v1.1.305) (2024-09-09)
20
6
 
21
7
  ### [1.1.304](https://github.com/jetthai/cuora-module/compare/v1.1.303...v1.1.304) (2024-09-09)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.305-dev-6",
3
+ "version": "1.1.305",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -87,7 +87,7 @@ export default {
87
87
  exchangeAward,
88
88
  },
89
89
  }),
90
- getHonorBroadcast: (appSecret) => ({ url: 'activities/honorBroadcast', method: 'get', params: { appSecret }, isPublic: true }),
90
+ getHonorBoard: (appSecret) => ({ url: 'activities/honorBoard', method: 'get', params: { appSecret }, isPublic: true }),
91
91
  getInstantRebateCollectTime: () => ({ url: 'activities/rebate/collectTime', method: 'get' }),
92
92
  instantRebateEstimate: () => ({ url: 'activities/rebate/estimate', method: 'get' }),
93
93
  instantRebateCollect: () => ({ url: 'activities/rebate/collect', method: 'get' }),
@@ -6,56 +6,80 @@ export default function (request) {
6
6
  {
7
7
  id: 'instant_rebate_activity',
8
8
  context: {
9
- showColletButton: false,
10
- estimateStartTime: null,
11
- estimateEndTime: null,
9
+ enableCollectButton: false,
12
10
  lastCollectTime: null,
13
11
  lastEstimateTime: null,
14
12
  collectAvailable: false,
15
- cumulativeValidTurnover: null,
16
- cumulativeRebateAmount: null,
17
- actualRebateAmount: null,
13
+ settlementTime: null,
14
+ validTurnover: null,
15
+ rebateAmount: null,
18
16
  rewardType: null,
19
17
  singleMinimumAmountReceive: null,
20
18
  remainingCount: 0,
21
19
  dailyRedemptionLimit: 0,
22
- reachedAmountLimit: false,
20
+ collectAmount: 0,
23
21
  activityNo: null,
24
- claimResultData: null,
25
22
  },
26
23
  initial: 'idle',
27
24
  states: {
28
25
  idle: {
29
26
  on: {
30
27
  SET_ACTIVITY_NO: {
31
- target: 'estimating',
28
+ target: 'loading',
32
29
  actions: 'setActivityNo',
33
30
  },
34
31
  },
35
32
  },
33
+ loading: {
34
+ invoke: {
35
+ src: 'fetchCollectTime',
36
+ onDone: {
37
+ target: 'pending',
38
+ actions: 'setInitData',
39
+ },
40
+ onError: {
41
+ target: 'fail',
42
+ },
43
+ },
44
+ },
45
+ pending: {
46
+ always: [{ target: 'loaded', cond: 'isEstimatable' }, { target: 'cantEstimate' }],
47
+ },
48
+ loaded: {
49
+ on: {
50
+ ESTIMATE: {
51
+ target: 'estimating',
52
+ },
53
+ },
54
+ },
55
+ cantEstimate: {},
36
56
  estimating: {
37
57
  invoke: {
38
58
  src: 'estimate',
39
59
  onDone: {
40
- target: 'checking',
60
+ target: 'estimated',
41
61
  actions: 'setEstimateResult',
42
62
  },
43
63
  onError: {
44
- target: 'fail',
64
+ target: 'loaded',
65
+ },
66
+ },
67
+ },
68
+ estimated: {
69
+ after: {
70
+ 0: {
71
+ target: 'checking',
45
72
  },
46
73
  },
47
74
  },
48
75
  checking: {
49
76
  always: [
50
- { target: 'claimAmountLimitReached', cond: 'isClaimAmountLimitReached' },
51
77
  { target: 'claimExhausted', cond: 'isClaimExhausted' },
52
78
  { target: 'insufficientAmount', cond: 'isInsufficientAmount' },
53
79
  { target: 'claimEnable', cond: 'isClaimEnable' },
54
- { target: 'pending' },
80
+ { target: 'cantEstimate' },
55
81
  ],
56
82
  },
57
- pending: {},
58
- claimAmountLimitReached: {},
59
83
  claimExhausted: {},
60
84
  insufficientAmount: {},
61
85
  claimEnable: {
@@ -69,33 +93,19 @@ export default function (request) {
69
93
  invoke: {
70
94
  src: 'claimRebateAmount',
71
95
  onDone: {
72
- target: 'checkClaimStatus',
73
- actions: 'setClaimesult',
96
+ target: 'claimed',
74
97
  },
75
98
  onError: {
76
99
  target: 'fail',
77
100
  },
78
101
  },
79
102
  },
80
- checkClaimStatus: {
81
- always: [{ target: 'claimed', cond: 'isClaimSuccess' }, { target: 'claimFail' }],
82
- },
83
- claimFail: {
84
- after: {
85
- 0: {
86
- target: 'claimEnable',
87
- },
88
- },
89
- },
90
103
  claimed: {},
91
104
  fail: {},
92
105
  },
93
106
  on: {
94
- ESTIMATE: {
95
- target: '.estimating',
96
- },
97
107
  START: {
98
- target: '.estimating',
108
+ target: '.loading',
99
109
  },
100
110
  STOP: {
101
111
  target: '.idle',
@@ -109,78 +119,90 @@ export default function (request) {
109
119
  activityNo: event.data,
110
120
  }
111
121
  }),
122
+ setInitData: assign((context, event) => {
123
+ const { enableCollectButton = false, lastCollectTime = 0, lastEstimateTime = 0, rewardType } = event.data
124
+ return { enableCollectButton, lastCollectTime, lastEstimateTime, rewardType }
125
+ }),
112
126
  setEstimateResult: assign((context, event) => {
113
127
  const {
114
- showColletButton = false,
115
- estimateStartTime = 0,
116
- estimateEndTime = 0,
117
128
  lastCollectTime = 0,
118
129
  collectAvailable = false,
119
- cumulativeValidTurnover = '0',
120
- cumulativeRebateAmount = '0',
121
- actualRebateAmount = '0',
130
+ settlementTime = 0,
131
+ validTurnover = '0',
132
+ rebateAmount = '0',
122
133
  rewardType = null,
123
134
  singleMinimumAmountReceive = 0,
124
135
  remainingCount = 0,
125
136
  dailyRedemptionLimit = 0,
126
- reachedAmountLimit = false,
127
137
  } = event.data
128
138
 
129
139
  return {
130
- showColletButton,
131
- estimateStartTime,
132
- estimateEndTime,
133
140
  lastCollectTime,
134
141
  collectAvailable,
135
- cumulativeValidTurnover,
136
- cumulativeRebateAmount,
137
- actualRebateAmount,
142
+ settlementTime,
143
+ validTurnover,
144
+ rebateAmount,
138
145
  rewardType,
139
146
  singleMinimumAmountReceive,
140
147
  remainingCount,
141
148
  dailyRedemptionLimit,
142
- reachedAmountLimit,
143
- }
144
- }),
145
- setClaimesult: assign((context, event) => {
146
- return {
147
- claimResultData: event.data,
148
149
  }
149
150
  }),
150
151
  },
151
152
  guards: {
152
- isClaimAmountLimitReached: (context, event) => {
153
- const { collectAvailable, reachedAmountLimit } = context
154
- return !collectAvailable && reachedAmountLimit
153
+ isEstimatable: (context, event) => {
154
+ const { lastCollectTime, lastEstimateTime } = context
155
+ if (lastCollectTime === lastEstimateTime) {
156
+ return true
157
+ } else {
158
+ const fiveMinutes = 60 * 5
159
+ const currentTime = new Date().getTime() / 1000
160
+
161
+ return parseInt(`${currentTime}`) - parseInt(`${lastEstimateTime}`) > fiveMinutes
162
+ }
155
163
  },
156
164
  isClaimExhausted: (context, event) => {
157
165
  const { collectAvailable, remainingCount, dailyRedemptionLimit } = context
158
166
  return !collectAvailable && parseInt(`${remainingCount}`) === parseInt(`${dailyRedemptionLimit}`)
159
167
  },
160
168
  isInsufficientAmount: (context, event) => {
161
- const { collectAvailable, singleMinimumAmountReceive, actualRebateAmount } = context
162
- const formattedSingleMinimumAmountReceive = parseFloat(singleMinimumAmountReceive.replace(/,/g, ''))
163
- const formattedActualRebateAmount = parseFloat(actualRebateAmount.replace(/,/g, ''))
164
-
165
- return !collectAvailable && parseFloat(`${formattedActualRebateAmount}`) < parseFloat(`${formattedSingleMinimumAmountReceive}`)
169
+ const { collectAvailable, singleMinimumAmountReceive, rebateAmount } = context
170
+ let splitArray = rebateAmount?.split(',')
171
+ let combindString = '0'
172
+ if (splitArray?.length > 0) {
173
+ splitArray.forEach((item) => {
174
+ combindString += item
175
+ })
176
+ } else {
177
+ combindString = rebateAmount
178
+ }
179
+ const deformatRebateAmount = parseFloat(`${combindString}`)
180
+ return !collectAvailable && deformatRebateAmount < parseFloat(`${singleMinimumAmountReceive}`)
166
181
  },
167
182
  isClaimEnable: (context, event) => {
168
- const { collectAvailable, remainingCount, dailyRedemptionLimit, actualRebateAmount, singleMinimumAmountReceive } = context
169
- const formattedSingleMinimumAmountReceive = parseFloat(singleMinimumAmountReceive.replace(/,/g, ''))
170
- const formattedActualRebateAmount = parseFloat(actualRebateAmount.replace(/,/g, ''))
171
-
183
+ const { collectAvailable, remainingCount, dailyRedemptionLimit, rebateAmount, singleMinimumAmountReceive } = context
184
+ let splitArray = rebateAmount?.split(',')
185
+ let combindString = '0'
186
+ if (splitArray?.length > 0) {
187
+ splitArray.forEach((item) => {
188
+ combindString += item
189
+ })
190
+ } else {
191
+ combindString = rebateAmount
192
+ }
193
+ const deformatRebateAmount = parseFloat(combindString)
172
194
  return (
173
195
  collectAvailable &&
174
196
  parseInt(`${remainingCount}`) < parseInt(`${dailyRedemptionLimit}`) &&
175
- parseFloat(`${formattedActualRebateAmount}`) >= parseFloat(`${formattedSingleMinimumAmountReceive}`)
197
+ deformatRebateAmount >= parseFloat(`${singleMinimumAmountReceive}`)
176
198
  )
177
199
  },
178
- isClaimSuccess: (context, event) => {
179
- const { claimResultData } = context
180
- return claimResultData?.result === 'success'
181
- },
182
200
  },
183
201
  services: {
202
+ fetchCollectTime: async (context, event) => {
203
+ const { data } = await request.send(api.getInstantRebateCollectTime())
204
+ return data
205
+ },
184
206
  estimate: async (context, event) => {
185
207
  const { data } = await request.send(api.instantRebateEstimate())
186
208
  return data
@@ -9,11 +9,6 @@ export default function (request) {
9
9
  initial: 'fetching',
10
10
  context: {
11
11
  tick: 6000,
12
- tabs: [],
13
- cashRainList: [],
14
- depositList: [],
15
- rouletteList: [],
16
- jackpotList: [],
17
12
  bigWinList: [],
18
13
  maxBetList: [],
19
14
  withdrawList: [],
@@ -43,32 +38,11 @@ export default function (request) {
43
38
  {
44
39
  actions: {
45
40
  setHonorBoardList: assign((context, event) => {
41
+ const { bigWinList = [], maxBetList = [], withdrawList = [] } = event.data
46
42
  return {
47
- tabs: (event.data || []).map((list) => {
48
- switch (list.type) {
49
- case 'CASH_RAIN':
50
- return 'cashRain'
51
- case 'DEPOSIT':
52
- return 'deposit'
53
- case 'FREE_ROULETTE_SPIN':
54
- return 'roulette'
55
- case 'JACKPOT':
56
- return 'jackpot'
57
- case 'WIN_SCORE':
58
- return 'bigWin'
59
- case 'WIN_MULTIPLIER':
60
- return 'maxBet'
61
- case 'WITHDRAW':
62
- return 'withdraw'
63
- }
64
- }),
65
- cashRainList: (event.data || []).find((item) => item.type === 'CASH_RAIN')?.data,
66
- depositList: (event.data || []).find((item) => item.type === 'DEPOSIT')?.data,
67
- rouletteList: (event.data || []).find((item) => item.type === 'FREE_ROULETTE_SPIN')?.data,
68
- jackpotList: (event.data || []).find((item) => item.type === 'JACKPOT')?.data,
69
- bigWinList: (event.data || []).find((item) => item.type === 'WIN_SCORE')?.data,
70
- maxBetList: (event.data || []).find((item) => item.type === 'WIN_MULTIPLIER')?.data,
71
- withdrawList: (event.data || []).find((item) => item.type === 'WITHDRAW')?.data,
43
+ bigWinList,
44
+ maxBetList,
45
+ withdrawList,
72
46
  }
73
47
  }),
74
48
  },
@@ -80,7 +54,7 @@ export default function (request) {
80
54
  },
81
55
  services: {
82
56
  fetchHonorBoardList: async (context, event) => {
83
- const { data } = await request.send(activity.getHonorBroadcast(appSecret))
57
+ const { data } = await request.send(activity.getHonorBoard(appSecret))
84
58
  return data
85
59
  },
86
60
  },
@@ -34,7 +34,6 @@ import vip_table from './vip_table.js'
34
34
  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
- import honor_board from './honor_board.js'
38
37
  import user_photo from './user_photo.js'
39
38
  import navbar from './navbar.js'
40
39
 
@@ -74,7 +73,6 @@ export default {
74
73
  promotions,
75
74
  roulette_v2,
76
75
  honor_board_cash,
77
- honor_board,
78
76
  user_photo,
79
77
  navbar,
80
78
  ...withdraw,
@@ -143,21 +143,7 @@ export default function (request) {
143
143
  }
144
144
  }),
145
145
  setSignUpEmail: assign((context, event) => {
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
146
+ const { email, nick_name, password, channel, subchannel, bankCode, bankAccount, holderName, branch, branchCode, affiliateCode } = event.data
161
147
  return {
162
148
  signUpData: {
163
149
  provider: 'email',
@@ -170,8 +156,6 @@ export default function (request) {
170
156
  branch,
171
157
  branchCode,
172
158
  affiliateCode,
173
- countryCode,
174
- phone,
175
159
  },
176
160
  channel,
177
161
  subchannel,
@@ -1,118 +0,0 @@
1
- import { assign, createMachine } from 'xstate'
2
- import activity from '../api/activity.js'
3
-
4
- export default function (request) {
5
- const { appSecret } = request.config
6
- return createMachine(
7
- {
8
- id: 'honor_board',
9
- type: 'parallel',
10
- context: {
11
- tick: 6000,
12
- },
13
- states: {
14
- feed: {
15
- initial: 'updating',
16
- states: {
17
- updating: {
18
- invoke: {
19
- src: 'fetchHonorBoardList',
20
- onDone: {
21
- target: 'waiting',
22
- actions: 'setBroadcastList',
23
- },
24
- onError: {
25
- target: 'waiting',
26
- },
27
- },
28
- },
29
- waiting: {
30
- after: {
31
- TIMEOUT: {
32
- target: 'updating',
33
- },
34
- },
35
- },
36
- },
37
- },
38
- broadcast: {
39
- initial: 'idle',
40
- states: {
41
- idle: {
42
- on: {
43
- START_BROADCAST: {
44
- target: 'picking',
45
- },
46
- },
47
- },
48
- picking: {
49
- after: {
50
- 5000: {
51
- target: 'display',
52
- actions: 'setBroadcast',
53
- },
54
- },
55
- },
56
- display: {
57
- after: {
58
- 5000: {
59
- target: 'picking',
60
- },
61
- },
62
- },
63
- },
64
- on: {
65
- RESET_BROADCAST: {
66
- target: '.idle',
67
- actions: 'resetBroadcast',
68
- },
69
- },
70
- },
71
- },
72
- },
73
- {
74
- delays: {
75
- TIMEOUT: (context, event) => {
76
- return context.tick * 10
77
- },
78
- },
79
- actions: {
80
- setBroadcastList: assign((context, event) => {
81
- const broadcastList = (event.data || []).map((item) => item.data).flat()
82
- const sortBroadcastList = broadcastList.sort((a, b) => {
83
- if (!a.time) return -1
84
- if (!b.time) return 1
85
- return a.time - b.time
86
- })
87
- return { broadcastList: sortBroadcastList }
88
- }),
89
- setBroadcast: assign((context, event) => {
90
- const { broadcastList = [], sentNormalBroadcastList = [], normalBroadcast = [] } = context
91
- let sentNormalList = sentNormalBroadcastList
92
- if (normalBroadcast) {
93
- sentNormalList = [...sentNormalBroadcastList, normalBroadcast]
94
- }
95
- const nextNormalBroadcast = broadcastList?.find((broadcast) => {
96
- return !sentNormalList.some((item) => item.broadcastId === broadcast.broadcastId)
97
- })
98
- return {
99
- normalBroadcast: nextNormalBroadcast,
100
- sentNormalBroadcastList: sentNormalList,
101
- }
102
- }),
103
- resetBroadcast: assign((context, event) => {
104
- return {
105
- normalBroadcast: null,
106
- sentNormalBroadcastList: [],
107
- }
108
- }),
109
- },
110
- services: {
111
- fetchHonorBoardList: async (context, event) => {
112
- const { data } = await request.send(activity.getHonorBroadcast(appSecret))
113
- return data
114
- },
115
- },
116
- }
117
- )
118
- }