@jetthai/cuora 1.0.35 → 1.0.36
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 +2 -0
- package/package.json +1 -1
- package/src/machine/auth.js +6 -49
- package/src/machine/error.js +2 -2
- package/src/machine/index.js +2 -2
- package/src/machine/{check.js → welcome.js} +35 -33
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.0.36](https://github.com/jetthai/cuora-module/compare/v1.0.35...v1.0.36) (2021-10-29)
|
|
6
|
+
|
|
5
7
|
### [1.0.35](https://github.com/jetthai/cuora-module/compare/v1.0.34...v1.0.35) (2021-10-28)
|
|
6
8
|
|
|
7
9
|
### [1.0.34](https://github.com/jetthai/cuora-module/compare/v1.0.33...v1.0.34) (2021-10-26)
|
package/package.json
CHANGED
package/src/machine/auth.js
CHANGED
|
@@ -82,7 +82,7 @@ export default function (request) {
|
|
|
82
82
|
src: 'fetchUserInfo',
|
|
83
83
|
onDone: {
|
|
84
84
|
target: 'pending',
|
|
85
|
-
actions: ['setUserInfo', 'extendToken'],
|
|
85
|
+
actions: ['setUserInfo', 'extendToken', send({ type: 'CHECK' })],
|
|
86
86
|
},
|
|
87
87
|
onError: {
|
|
88
88
|
target: '#auth.logout',
|
|
@@ -95,57 +95,19 @@ export default function (request) {
|
|
|
95
95
|
target: 'running',
|
|
96
96
|
},
|
|
97
97
|
},
|
|
98
|
-
on: {
|
|
99
|
-
FETCH_USER_INFO: {
|
|
100
|
-
target: 'running',
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
98
|
},
|
|
104
99
|
},
|
|
105
100
|
},
|
|
106
101
|
user: {
|
|
107
|
-
id: 'user',
|
|
108
102
|
initial: 'idle',
|
|
109
103
|
states: {
|
|
110
|
-
idle: {
|
|
111
|
-
on: {
|
|
112
|
-
CHECK: {
|
|
113
|
-
target: 'checking',
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
checking: {
|
|
118
|
-
always: [
|
|
119
|
-
{ target: 'inline', cond: 'isInline' },
|
|
120
|
-
{
|
|
121
|
-
target: 'normal',
|
|
122
|
-
},
|
|
123
|
-
],
|
|
124
|
-
},
|
|
125
|
-
inline: {},
|
|
104
|
+
idle: {},
|
|
126
105
|
normal: {},
|
|
106
|
+
inline: {},
|
|
107
|
+
},
|
|
108
|
+
on: {
|
|
109
|
+
CHECK: [{ target: '.inline', cond: 'isInline' }, { target: '.normal' }],
|
|
127
110
|
},
|
|
128
|
-
// states: {
|
|
129
|
-
// idle: {
|
|
130
|
-
// on: {
|
|
131
|
-
// UPDATE_USER_INFO: {
|
|
132
|
-
// target: 'updatingUserInfo',
|
|
133
|
-
// },
|
|
134
|
-
// },
|
|
135
|
-
// },
|
|
136
|
-
// updatingUserInfo: {
|
|
137
|
-
// invoke: {
|
|
138
|
-
// src: 'updateUserInfo',
|
|
139
|
-
// onDone: {
|
|
140
|
-
// target: 'idle',
|
|
141
|
-
// actions: send({ type: 'FETCH_USER_INFO' }),
|
|
142
|
-
// },
|
|
143
|
-
// onError: {
|
|
144
|
-
// target: 'idle',
|
|
145
|
-
// },
|
|
146
|
-
// },
|
|
147
|
-
// },
|
|
148
|
-
// },
|
|
149
111
|
},
|
|
150
112
|
},
|
|
151
113
|
on: {
|
|
@@ -180,12 +142,7 @@ export default function (request) {
|
|
|
180
142
|
hasToken: (context, event) => {
|
|
181
143
|
return context.token
|
|
182
144
|
},
|
|
183
|
-
isFirstLogin: (context, event) => {
|
|
184
|
-
const { bank_account, bank_setting_status } = context.userInfo || {}
|
|
185
|
-
return !!bank_account || bank_setting_status === 1
|
|
186
|
-
},
|
|
187
145
|
isInline: (context, event) => {
|
|
188
|
-
console.log(context.userInfo?.rank, context.userInfo?.rank >= 0)
|
|
189
146
|
return context.userInfo?.rank >= 0
|
|
190
147
|
},
|
|
191
148
|
},
|
package/src/machine/error.js
CHANGED
|
@@ -26,13 +26,13 @@ export default function () {
|
|
|
26
26
|
{ target: 'logout', cond: 'isLogout' },
|
|
27
27
|
{ target: 'deposit', cond: 'isNoBalance' },
|
|
28
28
|
{ target: 'unfinishedGame', cond: 'isUnfinishedGame', actions: 'setUnfinishedGame' },
|
|
29
|
-
{ target: 'hall' },
|
|
29
|
+
// { target: 'hall' },
|
|
30
30
|
],
|
|
31
31
|
},
|
|
32
32
|
logout: {},
|
|
33
33
|
deposit: {},
|
|
34
34
|
unfinishedGame: {},
|
|
35
|
-
hall: {},
|
|
35
|
+
// hall: {},
|
|
36
36
|
},
|
|
37
37
|
},
|
|
38
38
|
},
|
package/src/machine/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import activity from './activity'
|
|
2
2
|
import auth from './auth'
|
|
3
3
|
import auth_otp from './auth_otp'
|
|
4
|
-
import
|
|
4
|
+
import welcome from './welcome'
|
|
5
5
|
import common from './common'
|
|
6
6
|
import deposit from './deposit'
|
|
7
7
|
import error from './error'
|
|
@@ -21,7 +21,7 @@ export default {
|
|
|
21
21
|
...activity,
|
|
22
22
|
auth,
|
|
23
23
|
auth_otp,
|
|
24
|
-
|
|
24
|
+
welcome,
|
|
25
25
|
common,
|
|
26
26
|
deposit,
|
|
27
27
|
error,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { assign, createMachine } from 'xstate'
|
|
1
|
+
import { assign, createMachine, send } from 'xstate'
|
|
2
2
|
import Cookies from 'universal-cookie'
|
|
3
3
|
import payment from '../api/payment'
|
|
4
4
|
import user from '../api/user'
|
|
@@ -8,27 +8,33 @@ const cookies = new Cookies()
|
|
|
8
8
|
export default function (request) {
|
|
9
9
|
return createMachine(
|
|
10
10
|
{
|
|
11
|
-
id: '
|
|
12
|
-
initial: '
|
|
11
|
+
id: 'welcome',
|
|
12
|
+
initial: 'loading',
|
|
13
13
|
context: {
|
|
14
14
|
userInfo: null,
|
|
15
15
|
bonus: null,
|
|
16
16
|
gender: null,
|
|
17
17
|
},
|
|
18
18
|
states: {
|
|
19
|
-
|
|
19
|
+
loading: {
|
|
20
|
+
invoke: {
|
|
21
|
+
src: 'fetchUserInfo',
|
|
22
|
+
onDone: {
|
|
23
|
+
target: 'checking',
|
|
24
|
+
actions: 'setUserInfo',
|
|
25
|
+
},
|
|
26
|
+
onError: {
|
|
27
|
+
target: 'checking',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
20
31
|
checking: {
|
|
21
|
-
always: [
|
|
22
|
-
{ target: 'inline', cond: 'isInline' },
|
|
23
|
-
{ target: 'inquiry', cond: 'isInquiryIncomplete' },
|
|
24
|
-
{ target: 'completed' },
|
|
25
|
-
],
|
|
32
|
+
always: [{ target: 'firstLogin', cond: 'isFirstLogin' }, { target: 'completed' }],
|
|
26
33
|
},
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
initial: 'inquiring',
|
|
34
|
+
firstLogin: {
|
|
35
|
+
initial: 'input',
|
|
30
36
|
states: {
|
|
31
|
-
|
|
37
|
+
input: {
|
|
32
38
|
on: {
|
|
33
39
|
SET_BONUS: {
|
|
34
40
|
actions: 'setBonus',
|
|
@@ -36,20 +42,20 @@ export default function (request) {
|
|
|
36
42
|
SET_GENDER: {
|
|
37
43
|
actions: 'setGender',
|
|
38
44
|
},
|
|
39
|
-
|
|
45
|
+
SEND_INFO: {
|
|
40
46
|
target: 'submitting',
|
|
41
|
-
cond: '
|
|
47
|
+
cond: 'isFilled',
|
|
42
48
|
},
|
|
43
49
|
},
|
|
44
50
|
},
|
|
45
51
|
submitting: {
|
|
46
52
|
invoke: {
|
|
47
|
-
src: '
|
|
53
|
+
src: 'updatingInfo',
|
|
48
54
|
onDone: {
|
|
49
|
-
target: '#
|
|
55
|
+
target: '#welcome.completed',
|
|
50
56
|
},
|
|
51
57
|
onError: {
|
|
52
|
-
target: '#
|
|
58
|
+
target: '#welcome.completed',
|
|
53
59
|
},
|
|
54
60
|
},
|
|
55
61
|
exit: 'setInfo',
|
|
@@ -58,24 +64,17 @@ export default function (request) {
|
|
|
58
64
|
},
|
|
59
65
|
completed: {},
|
|
60
66
|
},
|
|
61
|
-
on: {
|
|
62
|
-
SET_USER_INFO: {
|
|
63
|
-
target: 'checking',
|
|
64
|
-
actions: 'setUserInfo',
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
67
|
},
|
|
68
68
|
{
|
|
69
69
|
guards: {
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
isFirstLogin: (context, event) => {
|
|
71
|
+
const { bank_account, bank_setting_status, topup, verification_status, uid } = context.userInfo || {}
|
|
72
|
+
// const hasBankAccount = bank_account || bank_setting_status === 1 // sabai
|
|
73
|
+
const isComplete = topup === 1 || verification_status === 1
|
|
74
|
+
const isSent = cookies.get(`welcome_${uid}`)
|
|
75
|
+
return !(isSent || isComplete)
|
|
72
76
|
},
|
|
73
|
-
|
|
74
|
-
const { bank_account, bank_setting_status, uid } = context.userInfo || {}
|
|
75
|
-
const hasBankAccount = bank_account || bank_setting_status === 1
|
|
76
|
-
return !hasBankAccount && !cookies.get(`welcome_${uid}`)
|
|
77
|
-
},
|
|
78
|
-
isInquiryFilled: (context, event) => {
|
|
77
|
+
isFilled: (context, event) => {
|
|
79
78
|
const { bonus, gender } = context
|
|
80
79
|
return bonus !== null && gender !== null
|
|
81
80
|
},
|
|
@@ -100,7 +99,10 @@ export default function (request) {
|
|
|
100
99
|
}),
|
|
101
100
|
},
|
|
102
101
|
services: {
|
|
103
|
-
|
|
102
|
+
fetchUserInfo: async (context, event) => {
|
|
103
|
+
return await request.send(user.getUserInfo())
|
|
104
|
+
},
|
|
105
|
+
updatingInfo: async (context, event) => {
|
|
104
106
|
const { bonus, gender } = context
|
|
105
107
|
await Promise.all([
|
|
106
108
|
request.send(payment.setBonusSetting({ bonus })),
|