@jetthai/cuora 1.1.477-dev.1 → 1.1.477
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/.claude/commands/sync-ai-prompts.md +1 -88
- package/.claude/settings.local.json +1 -3
- package/.github/copilot-instructions.md +57 -64
- package/.husky/post-checkout +3 -3
- package/.husky/pre-push +1 -1
- package/.prettierignore +1 -2
- package/AGENTS.md +58 -65
- package/AI_PROMPT_SOURCE.md +58 -65
- package/CHANGELOG.md +5 -319
- package/CLAUDE.md +58 -65
- package/GEMINI.md +58 -65
- package/README.md +12 -11
- package/package.json +1 -1
- package/scripts/auto-version.js +0 -1
- package/scripts/branch-auto-npm-publish.js +2 -9
- package/src/api/account.js +1 -0
- package/src/api/activity.js +37 -0
- package/src/api/auth.js +31 -0
- package/src/api/game.js +10 -0
- package/src/api/payment.js +52 -1
- package/src/api/user.js +16 -0
- package/src/index.js +2 -2
- package/src/machine/activity/activity.js +209 -0
- package/src/machine/activity/diamond_shop_activity_cash.js +1 -0
- package/src/machine/activity/diamond_shop_activity_fc.js +196 -0
- package/src/machine/activity/diamond_shop_activity_vn.js +178 -0
- package/src/machine/activity/fafafa_activity.js +10 -0
- package/src/machine/activity/index.js +12 -0
- package/src/machine/activity/invite_friends_activity.js +114 -0
- package/src/machine/activity/mini_game_activity.js +68 -0
- package/src/machine/activity/return_bonus_activity.js +153 -0
- package/src/machine/auth.js +59 -37
- package/src/machine/auth_otp_v2.js +177 -0
- package/src/machine/auth_otp_v3.js +19 -30
- package/src/machine/bank_binding_amb.js +146 -0
- package/src/machine/bonus.js +76 -0
- package/src/machine/common.js +55 -0
- package/src/machine/deposit/amb.js +93 -0
- package/src/machine/deposit/crypto_bank.js +330 -0
- package/src/machine/deposit/crypto_qrcode.js +148 -0
- package/src/machine/deposit/crypto_qrcode_cash.js +2 -2
- package/src/machine/deposit/crypto_way.js +252 -0
- package/src/machine/deposit/deposit_fc.js +272 -0
- package/src/machine/deposit/direct.js +310 -0
- package/src/machine/deposit/float.js +375 -0
- package/src/machine/deposit/index.js +28 -0
- package/src/machine/deposit/krway.js +151 -0
- package/src/machine/deposit/loadcard_vn.js +351 -0
- package/src/machine/deposit/manual_cash.js +8 -0
- package/src/machine/deposit/manual_vn.js +458 -0
- package/src/machine/deposit/qrcode_v2.js +338 -0
- package/src/machine/deposit/usdt.js +144 -0
- package/src/machine/deposit/virtual_bank_vn.js +269 -0
- package/src/machine/deposit/vpay.js +368 -0
- package/src/machine/game_hot_new.js +79 -0
- package/src/machine/game_info.js +12 -1
- package/src/machine/game_replay.js +46 -0
- package/src/machine/game_search_v2.js +401 -0
- package/src/machine/game_v2_1.js +89 -1
- package/src/machine/honor_board.js +132 -0
- package/src/machine/honor_board_cash.js +18 -15
- package/src/machine/inbox.js +12 -0
- package/src/machine/index.js +32 -0
- package/src/machine/merge.js +57 -0
- package/src/machine/payment_data.js +86 -0
- package/src/machine/promotions.js +170 -0
- package/src/machine/reward.js +255 -0
- package/src/machine/reward_cash.js +39 -0
- package/src/machine/reward_fc.js +98 -0
- package/src/machine/side.js +154 -0
- package/src/machine/side_v2.js +211 -0
- package/src/machine/user_reset_password.js +13 -0
- package/src/machine/user_sign_up.js +0 -3
- package/src/machine/vip_table.js +57 -0
- package/src/machine/websocket.js +4 -0
- package/src/machine/welcome.js +110 -0
- package/src/machine/withdraw/index.js +6 -0
- package/src/machine/withdraw/withdraw_crypto_cash.js +327 -0
- package/src/machine/withdraw/withdraw_krway.js +223 -0
- package/src/machine/withdraw/withdraw_manual.js +536 -0
- package/src/request/request.js +29 -4
- package/src/util/constant.js +1 -0
- package/src/util/index.js +4 -1
- package/src/util/math.js +4 -0
- package/test/auth_otp_v3.test.js +0 -192
package/src/api/activity.js
CHANGED
|
@@ -18,12 +18,39 @@ export default {
|
|
|
18
18
|
params: { appSecret },
|
|
19
19
|
isPublic: true,
|
|
20
20
|
}),
|
|
21
|
+
getTournamentDetail: ({ activityNo, appSecret }) => ({
|
|
22
|
+
url: 'tournament/detail',
|
|
23
|
+
method: 'get',
|
|
24
|
+
params: { activityNo, appSecret },
|
|
25
|
+
isPublic: true,
|
|
26
|
+
}),
|
|
21
27
|
getActivityDetail: ({ activityNo, appSecret, silent = false }) => ({
|
|
22
28
|
url: 'activities',
|
|
23
29
|
method: 'get',
|
|
24
30
|
params: { activityNo, appSecret },
|
|
25
31
|
silent,
|
|
26
32
|
}),
|
|
33
|
+
getActivityRanking: ({ appSecret }) => ({
|
|
34
|
+
url: 'activities/activity/ranking',
|
|
35
|
+
method: 'get',
|
|
36
|
+
params: { appSecret },
|
|
37
|
+
isPublic: true,
|
|
38
|
+
}),
|
|
39
|
+
getAchievements: ({ limit, page, appSecret }) => ({
|
|
40
|
+
url: 'activities/achievements',
|
|
41
|
+
method: 'get',
|
|
42
|
+
params: {
|
|
43
|
+
limit,
|
|
44
|
+
page,
|
|
45
|
+
appSecret,
|
|
46
|
+
},
|
|
47
|
+
}),
|
|
48
|
+
getAchievementsProgress: ({ achievementNo, appSecret }) => ({
|
|
49
|
+
url: 'activities/achievements/progress',
|
|
50
|
+
method: 'get',
|
|
51
|
+
params: { achievementNo, appSecret },
|
|
52
|
+
}),
|
|
53
|
+
getAchievementsIssued: () => ({ url: 'activities/achievements/issue', method: 'get' }),
|
|
27
54
|
postPromoCode: (promoCode) => ({
|
|
28
55
|
url: 'activities/promo',
|
|
29
56
|
method: 'post',
|
|
@@ -58,6 +85,7 @@ export default {
|
|
|
58
85
|
settleAmount: (data) => ({ url: 'activities/exchange/diamond/settle', method: 'post', params: data }),
|
|
59
86
|
exchange: (data) => ({ url: 'activities/exchange', method: 'post', params: data }),
|
|
60
87
|
collect: (data) => ({ url: 'activities/collect', method: 'post', params: data }),
|
|
88
|
+
getVipTable: ({ appSecret }) => ({ url: 'activities/viptable', method: 'get', params: { appSecret } }),
|
|
61
89
|
getLevelBonusInfo: () => ({ url: 'activities/level-bonus/info', method: 'get' }),
|
|
62
90
|
getRankingList: () => ({ url: 'activities/ranking', method: 'get' }),
|
|
63
91
|
getPublicRankingList: ({ appSecret }) => ({
|
|
@@ -66,12 +94,21 @@ export default {
|
|
|
66
94
|
isPublic: true,
|
|
67
95
|
params: { appSecret },
|
|
68
96
|
}),
|
|
97
|
+
exchangeDiamond: ({ activityNo, exchangeAward = [] }) => ({
|
|
98
|
+
url: 'activities/exchange/diamond',
|
|
99
|
+
method: 'post',
|
|
100
|
+
params: {
|
|
101
|
+
activityNo,
|
|
102
|
+
exchangeAward,
|
|
103
|
+
},
|
|
104
|
+
}),
|
|
69
105
|
getHonorBroadcast: ({ isPwa = false, appSecret }) => ({
|
|
70
106
|
url: 'activities/honorBroadcast',
|
|
71
107
|
method: 'get',
|
|
72
108
|
params: { isPwa, appSecret },
|
|
73
109
|
isPublic: true,
|
|
74
110
|
}),
|
|
111
|
+
getInstantRebateCollectTime: () => ({ url: 'activities/rebate/collectTime', method: 'get' }),
|
|
75
112
|
instantRebateEstimate: () => ({ url: 'activities/rebate/estimate', method: 'get' }),
|
|
76
113
|
instantRebateCollect: () => ({ url: 'activities/rebate/collect', method: 'get' }),
|
|
77
114
|
instantRebateHistory: ({ startDate, endDate, appSecret }) => ({
|
package/src/api/auth.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import pickBy from 'lodash/pickBy'
|
|
2
2
|
export default {
|
|
3
|
+
guestLogin: () => ({
|
|
4
|
+
url: 'guestLogin',
|
|
5
|
+
method: 'post',
|
|
6
|
+
isPublic: true,
|
|
7
|
+
}),
|
|
3
8
|
login: ({ username, password, provider, countryCode, phone, email, dt, reCaptchaToken, additionalUserInfo, loginType, isSignature, idToken }) => ({
|
|
4
9
|
url: 'login',
|
|
5
10
|
method: 'post',
|
|
@@ -7,6 +12,25 @@ export default {
|
|
|
7
12
|
isPublic: true,
|
|
8
13
|
headers: { 'x-access-captcha': reCaptchaToken },
|
|
9
14
|
}),
|
|
15
|
+
loginApp: ({ provider, accessToken, channel, subchannel, dt, from, id, name, picture }) => ({
|
|
16
|
+
url: 'appLogin',
|
|
17
|
+
method: 'post',
|
|
18
|
+
params: {
|
|
19
|
+
provider,
|
|
20
|
+
data: {
|
|
21
|
+
accessToken,
|
|
22
|
+
channel,
|
|
23
|
+
subchannel,
|
|
24
|
+
dt,
|
|
25
|
+
from,
|
|
26
|
+
id,
|
|
27
|
+
name,
|
|
28
|
+
picture,
|
|
29
|
+
provider,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
isPublic: true,
|
|
33
|
+
}),
|
|
10
34
|
register: ({ ac, fc = null, reCaptchaToken, dt, ...rest }) => {
|
|
11
35
|
const params = pickBy({ ac, fc }, (value) => {
|
|
12
36
|
return value !== undefined && value !== null
|
|
@@ -23,6 +47,13 @@ export default {
|
|
|
23
47
|
}
|
|
24
48
|
},
|
|
25
49
|
logout: () => ({ url: 'logout', method: 'post' }),
|
|
50
|
+
// bindGet for 'google' | 'zalo' | 'facebook'
|
|
51
|
+
bindGet: ({ x, provider, redirectURI }) => ({ url: 'bind', method: 'get', params: { x, provider, redirectURI } }),
|
|
52
|
+
bindPost: ({ provider, countryCode, phone, email }) => ({
|
|
53
|
+
url: 'bind',
|
|
54
|
+
method: 'post',
|
|
55
|
+
params: { provider, countryCode, phone, email },
|
|
56
|
+
}),
|
|
26
57
|
checkAccount: ({ account, nick_name, strategy, appSecret }) => ({
|
|
27
58
|
url: 'checkAccount',
|
|
28
59
|
method: 'post',
|
package/src/api/game.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export default {
|
|
2
|
+
getGameCategory: ({ id, first } = {}) => ({ method: 'get', url: 'game/list/v2/category', params: { id, first } }),
|
|
3
|
+
addFavoriteGame: (code) => ({ method: 'post', url: 'game/myfavorite/add', params: { games: [code] } }),
|
|
4
|
+
removeFavoriteGame: (code) => ({ method: 'post', url: 'game/myfavorite/remove', params: { games: [code] } }),
|
|
5
|
+
getStatements: () => ({ url: 'game/statements', method: 'get' }),
|
|
2
6
|
playGame: (params) => ({ url: 'game/play', method: 'get', params }),
|
|
3
7
|
demoGame: (params) => ({ url: 'game/demo', method: 'get', params, isPublic: true }),
|
|
4
8
|
logoutGame: ({ uid_site, provider_id }) => ({ url: 'game/logout', method: 'get', params: { uid_site, provider_id } }),
|
|
@@ -86,6 +90,12 @@ export default {
|
|
|
86
90
|
addListFavorite: (code) => ({ method: 'post', url: 'game/list/v3/addMyFavorite', params: { games: [code] } }),
|
|
87
91
|
removeListFavorite: (code) => ({ method: 'post', url: 'game/list/v3/removeMyFavorite', params: { games: [code] } }),
|
|
88
92
|
getGameInfo: ({ appSecret, gameCode }) => ({ method: 'get', url: 'game/info', params: { appSecret, gameCode } }),
|
|
93
|
+
getGameReplayInfo: ({ providerId, seqNo, lang, appSecret }) => ({
|
|
94
|
+
method: 'get',
|
|
95
|
+
url: 'game/gameReplay',
|
|
96
|
+
params: { providerId, seqNo, lang, appSecret },
|
|
97
|
+
isPublic: true,
|
|
98
|
+
}),
|
|
89
99
|
getFreeGameList: () => ({ method: 'get', url: 'activities/getFreeGameRewardList' }),
|
|
90
100
|
getFreeGameReward: ({ activityNo, receiveNo }) => ({ method: 'post', url: 'activities/getFreeGameReward', params: { activityNo, receiveNo } }),
|
|
91
101
|
getV3GameInfo: ({ appSecret, gameCodes }) => ({ method: 'post', url: 'game/list/v3/gameInfo', params: { appSecret, gameCodes } }),
|
package/src/api/payment.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export default {
|
|
2
|
+
getPaymentHistory: (returnDays) => ({ url: 'payment/v2/history', method: 'post', params: { returnDays } }),
|
|
3
|
+
getSpotMarket: () => ({ url: 'payment/v2/spotmarket', method: 'get' }),
|
|
2
4
|
getTransactionHistory: (payload) => ({
|
|
3
5
|
url: 'payment/v2/transactionHistory',
|
|
4
6
|
method: 'post',
|
|
@@ -57,6 +59,18 @@ export default {
|
|
|
57
59
|
getBankList: (paymentMethod) => ({ url: `payment/v2/${paymentMethod}/getBankList`, method: 'get' }),
|
|
58
60
|
getBindingBankList: ({ appSecret }) => ({ url: 'payment/v2/getBindingBankList', method: 'get', params: { appSecret }, isPublic: true }),
|
|
59
61
|
getBindingPaymentList: ({ appSecret }) => ({ url: 'payment/v2/getBindingPaymentList', method: 'get', params: { appSecret } }),
|
|
62
|
+
getWithdrawBankList: () => ({ url: 'payment/v2/getWithdrawBankList', method: 'get' }),
|
|
63
|
+
makeTransaction: ({ type, payload, paymentMethod }) => ({
|
|
64
|
+
url: `payment/v2/${paymentMethod}/transaction`,
|
|
65
|
+
method: 'post',
|
|
66
|
+
params: {
|
|
67
|
+
transferType: type,
|
|
68
|
+
...payload,
|
|
69
|
+
},
|
|
70
|
+
}),
|
|
71
|
+
checkTransaction: (paymentMethod) => ({ url: `payment/v2/${paymentMethod}/checkTransaction`, method: 'post' }),
|
|
72
|
+
setBonusSetting: ({ bonus }) => ({ url: 'payment/v2/setting', method: 'post', params: { bonus } }),
|
|
73
|
+
getCurrentWithdrawRule: () => ({ url: 'payment/v2/getCurrentWithdrawRule', method: 'get' }),
|
|
60
74
|
getDoubleWalletWithdrawRule: ({ walletType }) => ({
|
|
61
75
|
url: 'payment/v2/withdrawRule',
|
|
62
76
|
method: 'post',
|
|
@@ -67,6 +81,7 @@ export default {
|
|
|
67
81
|
method: 'post',
|
|
68
82
|
params: { exchangeType, cryptoNetwork, targetAddress },
|
|
69
83
|
}),
|
|
84
|
+
mergeWallet: () => ({ url: 'payment/v2/mergeWallet', method: 'post' }),
|
|
70
85
|
getPaymentDetail: ({ transferType } = {}) => ({
|
|
71
86
|
url: 'payment/v2/paymentDetail',
|
|
72
87
|
method: 'post',
|
|
@@ -87,6 +102,11 @@ export default {
|
|
|
87
102
|
method: 'post',
|
|
88
103
|
params: { transferType: 'WITHDRAW', amount, cryptoCurrency, promotionsNo },
|
|
89
104
|
}),
|
|
105
|
+
getWithdrawExpectedResult: ({ method, amount, cryptoNetwork }) => ({
|
|
106
|
+
url: `payment/v2/${method}/expected/result`,
|
|
107
|
+
method: 'post',
|
|
108
|
+
params: { transferType: 'WITHDRAW', amount, cryptoNetwork },
|
|
109
|
+
}),
|
|
90
110
|
submitDepositTransactionCrypto: ({ method, amount, cryptoCurrency, cryptoNetwork, sourceAddress, promotionsNo, receipt }) => ({
|
|
91
111
|
url: `payment/v2/${method}/transaction`,
|
|
92
112
|
method: 'post',
|
|
@@ -173,6 +193,38 @@ export default {
|
|
|
173
193
|
applyerHolderName,
|
|
174
194
|
},
|
|
175
195
|
}),
|
|
196
|
+
submitWithdrawTransactionManual: ({
|
|
197
|
+
method,
|
|
198
|
+
amount,
|
|
199
|
+
applyerBankCode,
|
|
200
|
+
applyerAccountNumber,
|
|
201
|
+
applyerIfscCode,
|
|
202
|
+
branch,
|
|
203
|
+
holderName,
|
|
204
|
+
cryptoCurrency,
|
|
205
|
+
cryptoNetwork,
|
|
206
|
+
targetAddress,
|
|
207
|
+
}) => ({
|
|
208
|
+
url: `payment/v2/${method}/withdraw-otp/verify`,
|
|
209
|
+
method: 'post',
|
|
210
|
+
params: {
|
|
211
|
+
transferType: 'WITHDRAW',
|
|
212
|
+
amount,
|
|
213
|
+
applyerBankCode,
|
|
214
|
+
applyerAccountNumber,
|
|
215
|
+
applyerIfscCode,
|
|
216
|
+
branch,
|
|
217
|
+
holderName,
|
|
218
|
+
cryptoCurrency,
|
|
219
|
+
cryptoNetwork,
|
|
220
|
+
targetAddress,
|
|
221
|
+
},
|
|
222
|
+
}),
|
|
223
|
+
submitWithdrawTransactionAmb: ({ method, amount }) => ({
|
|
224
|
+
url: `payment/v2/${method}/transaction`,
|
|
225
|
+
method: 'post',
|
|
226
|
+
params: { transferType: 'WITHDRAW', amount },
|
|
227
|
+
}),
|
|
176
228
|
getPromotionsList: () => ({ url: `payment/v2/bankWallet/promotions`, method: 'get' }),
|
|
177
229
|
getWithdrawRulePreview: ({ applyType, applyNo, amount, isFreeGame }) => ({
|
|
178
230
|
url: `payment/v2/bankWallet/promotion/preview`,
|
|
@@ -208,5 +260,4 @@ export default {
|
|
|
208
260
|
isPublic: true,
|
|
209
261
|
}),
|
|
210
262
|
getPaymentPromotions: () => ({ url: 'payment/v2/promotions', method: 'get' }),
|
|
211
|
-
setBonusSetting: ({ bonus }) => ({ url: 'payment/v2/setting', method: 'post', params: { bonus } }),
|
|
212
263
|
}
|
package/src/api/user.js
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
|
+
export const PASSWORD_RESET_INIT = 'otp-verifying'
|
|
2
|
+
export const PASSWORD_RESET_ALLOW = 'allow-change-password'
|
|
3
|
+
|
|
1
4
|
export default {
|
|
2
5
|
checkDt: () => ({ url: 'checkDt', method: 'get' }),
|
|
3
6
|
updateDt: (data) => ({ url: 'updateDt', method: 'post', params: data }),
|
|
4
7
|
getUserInfo: () => ({ url: 'self', method: 'get' }),
|
|
5
8
|
updateUserInfo: (data) => ({ url: 'self', method: 'post', params: data }),
|
|
6
9
|
changePassword: (data) => ({ url: 'settings/password', method: 'post', params: data }),
|
|
10
|
+
setPreference: ({ defaultCategory }) => ({ url: 'settings/preference', method: 'post', params: { defaultCategory } }),
|
|
7
11
|
resetOtp: ({ requestId, number }) => ({ url: 'reset', method: 'post', params: { requestId, number } }),
|
|
12
|
+
getAffiliate: () => ({ url: 'affiliate', method: 'get' }),
|
|
13
|
+
getAffiliateHome: () => ({ url: 'affiliate/home', method: 'get' }),
|
|
14
|
+
getAffiliateDashboard: () => ({ url: 'affiliate/dashboard', method: 'get' }),
|
|
15
|
+
getAffiliateDashboardList: ({ level, page, row }) => ({ url: 'affiliate/dashboard/list', method: 'post', params: { level, page, row } }),
|
|
16
|
+
postAffiliate: ({ affiliateCode }) => ({ url: 'affiliate', method: 'post', params: { affiliateCode } }),
|
|
8
17
|
getFriends: () => ({ url: 'friends', method: 'get' }),
|
|
9
18
|
getFriendsHome: () => ({ url: 'friends/home', method: 'get' }),
|
|
10
19
|
getFriendsDashboard: () => ({ url: 'friends/dashboard', method: 'get' }),
|
|
11
20
|
getFriendsDashboardList: ({ level, page, row }) => ({ url: 'friends/dashboard/list', method: 'post', params: { level, page, row } }),
|
|
12
21
|
getFriendsList: ({ type, page, row }) => ({ url: 'friends/reward-list', method: 'post', params: { type, page, row } }),
|
|
13
22
|
postFriends: ({ friendCode }) => ({ url: 'friends', method: 'post', params: { friendCode } }),
|
|
23
|
+
passwordRecovery: (recoveryData) => ({ url: 'recovery', method: 'post', params: recoveryData, isPublic: true }),
|
|
14
24
|
// passwordAbandon: ({ number }) => ({ url: 'recovery/abandon', method: 'post', params: { number }, isPublic: true }), 平台版和現金網未使用
|
|
15
25
|
// passwordAcknowledge: (acknowledgeData) => ({ url: 'recovery/acknowledge', method: 'post', params: acknowledgeData, isPublic: true }), 平台版和現金網未使用
|
|
16
26
|
verify: () => ({ url: 'verify', method: 'post' }),
|
|
@@ -40,6 +50,12 @@ export default {
|
|
|
40
50
|
params: { requestId, target, newPassword, appSecret },
|
|
41
51
|
isPublic: true,
|
|
42
52
|
}),
|
|
53
|
+
verifyV2Initiate: ({ strategy }) => ({
|
|
54
|
+
// strategy: 'phone' | 'email'
|
|
55
|
+
url: '/verify/v2/initiate',
|
|
56
|
+
method: 'post',
|
|
57
|
+
params: { strategy },
|
|
58
|
+
}),
|
|
43
59
|
otpAcknowledge: ({ requestId, target, code }) => ({
|
|
44
60
|
url: '/otpsso/acknowledge',
|
|
45
61
|
method: 'post',
|
package/src/index.js
CHANGED
|
@@ -2,6 +2,6 @@ import api from './api/index.js'
|
|
|
2
2
|
import machine from './machine/index.js'
|
|
3
3
|
import Request from './request/request.js'
|
|
4
4
|
import Config from './request/config.js'
|
|
5
|
-
import { constant, storage, paramStore } from './util/index.js'
|
|
5
|
+
import util, { constant, storage, paramStore } from './util/index.js'
|
|
6
6
|
|
|
7
|
-
export { api, machine, Request, Config, constant, storage, paramStore }
|
|
7
|
+
export { api, machine, Request, Config, util, constant, storage, paramStore }
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { createMachine, assign } from 'xstate'
|
|
2
|
+
import activity from '../../api/activity.js'
|
|
3
|
+
import payment from '../../api/payment.js'
|
|
4
|
+
|
|
5
|
+
export default function (request) {
|
|
6
|
+
const { appSecret } = request.config
|
|
7
|
+
return createMachine(
|
|
8
|
+
{
|
|
9
|
+
id: 'activity',
|
|
10
|
+
initial: 'init',
|
|
11
|
+
context: {
|
|
12
|
+
tick: 2000,
|
|
13
|
+
specifyActivities: [4, 29, 34],
|
|
14
|
+
activitiesDetailList: [],
|
|
15
|
+
activityList: [],
|
|
16
|
+
promotionList: [],
|
|
17
|
+
activityMap: {},
|
|
18
|
+
tournamentList: [],
|
|
19
|
+
refs: {},
|
|
20
|
+
uidSite: '',
|
|
21
|
+
siteConfig: {},
|
|
22
|
+
isPlaying: false,
|
|
23
|
+
},
|
|
24
|
+
states: {
|
|
25
|
+
init: {
|
|
26
|
+
on: {
|
|
27
|
+
SET_CONFIG: {
|
|
28
|
+
target: 'fetchingList',
|
|
29
|
+
actions: 'setSiteConifg',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
fetchingList: {
|
|
34
|
+
invoke: {
|
|
35
|
+
src: 'fetchList',
|
|
36
|
+
onDone: {
|
|
37
|
+
target: 'idle',
|
|
38
|
+
actions: ['setActivityList', 'setTournamentList', 'setPromotionList'],
|
|
39
|
+
},
|
|
40
|
+
onError: {
|
|
41
|
+
target: 'idle',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
idle: {
|
|
46
|
+
type: 'parallel',
|
|
47
|
+
states: {
|
|
48
|
+
activitiesDetail: {
|
|
49
|
+
initial: 'checking',
|
|
50
|
+
states: {
|
|
51
|
+
checking: {
|
|
52
|
+
always: [{ target: 'fetchActivityDetail', cond: 'hasSpecifyActivities' }, { target: 'end' }],
|
|
53
|
+
},
|
|
54
|
+
fetchActivityDetail: {
|
|
55
|
+
invoke: {
|
|
56
|
+
src: 'fetchActivitiesDetail',
|
|
57
|
+
onDone: {
|
|
58
|
+
target: 'end',
|
|
59
|
+
actions: 'setActivitiesDetailList',
|
|
60
|
+
},
|
|
61
|
+
onError: {
|
|
62
|
+
target: 'end',
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
end: {},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
pending: {
|
|
70
|
+
after: {
|
|
71
|
+
TIMEOUT: [
|
|
72
|
+
{ target: '#activity.fetchingList', cond: 'isNotInGame' },
|
|
73
|
+
{ target: '#activity.idle', cond: 'isInGame' },
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
on: {
|
|
77
|
+
SET_UNREAD: {
|
|
78
|
+
actions: 'setUnread',
|
|
79
|
+
},
|
|
80
|
+
RESET_ACTIVITIES: {
|
|
81
|
+
actions: 'resetActivities',
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
on: {
|
|
89
|
+
REFRESH: {
|
|
90
|
+
target: '#activity.fetchingList',
|
|
91
|
+
actions: 'leaveGame',
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
actions: {
|
|
97
|
+
setSiteConifg: assign((context, event) => {
|
|
98
|
+
return {
|
|
99
|
+
siteConfig: event.data,
|
|
100
|
+
}
|
|
101
|
+
}),
|
|
102
|
+
setTournamentList: assign((context, event) => {
|
|
103
|
+
const { activityList } = event.data
|
|
104
|
+
const tournamentList = activityList.filter((item) => item.tournament === 1)
|
|
105
|
+
return {
|
|
106
|
+
tournamentList,
|
|
107
|
+
}
|
|
108
|
+
}),
|
|
109
|
+
setActivityList: assign((context, event) => {
|
|
110
|
+
const noRedActivity = [2, 4, 13, 20, 90, 91, 92]
|
|
111
|
+
const { uidSite } = context
|
|
112
|
+
const { activityList } = event.data
|
|
113
|
+
let list = JSON.parse(JSON.stringify(activityList))
|
|
114
|
+
list.forEach((activity) => {
|
|
115
|
+
const storageUnread = localStorage.getItem(`unread_${activity.activityNo}_${uidSite}`)
|
|
116
|
+
if (noRedActivity.includes(activity.activityType)) {
|
|
117
|
+
activity.unread = false
|
|
118
|
+
} else if (storageUnread) {
|
|
119
|
+
activity.unread = JSON.parse(storageUnread)
|
|
120
|
+
} else {
|
|
121
|
+
activity.unread = true
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
return {
|
|
125
|
+
activityList: list,
|
|
126
|
+
}
|
|
127
|
+
}),
|
|
128
|
+
setPromotionList: assign((context, event) => {
|
|
129
|
+
const { promotionList } = event.data
|
|
130
|
+
return {
|
|
131
|
+
promotionList,
|
|
132
|
+
}
|
|
133
|
+
}),
|
|
134
|
+
setActivitiesDetailList: assign((context, event) => {
|
|
135
|
+
return {
|
|
136
|
+
activitiesDetailList: event.data.map((item) => item.data),
|
|
137
|
+
}
|
|
138
|
+
}),
|
|
139
|
+
setUnread: assign((context, event) => {
|
|
140
|
+
const { uidSite, activityNo, unread } = event.data
|
|
141
|
+
const list = JSON.parse(JSON.stringify(context.activityList))
|
|
142
|
+
localStorage.setItem(`unread_${activityNo}_${uidSite}`, `${unread}`)
|
|
143
|
+
list.map((item) => {
|
|
144
|
+
if (item.activityNo === activityNo) {
|
|
145
|
+
item.unread = JSON.parse(`${unread}`)
|
|
146
|
+
}
|
|
147
|
+
return item
|
|
148
|
+
})
|
|
149
|
+
return {
|
|
150
|
+
activityList: list,
|
|
151
|
+
uidSite,
|
|
152
|
+
}
|
|
153
|
+
}),
|
|
154
|
+
resetActivities: assign((context, event) => {
|
|
155
|
+
return {
|
|
156
|
+
isPlaying: true,
|
|
157
|
+
}
|
|
158
|
+
}),
|
|
159
|
+
leaveGame: assign((context, event) => {
|
|
160
|
+
return {
|
|
161
|
+
isPlaying: false,
|
|
162
|
+
}
|
|
163
|
+
}),
|
|
164
|
+
},
|
|
165
|
+
guards: {
|
|
166
|
+
hasSpecifyActivities: (context, event) => {
|
|
167
|
+
const { activityList = [], specifyActivities = [] } = context
|
|
168
|
+
const filterActivityList = activityList.filter((activity) => specifyActivities.includes(activity.activityType))
|
|
169
|
+
return filterActivityList.length > 0
|
|
170
|
+
},
|
|
171
|
+
isInGame: (context, event) => {
|
|
172
|
+
return context.isPlaying
|
|
173
|
+
},
|
|
174
|
+
isNotInGame: (context, event) => {
|
|
175
|
+
return !context.isPlaying
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
delays: {
|
|
179
|
+
TIMEOUT: (context, event) => {
|
|
180
|
+
const { tick } = context
|
|
181
|
+
return tick * 10
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
services: {
|
|
185
|
+
fetchList: async (context, event) => {
|
|
186
|
+
const hasToken = request.getToken()
|
|
187
|
+
const apiCallable = hasToken
|
|
188
|
+
const [{ data }, promotionList] = await Promise.all([
|
|
189
|
+
hasToken ? request.send(activity.getActivityList({ appSecret })) : request.send(activity.getAllActivityList({ appSecret })),
|
|
190
|
+
apiCallable && !context.isPlaying ? request.send(payment.getPromotionsList()) : [],
|
|
191
|
+
])
|
|
192
|
+
|
|
193
|
+
return { activityList: data, promotionList }
|
|
194
|
+
},
|
|
195
|
+
fetchActivitiesDetail: async (context, event) => {
|
|
196
|
+
await new Promise((resolve) => setTimeout(resolve, 1000)) // delay 1 second
|
|
197
|
+
|
|
198
|
+
const { activityList = [], specifyActivities = [] } = context
|
|
199
|
+
const filterActivityList = activityList.filter((activity) => specifyActivities.includes(activity.activityType))
|
|
200
|
+
const promiseArray = filterActivityList.map((item) => {
|
|
201
|
+
return request.send(activity.getActivityDetail({ activityNo: item.activityNo, appSecret }))
|
|
202
|
+
})
|
|
203
|
+
const activitiesDetail = await Promise.all(promiseArray)
|
|
204
|
+
return activitiesDetail
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
}
|
|
208
|
+
)
|
|
209
|
+
}
|