@jetthai/cuora 1.0.191 → 1.0.192

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.192](https://github.com/jetthai/cuora-module/compare/v1.0.191...v1.0.192) (2022-10-26)
6
+
5
7
  ### [1.0.191](https://github.com/jetthai/cuora-module/compare/v1.0.184-3...v1.0.191) (2022-10-26)
6
8
 
7
9
  ### [1.0.190](https://github.com/jetthai/cuora-module/compare/v1.0.184-2...v1.0.190) (2022-10-18)
package/dist/bundle.mjs CHANGED
@@ -7286,6 +7286,154 @@ function specify_turnover_activity (request) {
7286
7286
  )
7287
7287
  }
7288
7288
 
7289
+ function sign_in_activity (request) {
7290
+ const { appSecret } = request.config;
7291
+ return createMachine(
7292
+ {
7293
+ id: 'sign_in_activity',
7294
+ context: {
7295
+ activityNo: null,
7296
+ receiveNo: null,
7297
+ activityDetail: null,
7298
+ rewardType: null,
7299
+
7300
+ // 領獎後得到的資訊
7301
+ receiveStatus: null,
7302
+ progressStatus: null,
7303
+ achieve: false,
7304
+ awards: [],
7305
+ target: null,
7306
+ turnover: null,
7307
+ dayOfTheWeek: 1,
7308
+ },
7309
+ initial: 'idle',
7310
+ states: {
7311
+ idle: {
7312
+ on: {
7313
+ SET_ACTIVITY_NO: {
7314
+ target: 'loading',
7315
+ actions: 'setActivityNo',
7316
+ },
7317
+ },
7318
+ },
7319
+ loading: {
7320
+ invoke: {
7321
+ src: 'fetchActivityDetail',
7322
+ onDone: {
7323
+ target: 'loaded',
7324
+ actions: 'setActivityDetail',
7325
+ },
7326
+ onError: {
7327
+ target: 'idle',
7328
+ },
7329
+ },
7330
+ },
7331
+ loaded: {
7332
+ always: [{ target: 'received', cond: 'isReceived' }, { target: 'receiveable', cond: 'isReceiveable' }, { target: 'progress_status' }],
7333
+ },
7334
+ received: {
7335
+ entry: assign((context, event) => {
7336
+ return {
7337
+ progressStatus: 100,
7338
+ }
7339
+ }),
7340
+ },
7341
+ receiveable: {
7342
+ on: {
7343
+ RECEIVE_REWARD: {
7344
+ target: 'receiving',
7345
+ actions: 'setCallback',
7346
+ },
7347
+ },
7348
+ },
7349
+ receiving: {
7350
+ invoke: {
7351
+ src: 'receiveReward',
7352
+ onDone: {
7353
+ target: 'loaded',
7354
+ actions: 'doCallback',
7355
+ },
7356
+ onError: {
7357
+ target: 'loaded',
7358
+ },
7359
+ },
7360
+ },
7361
+ progress_status: {
7362
+ entry: 'setProgressStatus',
7363
+ },
7364
+ },
7365
+ },
7366
+ {
7367
+ actions: {
7368
+ setActivityNo: assign((context, event) => {
7369
+ console.log('Event:', event.data);
7370
+ return {
7371
+ activityNo: event.data,
7372
+ }
7373
+ }),
7374
+ setActivityDetail: assign((context, event) => {
7375
+ return {
7376
+ activityDetail: event.data,
7377
+ receiveNo: event.data.receiveNo,
7378
+ rewardType: event.data.policy,
7379
+ receiveStatus: event.data.receiveStatus,
7380
+ achieve: event.data.achieve,
7381
+ awards: event.data.awards,
7382
+ target: event.data.target,
7383
+ turnover: event.data.turnover,
7384
+ dayOfTheWeek: event.data.dayOfTheWeek,
7385
+ }
7386
+ }),
7387
+ setProgressStatus: assign((context, event) => {
7388
+ const tempProgress = (parseFloat(context.turnover) / parseFloat(context.target)) * 100;
7389
+ let progressType = null;
7390
+ if (tempProgress < 25) progressType = 0;
7391
+ else if (tempProgress >= 25 && tempProgress < 50) progressType = 25;
7392
+ else if (tempProgress >= 50 && tempProgress < 75) progressType = 50;
7393
+ else if (tempProgress >= 75 && tempProgress < 100) progressType = 75;
7394
+ else if (tempProgress >= 100) progressType = 100;
7395
+ else progressType = 0;
7396
+
7397
+ return {
7398
+ progressStatus: progressType,
7399
+ }
7400
+ }),
7401
+ setCallback: assign((context, event) => {
7402
+ return {
7403
+ callback: event.data?.callback || (() => { }),
7404
+ }
7405
+ }),
7406
+ doCallback: (context, event) => {
7407
+ context.callback();
7408
+ },
7409
+ },
7410
+ guards: {
7411
+ hasActivityNo: (context, event) => {
7412
+ return context.activityNo
7413
+ },
7414
+ isReceived: (context, event) => {
7415
+ return context.receiveStatus === 1
7416
+ },
7417
+ isReceiveable: (context, event) => {
7418
+ return context.receiveStatus === 2
7419
+ },
7420
+ },
7421
+ services: {
7422
+ fetchActivityDetail: async (context, event) => {
7423
+ const { activityNo } = context;
7424
+ const { data } = await request.send(activity$2.getActivityDetail({ activityNo, appSecret }));
7425
+ return data
7426
+ },
7427
+ receiveReward: async (context, event) => {
7428
+ const { activityNo, receiveNo } = context;
7429
+ const { data } = await request.send(activity$2.getReward({ activityNo, receiveNo, appSecret }));
7430
+ return data
7431
+ },
7432
+ },
7433
+ }
7434
+ )
7435
+ }
7436
+
7289
7437
  function time_bomb_activity (request) {
7290
7438
  const { appSecret } = request.config;
7291
7439
  return createMachine(
@@ -7506,6 +7654,7 @@ var activity = {
7506
7654
  return_bonus_activity,
7507
7655
  specify_bets_activity,
7508
7656
  specify_turnover_activity,
7657
+ sign_in_activity,
7509
7658
  time_bomb_activity,
7510
7659
  mini_game_activity,
7511
7660
  activity: activity$1,
@@ -17282,15 +17431,7 @@ function loadcard_vn (request) {
17282
17431
  id: 'loadcard',
17283
17432
  initial: 'loading',
17284
17433
  context: {
17285
- cards: [
17286
- { name: 'mobifone', code: 'VMS', category: 'loadcard', methodDescription: 'MOBIFONE' },
17287
- { name: 'viettel', code: 'VTT', category: 'loadcard', methodDescription: 'VIETTEL' },
17288
- { name: 'vinaphone', code: 'VNP', category: 'loadcard', methodDescription: 'VINAPHONE' },
17289
- // { name: 'vietnam mobile', code: 'VNM' },
17290
- // { name: 'thẻ zing', code: 'ZING' },
17291
- // { name: 'thẻ gate', code: 'GATE' },
17292
- // { name: 'thẻ garena', code: 'GARENA' },
17293
- ],
17434
+ cards: [],
17294
17435
  options: [],
17295
17436
 
17296
17437
  selectedCard: null,
@@ -17325,20 +17466,37 @@ function loadcard_vn (request) {
17325
17466
  actions: 'setCard',
17326
17467
  },
17327
17468
  SELECT_AMOUNT: {
17328
- target: 'calculable',
17469
+ target: 'debouncing',
17329
17470
  actions: 'setAmount',
17330
17471
  },
17331
17472
  },
17332
17473
  },
17474
+ debouncing: {
17475
+ on: {
17476
+ SELECT_AMOUNT: {
17477
+ target: 'debouncing',
17478
+ actions: 'setAmount',
17479
+ },
17480
+ BACK: {
17481
+ target: 'loaded',
17482
+ },
17483
+ },
17484
+ after: {
17485
+ 1000: {
17486
+ target: 'calculating',
17487
+ },
17488
+ },
17489
+ },
17333
17490
  fail: {},
17334
17491
  calculable: {
17335
17492
  entry: 'clearCalculation',
17336
17493
  on: {
17337
17494
  SELECT_AMOUNT: {
17495
+ target: 'debouncing',
17338
17496
  actions: 'setAmount',
17339
17497
  },
17340
17498
  CALCULATE: {
17341
- target: 'calculating',
17499
+ target: 'debouncing',
17342
17500
  },
17343
17501
  BACK: {
17344
17502
  target: 'loaded',
@@ -17360,7 +17518,7 @@ function loadcard_vn (request) {
17360
17518
  calculated: {
17361
17519
  on: {
17362
17520
  SELECT_AMOUNT: {
17363
- target: 'calculable',
17521
+ target: 'debouncing',
17364
17522
  actions: 'setAmount',
17365
17523
  },
17366
17524
  CONFIRM: {
@@ -17370,7 +17528,7 @@ function loadcard_vn (request) {
17370
17528
  target: 'loaded',
17371
17529
  },
17372
17530
  CLEAR_CALCULATION: {
17373
- target: 'calculable',
17531
+ target: 'debouncing',
17374
17532
  actions: 'clearCalculation',
17375
17533
  },
17376
17534
  },
@@ -17425,18 +17583,20 @@ function loadcard_vn (request) {
17425
17583
  }),
17426
17584
  setInitData: assign((context, event) => {
17427
17585
  const paymentDetails = event.data;
17428
- const currentPayment = paymentDetails.find((element) => element.category === context.currentCategory);
17586
+ const cards = paymentDetails.filter((element) => element.category === context.currentCategory);
17429
17587
  return {
17430
17588
  paymentDetails,
17431
- currentPayment,
17432
- currentMethod: currentPayment.method,
17433
- options: currentPayment.optional,
17434
- selectedCard: context.cards[0],
17589
+ cards,
17590
+ selectedCard: cards[0],
17591
+ currentMethod: cards[0].method,
17592
+ options: cards[0].optional
17435
17593
  }
17436
17594
  }),
17437
17595
  setCard: assign((context, event) => {
17438
17596
  return {
17439
17597
  selectedCard: event.data,
17598
+ currentMethod: event.data.method,
17599
+ options: event.data.optional,
17440
17600
  }
17441
17601
  }),
17442
17602
  setCardNumber: assign((context, event) => {
@@ -17473,11 +17633,6 @@ function loadcard_vn (request) {
17473
17633
  fetchInitData: async (context, event) => {
17474
17634
  return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
17475
17635
  },
17476
- fetchBanksList: async (context, event) => {
17477
- const { paymentDetails, currentCategory } = context;
17478
- const method = paymentDetails.find((item) => item.category === currentCategory)?.method;
17479
- return await request.send(payment.getBankList(method))
17480
- },
17481
17636
  fetchCalculation: async (context, event) => {
17482
17637
  const { currentMethod, selectedAmount } = context;
17483
17638
  return await request.send(
@@ -17493,7 +17648,7 @@ function loadcard_vn (request) {
17493
17648
  payment.submitDepositTransactionLoadcard({
17494
17649
  method: currentMethod,
17495
17650
  amount: selectedAmount,
17496
- card_type: selectedCard.code,
17651
+ card_type: selectedCard.channel_id,
17497
17652
  card_code: cardNumber,
17498
17653
  card_seri: serialNumber,
17499
17654
  })
@@ -17906,11 +18061,6 @@ function qrcode_v2 (request) {
17906
18061
  fetchInitData: async (context, event) => {
17907
18062
  return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
17908
18063
  },
17909
- fetchBanksList: async (context, event) => {
17910
- const { paymentDetails, currentCategory } = context;
17911
- const method = paymentDetails.find((item) => item.category === currentCategory)?.method;
17912
- return await request.send(payment.getBankList(method))
17913
- },
17914
18064
  fetchCalculation: async (context, event) => {
17915
18065
  const { currentMethod, selectedAmount } = context;
17916
18066
  return await request.send(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.0.191",
3
+ "version": "1.0.192",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -1,5 +1,5 @@
1
1
  import { assign, createMachine } from 'xstate'
2
- import apiActivity from '../../api/activity.js'
2
+ import api from '../../api/activity.js'
3
3
 
4
4
  export default function (request) {
5
5
  const { appSecret } = request.config
@@ -186,18 +186,18 @@ export default function (request) {
186
186
  },
187
187
  services: {
188
188
  fetchActivityList: async (context, event) => {
189
- const { data } = await request.send(apiActivity.getActivityList({ appSecret }))
189
+ const { data } = await request.send(api.getActivityList({ appSecret }))
190
190
  return data
191
191
  },
192
192
  fetchActivityDetail: async (context, event) => {
193
193
  const { activityNo } = context
194
- const { data } = await request.send(apiActivity.getActivityDetail({ activityNo, appSecret }))
194
+ const { data } = await request.send(api.getActivityDetail({ activityNo, appSecret }))
195
195
  return data
196
196
  },
197
197
  exchange: async (context, event) => {
198
198
  const { activityNo } = context
199
199
  return await request.send(
200
- apiActivity.exchange({
200
+ api.exchange({
201
201
  exchangeType: 1,
202
202
  activityNo,
203
203
  exchangeAward: event.data,
@@ -205,7 +205,7 @@ export default function (request) {
205
205
  )
206
206
  },
207
207
  collect: async (context, event) => {
208
- return await request.send(apiActivity.collect({ appSecret }))
208
+ return await request.send(api.collect({ appSecret }))
209
209
  },
210
210
  },
211
211
  }
@@ -8,6 +8,7 @@ import ranking_activity from './ranking_activity.js'
8
8
  import return_bonus_activity from './return_bonus_activity.js'
9
9
  import specify_bets_activity from './specify_bets_activity.js'
10
10
  import specify_turnover_activity from './specify_turnover_activity.js'
11
+ import sign_in_activity from './sign_in_activity.js'
11
12
  import time_bomb_activity from './time_bomb_activity.js'
12
13
  import mini_game_activity from './mini_game_activity.js'
13
14
  import activity from './activity.js'
@@ -23,6 +24,7 @@ export default {
23
24
  return_bonus_activity,
24
25
  specify_bets_activity,
25
26
  specify_turnover_activity,
27
+ sign_in_activity,
26
28
  time_bomb_activity,
27
29
  mini_game_activity,
28
30
  activity,
@@ -0,0 +1,150 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import api from '../../api/activity.js'
3
+
4
+ export default function (request) {
5
+ const { appSecret } = request.config
6
+ return createMachine(
7
+ {
8
+ id: 'sign_in_activity',
9
+ context: {
10
+ activityNo: null,
11
+ receiveNo: null,
12
+ activityDetail: null,
13
+ rewardType: null,
14
+
15
+ // 領獎後得到的資訊
16
+ receiveStatus: null,
17
+ progressStatus: null,
18
+ achieve: false,
19
+ awards: [],
20
+ target: null,
21
+ turnover: null,
22
+ dayOfTheWeek: 1,
23
+ },
24
+ initial: 'idle',
25
+ states: {
26
+ idle: {
27
+ on: {
28
+ SET_ACTIVITY_NO: {
29
+ target: 'loading',
30
+ actions: 'setActivityNo',
31
+ },
32
+ },
33
+ },
34
+ loading: {
35
+ invoke: {
36
+ src: 'fetchActivityDetail',
37
+ onDone: {
38
+ target: 'loaded',
39
+ actions: 'setActivityDetail',
40
+ },
41
+ onError: {
42
+ target: 'idle',
43
+ },
44
+ },
45
+ },
46
+ loaded: {
47
+ always: [{ target: 'received', cond: 'isReceived' }, { target: 'receiveable', cond: 'isReceiveable' }, { target: 'progress_status' }],
48
+ },
49
+ received: {
50
+ entry: assign((context, event) => {
51
+ return {
52
+ progressStatus: 100,
53
+ }
54
+ }),
55
+ },
56
+ receiveable: {
57
+ on: {
58
+ RECEIVE_REWARD: {
59
+ target: 'receiving',
60
+ actions: 'setCallback',
61
+ },
62
+ },
63
+ },
64
+ receiving: {
65
+ invoke: {
66
+ src: 'receiveReward',
67
+ onDone: {
68
+ target: 'loaded',
69
+ actions: 'doCallback',
70
+ },
71
+ onError: {
72
+ target: 'loaded',
73
+ },
74
+ },
75
+ },
76
+ progress_status: {
77
+ entry: 'setProgressStatus',
78
+ },
79
+ },
80
+ },
81
+ {
82
+ actions: {
83
+ setActivityNo: assign((context, event) => {
84
+ console.log('Event:', event.data)
85
+ return {
86
+ activityNo: event.data,
87
+ }
88
+ }),
89
+ setActivityDetail: assign((context, event) => {
90
+ return {
91
+ activityDetail: event.data,
92
+ receiveNo: event.data.receiveNo,
93
+ rewardType: event.data.policy,
94
+ receiveStatus: event.data.receiveStatus,
95
+ achieve: event.data.achieve,
96
+ awards: event.data.awards,
97
+ target: event.data.target,
98
+ turnover: event.data.turnover,
99
+ dayOfTheWeek: event.data.dayOfTheWeek,
100
+ }
101
+ }),
102
+ setProgressStatus: assign((context, event) => {
103
+ const tempProgress = (parseFloat(context.turnover) / parseFloat(context.target)) * 100
104
+ let progressType = null
105
+ if (tempProgress < 25) progressType = 0
106
+ else if (tempProgress >= 25 && tempProgress < 50) progressType = 25
107
+ else if (tempProgress >= 50 && tempProgress < 75) progressType = 50
108
+ else if (tempProgress >= 75 && tempProgress < 100) progressType = 75
109
+ else if (tempProgress >= 100) progressType = 100
110
+ else progressType = 0
111
+
112
+ return {
113
+ progressStatus: progressType,
114
+ }
115
+ }),
116
+ setCallback: assign((context, event) => {
117
+ return {
118
+ callback: event.data?.callback || (() => { }),
119
+ }
120
+ }),
121
+ doCallback: (context, event) => {
122
+ context.callback()
123
+ },
124
+ },
125
+ guards: {
126
+ hasActivityNo: (context, event) => {
127
+ return context.activityNo
128
+ },
129
+ isReceived: (context, event) => {
130
+ return context.receiveStatus === 1
131
+ },
132
+ isReceiveable: (context, event) => {
133
+ return context.receiveStatus === 2
134
+ },
135
+ },
136
+ services: {
137
+ fetchActivityDetail: async (context, event) => {
138
+ const { activityNo } = context
139
+ const { data } = await request.send(api.getActivityDetail({ activityNo, appSecret }))
140
+ return data
141
+ },
142
+ receiveReward: async (context, event) => {
143
+ const { activityNo, receiveNo } = context
144
+ const { data } = await request.send(api.getReward({ activityNo, receiveNo, appSecret }))
145
+ return data
146
+ },
147
+ },
148
+ }
149
+ )
150
+ }