@jetthai/cuora 1.0.149-2 → 1.0.150

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,9 +2,7 @@
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.149-2](https://github.com/jetthai/cuora-module/compare/v1.0.149-1...v1.0.149-2) (2022-07-28)
6
-
7
- ### [1.0.149-1](https://github.com/jetthai/cuora-module/compare/v1.0.149...v1.0.149-1) (2022-07-27)
5
+ ### [1.0.150](https://github.com/jetthai/cuora-module/compare/v1.0.149...v1.0.150) (2022-07-27)
8
6
 
9
7
  ### [1.0.149](https://github.com/jetthai/cuora-module/compare/v1.0.148...v1.0.149) (2022-07-26)
10
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.0.149-2",
3
+ "version": "1.0.150",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
@@ -48,5 +48,4 @@ export default {
48
48
  getRewardList: ({ rewardType, count, appSecret }) => ({ url: 'activities/rewards', method: 'get', params: { rewardType, count, appSecret } }),
49
49
  exchange: (data) => ({ url: 'activities/exchange', method: 'post', params: data }),
50
50
  collect: (data) => ({ url: 'activities/collect', method: 'post', params: data }),
51
- getVipTable: () => ({ url: 'activities/viptable', method: 'get' }),
52
51
  }
package/src/api/auth.js CHANGED
@@ -19,4 +19,11 @@ export default {
19
19
  headers: { 'x-access-captcha': reCaptchaToken },
20
20
  }),
21
21
  logout: () => ({ url: 'logout', method: 'post' }),
22
+ // bindGet for 'google' | 'zalo' | 'facebook'
23
+ bindGet: ({ x, provider, redirectURI }) => ({ url: 'bind', method: 'get', params: { x, provider, redirectURI } }),
24
+ bindPost: ({ provider, countryCode, phone, email }) => ({
25
+ url: 'bind',
26
+ method: 'post',
27
+ params: { provider, countryCode, phone, email },
28
+ }),
22
29
  }
package/src/api/user.js CHANGED
@@ -10,6 +10,7 @@ export default {
10
10
  setPreference: ({ defaultCategory }) => ({ url: 'settings/preference', method: 'post', params: { defaultCategory } }),
11
11
  resetOtp: ({ requestId, number }) => ({ url: 'reset', method: 'post', params: { requestId, number } }),
12
12
  getAffiliate: () => ({ url: 'affiliate', method: 'get' }),
13
+ getVipTable: () => ({ url: 'viptable', method: 'get' }),
13
14
  postAffiliate: ({ affiliateCode }) => ({ url: 'affiliate', method: 'post', params: { affiliateCode } }),
14
15
  passwordRecovery: (recoveryData) => ({ url: 'recovery', method: 'post', params: recoveryData, isPublic: true }),
15
16
  passwordAbandon: ({ number }) => ({ url: 'recovery/abandon', method: 'post', params: { number }, isPublic: true }),
@@ -291,14 +291,14 @@ export default function (request) {
291
291
  const redirectURL = urljoin(
292
292
  request.config.fullURL,
293
293
  'login?' +
294
- qs.stringify({
295
- provider,
296
- redirectURI: `${window.location.protocol}//${window.location.host}`,
297
- channel: cookies.get('channel') || channel || defaultChannel || 'official',
298
- subchannel: cookies.get('subchannel') || subchannel || defaultSubchannel || 'pwa',
299
- // dt,
300
- platform: 'pwa',
301
- })
294
+ qs.stringify({
295
+ provider,
296
+ redirectURI: `${window.location.protocol}//${window.location.host}`,
297
+ channel: cookies.get('channel') || channel || defaultChannel || 'official',
298
+ subchannel: cookies.get('subchannel') || subchannel || defaultSubchannel || 'pwa',
299
+ // dt,
300
+ platform: 'pwa',
301
+ })
302
302
  )
303
303
  window.location.href = redirectURL
304
304
  },
@@ -330,9 +330,6 @@ export default function (request) {
330
330
  fetchUserInfo: async (context, event) => {
331
331
  return await request.send(user.getUserInfo())
332
332
  },
333
- updateUserInfo: async (context, event) => {
334
- return await request.send(user.updateUserInfo(event.data))
335
- },
336
333
  },
337
334
  }
