@jetthai/cuora 1.0.54 → 1.0.56

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,6 +2,10 @@
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.56](https://github.com/jetthai/cuora-module/compare/v1.0.55...v1.0.56) (2021-12-15)
6
+
7
+ ### [1.0.55](https://github.com/jetthai/cuora-module/compare/v1.0.54...v1.0.55) (2021-12-14)
8
+
5
9
  ### [1.0.54](https://github.com/jetthai/cuora-module/compare/v1.0.53...v1.0.54) (2021-12-13)
6
10
 
7
11
  ### [1.0.53](https://github.com/jetthai/cuora-module/compare/v1.0.52...v1.0.53) (2021-12-10)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.0.54",
3
+ "version": "1.0.56",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
@@ -35,10 +35,10 @@ export default {
35
35
  method: 'post',
36
36
  params: { activityNo, gender, email, score, suggest, uidSite, affiliateCode, appSecret },
37
37
  }),
38
- getReward: ({ activityNo, receiveNo, appSecret }) => ({
38
+ getReward: ({ activityNo, receiveNo, appSecret, attended }) => ({
39
39
  url: 'activities/rewards',
40
40
  method: 'post',
41
- params: { activityNo, receiveNo, appSecret },
41
+ params: { activityNo, receiveNo, appSecret, attended },
42
42
  }),
43
43
  getRewardList: ({ count, appSecret }) => ({ url: 'activities/rewards', method: 'get', params: { count, appSecret } }),
44
44
  exchange: (data) => ({ url: 'activities/exchange', method: 'post', params: data }),
@@ -40,7 +40,7 @@ export default function (request) {
40
40
  on: {
41
41
  EXCHANGE: {
42
42
  target: 'exchanging',
43
- cond: 'isExchangeable'
43
+ cond: 'isExchangeable',
44
44
  },
45
45
  ADD_TO_CART: {
46
46
  actions: ['addProduct', 'count'],
@@ -137,7 +137,7 @@ export default function (request) {
137
137
  isExchangeable: (context, event) => {
138
138
  const { exchangeList } = context
139
139
  return exchangeList.length > 0
140
- }
140
+ },
141
141
  },
142
142
  services: {
143
143
  fetchActivityDetail: async (context, event) => {
@@ -41,11 +41,7 @@ export default function (request) {
41
41
  },
42
42
  },
43
43
  loaded: {
44
- always: [
45
- { target: 'receivable', cond: 'isReceivable' },
46
- { target: 'notReceivableYet', cond: 'isNotReceivableYet' },
47
- { target: 'empty' },
48
- ],
44
+ always: [{ target: 'receivable', cond: 'isReceivable' }, { target: 'notReceivableYet', cond: 'isNotReceivableYet' }, { target: 'empty' }],
49
45
  },
50
46
  receivable: {
51
47
  on: {
@@ -4,8 +4,8 @@ import api from '../api/user'
4
4
  export default function (request) {
5
5
  return createMachine(
6
6
  {
7
- id: 'otp',
8
- initial: 'idle',
7
+ id: 'auth_otp',
8
+ initial: 'fetching',
9
9
  context: {
10
10
  userInfo: null,
11
11
  error: null,
@@ -16,16 +16,23 @@ export default function (request) {
16
16
  ttl: 0,
17
17
  },
18
18
  states: {
19
- idle: {
19
+ fetching: {
20
+ invoke: {
21
+ src: 'fetchUserInfo',
22
+ onDone: {
23
+ target: 'checking',
24
+ actions: 'setUserInfo',
25
+ },
26
+ onError: {
27
+ target: 'fail',
28
+ },
29
+ },
30
+ },
31
+ checking: {
20
32
  always: [
21
33
  { target: 'verified', cond: 'isVerified' },
22
34
  { target: 'notVerified', cond: 'isNotVerified' },
23
35
  ],
24
- on: {
25
- SET_USER_INFO: {
26
- actions: 'setUserInfo',
27
- },
28
- },
29
36
  },
30
37
  notVerified: {
31
38
  initial: 'checkingStatus',
@@ -44,7 +51,7 @@ export default function (request) {
44
51
  },
45
52
  },
46
53
  errorChecking: {
47
- always: [{ target: 'phone', cond: 'hasNoPhone' }, { target: '#otp.fail' }],
54
+ always: [{ target: 'phone', cond: 'hasNoPhone' }, { target: '#auth_otp.fail' }],
48
55
  },
49
56
  phone: {
50
57
  on: {
@@ -87,7 +94,7 @@ export default function (request) {
87
94
  target: 'reset',
88
95
  },
89
96
  RESEND_PHONE: {
90
- target: '#otp.notVerified.phone',
97
+ target: '#auth_otp.notVerified.phone',
91
98
  },
92
99
  },
93
100
  },
@@ -95,7 +102,7 @@ export default function (request) {
95
102
  invoke: {
96
103
  src: 'acknowledge',
97
104
  onDone: {
98
- target: '#otp.verified',
105
+ target: '#auth_otp.verified',
99
106
  },
100
107
  onError: {
101
108
  target: 'idle',
@@ -169,6 +176,9 @@ export default function (request) {
169
176
  },
170
177
  },
171
178
  services: {
179
+ fetchUserInfo: async (context, event) => {
180
+ return await request.send(api.getUserInfo())
181
+ },
172
182
  verify: async (context, event) => {
173
183
  return await request.send(api.verify())
174
184
  },