@jetthai/cuora 1.1.296 → 1.1.297-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.
@@ -74,12 +74,14 @@ export default function (request) {
74
74
  },
75
75
  checking: {
76
76
  always: [
77
+ { target: 'claimAmountLimitReached', cond: 'isClaimAmountLimitReached' },
77
78
  { target: 'claimExhausted', cond: 'isClaimExhausted' },
78
79
  { target: 'insufficientAmount', cond: 'isInsufficientAmount' },
79
80
  { target: 'claimEnable', cond: 'isClaimEnable' },
80
81
  { target: 'cantEstimate' },
81
82
  ],
82
83
  },
84
+ claimAmountLimitReached: {},
83
85
  claimExhausted: {},
84
86
  insufficientAmount: {},
85
87
  claimEnable: {
@@ -161,6 +163,10 @@ export default function (request) {
161
163
  return parseInt(`${currentTime}`) - parseInt(`${lastEstimateTime}`) > fiveMinutes
162
164
  }
163
165
  },
166
+ isClaimAmountLimitReached: (context, event) => {
167
+ const { collectAvailable } = context
168
+ return !collectAvailable
169
+ },
164
170
  isClaimExhausted: (context, event) => {
165
171
  const { collectAvailable, remainingCount, dailyRedemptionLimit } = context
166
172
  return !collectAvailable && parseInt(`${remainingCount}`) === parseInt(`${dailyRedemptionLimit}`)
@@ -244,7 +244,14 @@ export default function (request, context) {
244
244
  isSubmittable: (context, event) => {
245
245
  const { selectedCrypto, selectedAddress, selectedAmount, depositTime, receipt, calculation, siteConfig } = context
246
246
  const { bankDepositProofIsOptional = '1' } = siteConfig
247
- return selectedCrypto && selectedAddress && selectedAmount && depositTime && calculation && (receipt || bankDepositProofIsOptional === '0')
247
+ return (
248
+ selectedCrypto &&
249
+ selectedAddress &&
250
+ selectedAmount &&
251
+ (bankDepositProofIsOptional === '2' ? true : depositTime) &&
252
+ calculation &&
253
+ (receipt || bankDepositProofIsOptional !== '1')
254
+ )
248
255
  },
249
256
  },
250
257
  services: {
@@ -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
+ }
@@ -501,8 +501,8 @@ export default function (request) {
501
501
  return !context.boundBanks?.length
502
502
  },
503
503
  isConvertible: (context, event) => {
504
- const { balance, enableWithdraw } = context
505
- return balance > 0 && enableWithdraw
504
+ const { enableWithdraw } = context
505
+ return enableWithdraw
506
506
  },
507
507
  isNotWithdrawable: (context, event) => {
508
508
  const { balance, enableWithdraw, paymentDetail } = context