@jetthai/cuora 1.0.72 → 1.0.73
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,8 @@
|
|
|
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.73](https://github.com/jetthai/cuora-module/compare/v1.0.72...v1.0.73) (2022-01-04)
|
|
6
|
+
|
|
5
7
|
### [1.0.72](https://github.com/jetthai/cuora-module/compare/v1.0.71...v1.0.72) (2022-01-04)
|
|
6
8
|
|
|
7
9
|
### [1.0.71](https://github.com/jetthai/cuora-module/compare/v1.0.70...v1.0.71) (2022-01-03)
|
package/package.json
CHANGED
|
@@ -7,6 +7,7 @@ import ranking_activity from './ranking_activity'
|
|
|
7
7
|
import return_bonus_activity from './return_bonus_activity'
|
|
8
8
|
import specify_bets_activity from './specify_bets_activity'
|
|
9
9
|
import specify_turnover_activity from './specify_turnover_activity'
|
|
10
|
+
import time_bomb_activity from './time_bomb_activity'
|
|
10
11
|
import activity from './activity'
|
|
11
12
|
|
|
12
13
|
export default {
|
|
@@ -19,5 +20,6 @@ export default {
|
|
|
19
20
|
return_bonus_activity,
|
|
20
21
|
specify_bets_activity,
|
|
21
22
|
specify_turnover_activity,
|
|
23
|
+
time_bomb_activity,
|
|
22
24
|
activity,
|
|
23
25
|
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import api from '../../api/activity'
|
|
3
|
+
|
|
4
|
+
export default function (request) {
|
|
5
|
+
const { appSecret } = request.config
|
|
6
|
+
return createMachine(
|
|
7
|
+
{
|
|
8
|
+
id: 'time_bomb_activity',
|
|
9
|
+
context: {
|
|
10
|
+
activityNo: null,
|
|
11
|
+
activityDetail: null,
|
|
12
|
+
duration: null,
|
|
13
|
+
},
|
|
14
|
+
initial: 'idle',
|
|
15
|
+
states: {
|
|
16
|
+
idle: {
|
|
17
|
+
on: {
|
|
18
|
+
SET_ACTIVITY_NO: {
|
|
19
|
+
target: 'loading',
|
|
20
|
+
actions: 'setActivityNo',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
loading: {
|
|
25
|
+
invoke: {
|
|
26
|
+
src: 'fetchActivityDetail',
|
|
27
|
+
onDone: {
|
|
28
|
+
target: 'loaded',
|
|
29
|
+
actions: 'setActivityDetail',
|
|
30
|
+
},
|
|
31
|
+
onError: {
|
|
32
|
+
target: 'idle',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
loaded: {
|
|
37
|
+
entry: 'setDuration',
|
|
38
|
+
always: [{ target: 'expired', cond: 'isExpired' }],
|
|
39
|
+
after: {
|
|
40
|
+
1000: {
|
|
41
|
+
target: 'loaded',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
expired: {},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
actions: {
|
|
50
|
+
setActivityNo: assign((context, event) => {
|
|
51
|
+
return {
|
|
52
|
+
activityNo: event.data,
|
|
53
|
+
}
|
|
54
|
+
}),
|
|
55
|
+
setActivityDetail: assign((context, event) => {
|
|
56
|
+
return {
|
|
57
|
+
activityDetail: event.data,
|
|
58
|
+
}
|
|
59
|
+
}),
|
|
60
|
+
setDuration: assign((context, event) => {
|
|
61
|
+
return {
|
|
62
|
+
duration: context?.activityDetail?.deadline - new Date().getTime() / 1000,
|
|
63
|
+
}
|
|
64
|
+
}),
|
|
65
|
+
},
|
|
66
|
+
guards: {
|
|
67
|
+
isExpired: (context, event) => {
|
|
68
|
+
return context.duration <= 0
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
services: {
|
|
72
|
+
fetchActivityDetail: async (context, event) => {
|
|
73
|
+
const { activityNo } = context
|
|
74
|
+
const { data } = await request.send(api.getActivityDetail({ activityNo, appSecret }))
|
|
75
|
+
return data
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
}
|
|
79
|
+
)
|
|
80
|
+
}
|