@jetthai/cuora 1.0.114 → 1.0.116

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.116](https://github.com/jetthai/cuora-module/compare/v1.0.115...v1.0.116) (2022-05-12)
6
+
7
+ ### [1.0.115](https://github.com/jetthai/cuora-module/compare/v1.0.114...v1.0.115) (2022-05-12)
8
+
5
9
  ### [1.0.114](https://github.com/jetthai/cuora-module/compare/v1.0.113...v1.0.114) (2022-04-27)
6
10
 
7
11
  ### [1.0.113](https://github.com/jetthai/cuora-module/compare/v1.0.112...v1.0.113) (2022-04-26)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.0.114",
3
+ "version": "1.0.116",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
@@ -40,7 +40,12 @@ export default {
40
40
  method: 'post',
41
41
  params: { activityNo, receiveNo, appSecret, attended },
42
42
  }),
43
- getRewardList: ({ count, appSecret }) => ({ url: 'activities/rewards', method: 'get', params: { count, appSecret } }),
43
+ getTotalReward: ({ rewardType }) => ({
44
+ url: 'activities/rewardAmount',
45
+ method: 'get',
46
+ params: { rewardType },
47
+ }),
48
+ getRewardList: ({ rewardType, count, appSecret }) => ({ url: 'activities/rewards', method: 'get', params: { rewardType, count, appSecret } }),
44
49
  exchange: (data) => ({ url: 'activities/exchange', method: 'post', params: data }),
45
- collect: ({ appSecret }) => ({ url: 'activities/collect', method: 'post', params: { appSecret } }),
50
+ collect: (data) => ({ url: 'activities/collect', method: 'post', params: data }),
46
51
  }
@@ -35,7 +35,7 @@ export default function (request) {
35
35
  emergencyBroadcast: null,
36
36
  normalBroadcast: null,
37
37
  sentEmergencyBroadcastList: [],
38
- sentNormalBroadcastList: [],
38
+ sentNormalBroadcastList: []
39
39
  },
40
40
  states: {
41
41
  config: {
@@ -187,7 +187,7 @@ export default function (request) {
187
187
  emergencyBroadcast: nextEmergencyBroadcast,
188
188
  sentEmergencyBroadcastList: sentEmergencyList,
189
189
  normalBroadcast: nextNormalBroadcast,
190
- sentNormalBroadcastList: sentNormalList,
190
+ sentNormalBroadcastList: sentNormalList
191
191
  }
192
192
  }),
193
193
  resetBroadcast: assign((context, event) => {
@@ -195,7 +195,7 @@ export default function (request) {
195
195
  emergencyBroadcast: null,
196
196
  sentEmergencyBroadcastList: [],
197
197
  normalBroadcast: null,
198
- sentNormalBroadcastList: [],
198
+ sentNormalBroadcastList: []
199
199
  }
200
200
  }),
201
201
  },
@@ -224,7 +224,7 @@ export default function (request) {
224
224
  },
225
225
  fetchMessages: async (context, event) => {
226
226
  const { isRewardListEnable, currentTab, inbox } = JSON.parse(JSON.stringify(context))
227
- if (isRewardListEnable && currentTab === 'REWARD') {
227
+ if (isRewardListEnable && (currentTab === 'REWARD' || currentTab === 'DIAMOND')) {
228
228
  const { data } = await request.send(activity.getRewardList({ count: 30, appSecret }))
229
229
  inbox[currentTab] = { data, page: 0, totalPage: 1 }
230
230
  } else {
@@ -8,8 +8,9 @@ export default function (request) {
8
8
  id: 'reward',
9
9
  type: 'parallel',
10
10
  context: {
11
- rewardList: [],
12
- callback: () => {},
11
+ otherRewardList: [],
12
+ pointsRewardList: [],
13
+ callback: () => { },
13
14
  },
14
15
  states: {
15
16
  timer: {
@@ -48,6 +49,10 @@ export default function (request) {
48
49
  target: 'receiving',
49
50
  actions: 'setCallback',
50
51
  },
52
+ RECEIVE_ALL_POINTS: {
53
+ target: 'allPointsReceiving',
54
+ actions: 'setCallback',
55
+ },
51
56
  },
52
57
  },
53
58
  receiving: {
@@ -62,6 +67,18 @@ export default function (request) {
62
67
  },
63
68
  },
64
69
  },
70
+ allPointsReceiving: {
71
+ invoke: {
72
+ src: 'receiveAllPoints',
73
+ onDone: {
74
+ target: 'idle',
75
+ actions: [send({ type: 'REFRESH' }), 'doCallback'],
76
+ },
77
+ onError: {
78
+ target: 'idle',
79
+ },
80
+ },
81
+ }
65
82
  },
66
83
  },
67
84
  },
@@ -70,12 +87,13 @@ export default function (request) {
70
87
  actions: {
71
88
  setRewardList: assign((context, event) => {
72
89
  return {
73
- rewardList: event.data || [],
90
+ otherRewardList: event.data[0]?.data || [],
91
+ pointsRewardList: event.data[1]?.data || [],
74
92
  }
75
93
  }),
76
94
  setCallback: assign((context, event) => {
77
95
  return {
78
- callback: event.data?.callback || (() => {}),
96
+ callback: event.data?.callback || (() => { }),
79
97
  }
80
98
  }),
81
99
  doCallback: (context, event) => {
@@ -84,13 +102,18 @@ export default function (request) {
84
102
  },
85
103
  services: {
86
104
  fetchRewardList: async (context, event) => {
87
- const { data } = await request.send(activity.getRewardList({ count: 30, appSecret }))
88
- return data
105
+ const getPointsRewardAPI = request.send(activity.getRewardList({ rewardType: 'POINTS', count: 30, appSecret }))
106
+ const getOtherRewardAPI = request.send(activity.getRewardList({ rewardType: 'CASH,FREE', count: 30, appSecret }))
107
+ const [otherRewardList, pointsRewardList] = await Promise.all([getOtherRewardAPI, getPointsRewardAPI])
108
+ return [otherRewardList, pointsRewardList]
89
109
  },
90
110
  receiveReward: async (context, event) => {
91
111
  const { activityNo, receiveNo, attended } = event.data
92
112
  return await request.send(activity.getReward({ activityNo, receiveNo, appSecret, attended }))
93
113
  },
114
+ receiveAllPoints: async (context, event) => {
115
+ return await request.send(activity.collect({ collectType: 'collectPoints', appSecret }))
116
+ },
94
117
  },
95
118
  }
96
119
  )