@jetthai/cuora 1.1.112-1 → 1.1.113

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,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.1.112-1](https://github.com/jetthai/cuora-module/compare/v1.1.112...v1.1.112-1) (2023-05-31)
5
+ ### [1.1.113](https://github.com/jetthai/cuora-module/compare/v1.1.96-signin-5...v1.1.113) (2023-05-31)
6
6
 
7
7
  ### [1.1.112](https://github.com/jetthai/cuora-module/compare/v1.1.104-1...v1.1.112) (2023-05-31)
8
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.112-1",
3
+ "version": "1.1.113",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -16,6 +16,7 @@ import sign_in_activity from './sign_in_activity.js'
16
16
  import time_bomb_activity from './time_bomb_activity.js'
17
17
  import mini_game_activity from './mini_game_activity.js'
18
18
  import roulette_activity_v2 from './roulette_activity_v2.js'
19
+ import sign_in_monthly_activity from './sign_in_monthly_activity.js'
19
20
  import otp_verified_activity from './otp_verified_activity.js'
20
21
 
21
22
  export default {
@@ -37,5 +38,6 @@ export default {
37
38
  time_bomb_activity,
38
39
  mini_game_activity,
39
40
  roulette_activity_v2,
41
+ sign_in_monthly_activity,
40
42
  otp_verified_activity,
41
43
  }
@@ -0,0 +1,65 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import api from '@jetthai/cuora/src/api/activity'
3
+
4
+ export default function (request) {
5
+ const { appSecret } = request.config
6
+ return createMachine(
7
+ {
8
+ id: 'sign_in_monthly',
9
+ context: {
10
+ activityNo: null,
11
+ activityDetail: null,
12
+ receiveStatus: 0,
13
+ rewardsCalendar: [],
14
+ },
15
+ initial: 'idle',
16
+ states: {
17
+ idle: {
18
+ on: {
19
+ SET_ACTIVITY_NO: {
20
+ target: 'fetching',
21
+ actions: 'setActivityNo',
22
+ },
23
+ },
24
+ },
25
+ fetching: {
26
+ invoke: {
27
+ src: 'fetchActivityDetail',
28
+ onDone: {
29
+ target: 'loaded',
30
+ actions: 'setInitData',
31
+ },
32
+ onError: {
33
+ target: 'loaded',
34
+ },
35
+ },
36
+ },
37
+ loaded: {},
38
+ },
39
+ },
40
+ {
41
+ actions: {
42
+ setActivityNo: assign((context, event) => {
43
+ return {
44
+ activityNo: event.data,
45
+ }
46
+ }),
47
+ setInitData: assign((context, event) => {
48
+ const { rewardsCalendar = [], receiveStatus = 0 } = event.data || {}
49
+ return {
50
+ activityDetail: event.data,
51
+ rewardsCalendar,
52
+ receiveStatus,
53
+ }
54
+ }),
55
+ },
56
+ services: {
57
+ fetchActivityDetail: async (context, event) => {
58
+ const { activityNo } = context
59
+ const { data } = await request.send(api.getActivityDetail({ activityNo, appSecret }))
60
+ return data
61
+ },
62
+ },
63
+ }
64
+ )
65
+ }
@@ -90,7 +90,10 @@ export default function (request) {
90
90
  receiving: {
91
91
  invoke: {
92
92
  src: 'receiveReward',
93
- onDone: [{ actions: send({ type: 'REFRESH' }) }, { target: 'idle', cond: 'isPrize' }, { target: 'idle', actions: 'doCallback' }],
93
+ onDone: {
94
+ target: 'received',
95
+ actions: [send({ type: 'REFRESH' }), 'doCallback'],
96
+ },
94
97
  onError: {
95
98
  target: 'idle',
96
99
  },
@@ -149,16 +152,11 @@ export default function (request) {
149
152
  }
150
153
  }),
151
154
  },
152
- guards: {
153
- isPrize: (context, event) => {
154
- return event.data?.rewardType === 'PRIZE'
155
- },
156
- },
157
155
  services: {
158
156
  fetchRewardList: async (context, event) => {
159
157
  const getRewardAPI = request.send(activity.getRewardList({ count: 30, appSecret }))
160
158
  const getPointsRewardAPI = request.send(activity.getRewardList({ rewardType: 'POINTS', count: 30, appSecret }))
161
- const getOtherRewardAPI = request.send(activity.getRewardList({ rewardType: 'CASH,FREE,PRIZE', count: 30, appSecret }))
159
+ const getOtherRewardAPI = request.send(activity.getRewardList({ rewardType: 'CASH,FREE', count: 30, appSecret }))
162
160
  const [otherRewardList, pointsRewardList, rewardList] = await Promise.all([getOtherRewardAPI, getPointsRewardAPI, getRewardAPI])
163
161
  return [otherRewardList, pointsRewardList, rewardList]
164
162
  },