@jetthai/cuora 1.0.115 → 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,7 +2,9 @@
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.115](https://github.com/jetthai/cuora-module/compare/v1.0.114...v1.0.115) (2022-04-29)
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)
6
8
 
7
9
  ### [1.0.114](https://github.com/jetthai/cuora-module/compare/v1.0.113...v1.0.114) (2022-04-27)
8
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.0.115",
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
  }
@@ -264,18 +264,18 @@ export default function (request) {
264
264
  }),
265
265
  redirectTo3Party: async (context, event) => {
266
266
  const { provider, channel, subchannel } = event.data
267
- const dt = await getDeviceToken({ fpToken, sentry, apiURL: request.config.apiURL })
267
+ // const dt = await getDeviceToken({ fpToken, sentry, apiURL: request.config.apiURL })
268
268
  const redirectURL = urljoin(
269
269
  request.config.fullURL,
270
270
  'login?' +
271
- qs.stringify({
272
- provider,
273
- redirectURI: `${window.location.protocol}//${window.location.host}`,
274
- channel: cookies.get('channel') || channel || 'official',
275
- subchannel: cookies.get('subchannel') || subchannel || 'pwa',
276
- dt,
277
- platform: 'pwa',
278
- })
271
+ qs.stringify({
272
+ provider,
273
+ redirectURI: `${window.location.protocol}//${window.location.host}`,
274
+ channel: cookies.get('channel') || channel || 'official',
275
+ subchannel: cookies.get('subchannel') || subchannel || 'pwa',
276
+ // dt,
277
+ platform: 'pwa',
278
+ })
279
279
  )
280
280
  window.location.href = redirectURL
281
281
  },
@@ -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
  )