338
335
  )
@@ -1,6 +1,6 @@
1
1
  import { createMachine, assign } from 'xstate'
2
- import api from '../api/user'
3
2
  import user from '../api/user'
3
+ import auth from '../api/auth'
4
4
 
5
5
  export default function (request) {
6
6
  return createMachine(
@@ -86,7 +86,8 @@ export default function (request) {
86
86
  invoke: {
87
87
  src: 'sendPhone',
88
88
  onDone: {
89
- target: 'checkingStatus',
89
+ target: 'otp',
90
+ actions: 'setVerificationData',
90
91
  },
91
92
  onError: { target: 'phone' },
92
93
  },
@@ -95,7 +96,8 @@ export default function (request) {
95
96
  invoke: {
96
97
  src: 'sendEmail',
97
98
  onDone: {
98
- target: 'checkingStatus',
99
+ target: 'otp',
100
+ actions: 'setVerificationData',
99
101
  },
100
102
  onError: { target: 'email' },
101
103
  },
@@ -226,22 +228,22 @@ export default function (request) {
226
228
  },
227
229
  services: {
228
230
  fetchUserInfo: async (context, event) => {
229
- return await request.send(api.getUserInfo())
231
+ return await request.send(user.getUserInfo())
230
232
  },
231
233
  verify: async (context, event) => {
232
- return await request.send(api.verifyV2Initiate({ strategy: context.strategy }))
234
+ return await request.send(user.verifyV2Initiate({ strategy: context.strategy }))
233
235
  },
234
236
  sendPhone: async (context, event) => {
235
237
  const { countryCode, phone } = context
236
- return await request.send(api.updateUserInfo({ countryCode, phone }))
238
+ return await request.send(auth.bindPost({ provider: 'phone', countryCode, phone }))
237
239
  },
238
240
  sendEmail: async (context, event) => {
239
241
  const { email } = context
240
- return await request.send(api.updateUserInfo({ email }))
242
+ return await request.send(auth.bindPost({ provider: 'email', email }))
241
243
  },
242
244
  resetOtp: async (context, event) => {
243
245
  const { requestId, target } = context
244
- return await request.send(api.otpReset({ requestId, target }))
246
+ return await request.send(user.otpReset({ requestId, target }))
245
247
  },
246
248
  acknowledge: async (context, event) => {
247
249
  const { requestId, target } = context
@@ -16,7 +16,7 @@ export default function (request) {
16
16
  currentCategory: 'direct',
17
17
  currentMethod: null,
18
18
  amount: null,
19
- result: null
19
+ result: null,
20
20
  },
21
21
  states: {
22
22
  loading: {
@@ -51,7 +51,7 @@ export default function (request) {
51
51
  loaded: {
52
52
  on: {
53
53
  SELECT_DIRECT: {
54
- actions: ['setDirect', 'reset']
54
+ actions: ['setDirect', 'reset'],
55
55
  },
56
56
  SELECT_BANK: {
57
57
  actions: 'setSelectedBank',
@@ -142,7 +142,7 @@ export default function (request) {
142
142
  }),
143
143
  setAmount: assign((context, event) => {
144
144
  return {
145
- amount: event.data
145
+ amount: event.data,
146
146
  }
147
147
  }),
148
148
  setCalculation: assign((context, event) => {
@@ -200,7 +200,7 @@ export default function (request) {
200
200
  payment.submitDepositTransactionBank({
201
201
  method: currentMethod,
202
202
  amount,
203
- applyerBankCode: selectedBank.bankCode
203
+ applyerBankCode: selectedBank.bankCode,
204
204
  })
205
205
  )
206
206
  },
@@ -15,7 +15,7 @@ export default function (request) {
15
15
  channel: null,
16
16
  subchannel: null,
17
17
  signUpData: {},
18
- reCaptchaToken: null
18
+ reCaptchaToken: null,
19
19
  },
20
20
  states: {
21
21
  idle: {
@@ -49,7 +49,7 @@ export default function (request) {
49
49
  setReCaptchaToken: assign((context, event) => {
50
50
  const { reCaptchaToken } = event.data
51
51
  return {
52
- reCaptchaToken
52
+ reCaptchaToken,
53
53
  }
54
54
  }),
55
55
  setSignUpPhone: assign((context, event) => {
@@ -89,7 +89,7 @@ export default function (request) {
89
89
  channel: cookies.get('channel') || defaultChannel || channel,
90
90
  subchannel: cookies.get('subchannel') || defaultSubchannel || subchannel,
91
91
  dt,
92
- reCaptchaToken: context.reCaptchaToken
92
+ reCaptchaToken: context.reCaptchaToken,
93
93
  })
94
94
  )
95
95
  },
@@ -1,5 +1,5 @@
1
1
  import { createMachine, assign } from 'xstate'
2
- import activity from '../api/activity'
2
+ import user from '../api/user'
3
3
  export default function (request) {
4
4
  return createMachine(
5
5
  {
@@ -7,6 +7,13 @@ export default function (request) {
7
7
  initial: 'fetching',
8
8
  context: {
9
9
  vipTable: [],
10
+ filterVipTable: [],
11
+ fasterWithdraw: [],
12
+ fasterReward: [],
13
+ cashbackOthers: [],
14
+ cashbackSlot: [],
15
+ cashbackFishing: [],
16
+ upgradeReward: [],
10
17
  },
11
18
  states: {
12
19
  fetching: {
@@ -19,32 +26,53 @@ export default function (request) {
19
26
  onError: {
20
27
  target: 'fail',
21
28
  },
22
- }
29
+ },
23
30
  },
24
31
  completed: {},
25
- fail: {}
26
- }
32
+ fail: {},
33
+ },
27
34
  },
28
35
  {
29
36
  actions: {
30
37
  setVipTable: assign((context, event) => {
31
38
  const vipTable = event.data
39
+ const filterVipTable = vipTable.filter((item) => item.title !== 'rookie' && item.title !== 'guest')
40
+ const fasterWithdraw = filterVipTable.map((item) => item.fasterWithdraw)
41
+ const fasterReward = filterVipTable.map((item) => item.fasterReward)
42
+ const cashbackOthers = filterVipTable.map((item) => item.cashbackOther)
43
+ const cashbackSlot = filterVipTable.map((item) => item.cashbackSlot)
44
+ const cashbackFishing = filterVipTable.map((item) => item.cashbackFishing)
45
+ const upgradeReward = filterVipTable.map((item) => {
46
+ return {
47
+ reward: item.upgradeReward,
48
+ type: item.rewardType,
49
+ }
50
+ })
32
51
 
33
- return { vipTable }
52
+ return {
53
+ vipTable,
54
+ filterVipTable,
55
+ fasterWithdraw,
56
+ fasterReward,
57
+ cashbackOthers,
58
+ cashbackSlot,
59
+ cashbackFishing,
60
+ upgradeReward,
61
+ }
34
62
  }),
35
63
  },
36
64
  services: {
37
65
  fetchVipTable: async (context, event) => {
38
- const { viptable = {} } = await request.send(activity.getVipTable())
66
+ const { viptable = {} } = await request.send(user.getVipTable())
39
67
  const { data = [] } = viptable
40
- data.map(item => {
68
+ data.map((item) => {
41
69
  item.title = item.title.toLowerCase()
42
70
  return item
43
71
  })
44
72
 
45
73
  return data
46
74
  },
47
- }
75
+ },
48
76
  }
49
77
  )
50
- }
78
+ }