@jetthai/cuora 1.0.203 → 1.0.204

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.204](https://github.com/jetthai/cuora-module/compare/v1.0.203...v1.0.204) (2022-11-21)
6
+
5
7
  ### [1.0.203](https://github.com/jetthai/cuora-module/compare/v1.0.202...v1.0.203) (2022-11-17)
6
8
 
7
9
  ### [1.0.202](https://github.com/jetthai/cuora-module/compare/v1.0.201...v1.0.202) (2022-11-14)
package/dist/bundle.mjs CHANGED
@@ -86,8 +86,8 @@ var auth$1 = {
86
86
  },
87
87
  isPublic: true,
88
88
  }),
89
- register: ({ channel = 'official', subchannel = 'pwa', reCaptchaToken, dt, ...rest }) => ({
90
- url: `register?channel=${channel}&subchannel=${subchannel}`,
89
+ register: ({ channel = 'official', subchannel = 'pwa', affiliate = null, reCaptchaToken, dt, ...rest }) => ({
90
+ url: `register?channel=${channel}&subchannel=${subchannel}${affiliate ? `&affiliate=${affiliate}` : ''}`,
91
91
  method: 'post',
92
92
  params: { dt, ...rest },
93
93
  isPublic: true,
@@ -321,6 +321,9 @@ var user = {
321
321
  setPreference: ({ defaultCategory }) => ({ url: 'settings/preference', method: 'post', params: { defaultCategory } }),
322
322
  resetOtp: ({ requestId, number }) => ({ url: 'reset', method: 'post', params: { requestId, number } }),
323
323
  getAffiliate: () => ({ url: 'affiliate', method: 'get' }),
324
+ getAffiliateHome: () => ({ url: 'affiliate/home', method: 'get' }),
325
+ getAffiliateDashboard: () => ({ url: 'affiliate/dashboard', method: 'get' }),
326
+ getAffiliateDashboardList: ({ level, page, row }) => ({ url: 'affiliate/dashboard/list', method: 'post', params: { level, page, row } }),
324
327
  postAffiliate: ({ affiliateCode }) => ({ url: 'affiliate', method: 'post', params: { affiliateCode } }),
325
328
  passwordRecovery: (recoveryData) => ({ url: 'recovery', method: 'post', params: recoveryData, isPublic: true }),
326
329
  passwordAbandon: ({ number }) => ({ url: 'recovery/abandon', method: 'post', params: { number }, isPublic: true }),
@@ -6820,10 +6823,193 @@ function invite_friends_activity (request) {
6820
6823
  )
6821
6824
  }
6822
6825
 
6823
- // activityNo: "1627572510449"
6824
- // affiliateCode: "363022150296"
6825
- // appSecret: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1NjM0MzI0NzZ9.ofBZV-ecs8C04MkXi0zGk6w2Ltpu_MCuOUpwPUfnz7o"
6826
- // uidSite: "fkkuez6qcck9qn83lu@FK"
6826
+ function affiliate_invite_friends_activity (request) {
6827
+ const { appSecret } = request.config;
6828
+ return createMachine(
6829
+ {
6830
+ id: 'affiliate_invite_friends_activity',
6831
+ context: {
6832
+ affiliateEnable: false,
6833
+ activityNo: null,
6834
+ bindingCode: null,
6835
+ uidSite: null,
6836
+ receiveNo: null,
6837
+ affiliateCode: '',
6838
+ commission: 0,
6839
+ downLine: 0,
6840
+ activeDownLine: 0,
6841
+ levelTable: [],
6842
+ pastTable: [],
6843
+ levelDownLine: {},
6844
+ currentLevel: 1,
6845
+ page: 1
6846
+ },
6847
+ initial: 'fetching1',
6848
+ states: {
6849
+ fetching1: {
6850
+ invoke: {
6851
+ src: 'fetchAffiliateCode',
6852
+ onDone: {
6853
+ target: 'checking',
6854
+ actions: 'setAffiliateCode',
6855
+ },
6856
+ onError: {
6857
+ target: 'fetching2',
6858
+ },
6859
+ },
6860
+ },
6861
+ checking: {
6862
+ always: [
6863
+ { target: 'fetching2', cond: 'isAffiliateEnable' },
6864
+ { target: 'idle' },
6865
+ ],
6866
+ },
6867
+ fetching2: {
6868
+ invoke: {
6869
+ src: 'fetchAffiliateData',
6870
+ onDone: {
6871
+ target: 'idle',
6872
+ actions: 'setInitialData',
6873
+ },
6874
+ onError: {
6875
+ target: 'fail',
6876
+ },
6877
+ },
6878
+ },
6879
+ idle: {
6880
+ on: {
6881
+ BIND_AFFILIATE_CODE: {
6882
+ target: 'binding',
6883
+ actions: ['setBindingCode', 'setUidSite', 'setActivityNo'],
6884
+ },
6885
+ SELECT_LEVEL: {
6886
+ target: 'fetchingList',
6887
+ actions: 'setLevelSearch'
6888
+ }
6889
+ }
6890
+ },
6891
+ binding: {
6892
+ invoke: {
6893
+ src: 'postAffiliate',
6894
+ onDone: {
6895
+ target: 'awarding',
6896
+ },
6897
+ onError: {
6898
+ target: 'fail',
6899
+ },
6900
+ },
6901
+ },
6902
+ awarding: {
6903
+ invoke: {
6904
+ src: 'awardPrize',
6905
+ onDone: {
6906
+ target: 'bound',
6907
+ },
6908
+ onError: {
6909
+ target: 'fail',
6910
+ },
6911
+ },
6912
+ },
6913
+ bound: {
6914
+ after: {
6915
+ 0: {
6916
+ target: 'idle',
6917
+ },
6918
+ },
6919
+ },
6920
+ fetchingList: {
6921
+ invoke: {
6922
+ src: 'fetchLevelDownLineList',
6923
+ onDone: {
6924
+ target: 'idle',
6925
+ actions: 'setLevelDownLineList'
6926
+ },
6927
+ onError: {
6928
+ target: 'idle',
6929
+ },
6930
+ },
6931
+ },
6932
+ fail: {},
6933
+ },
6934
+ },
6935
+ {
6936
+ actions: {
6937
+ setAffiliateCode: assign((context, event) => {
6938
+ const { affiliateCode = '' } = event.data || {};
6939
+ return {
6940
+ affiliateCode
6941
+ }
6942
+ }),
6943
+ setInitialData: assign((context, event) => {
6944
+ const { commission = 0, downLine = 0, activeDownLine = 0 } = event.data[1] || {};
6945
+ const { levelTable = [], pastTable = [] } = event.data[2] || {};
6946
+ return {
6947
+ commission,
6948
+ downLine,
6949
+ activeDownLine,
6950
+ levelTable,
6951
+ pastTable
6952
+ }
6953
+ }),
6954
+ setBindingCode: assign((context, event) => {
6955
+ return {
6956
+ bindingCode: event.data.bindingCode,
6957
+ }
6958
+ }),
6959
+ setActivityNo: assign((context, event) => {
6960
+ return {
6961
+ activityNo: event.data.activityNo,
6962
+ }
6963
+ }),
6964
+ setUidSite: assign((context, event) => {
6965
+ return {
6966
+ uidSite: event.data.uidSite,
6967
+ }
6968
+ }),
6969
+ setLevelSearch: assign((context, event) => {
6970
+ const { level, page } = event.data;
6971
+ console.log('Module:', level, page);
6972
+ return {
6973
+ currentLevel: level,
6974
+ page
6975
+ }
6976
+ }),
6977
+ setLevelDownLineList: assign((context, event) => {
6978
+ return {
6979
+ levelDownLine: event.data
6980
+ }
6981
+ })
6982
+ },
6983
+ guards: {
6984
+ isAffiliateEnable: (context, event) => context.affiliateEnable
6985
+ },
6986
+ services: {
6987
+ fetchAffiliateCode: async () => {
6988
+ return await request.send(user.getAffiliate())
6989
+ },
6990
+ fetchAffiliateData: async (context, event) => {
6991
+ const affiliateHomeAPI = request.send(user.getAffiliateHome());
6992
+ const affiliateDashboard = request.send(user.getAffiliateDashboard());
6993
+ const [affiliateHomeData, affiliateDashboardData] = await Promise.all([affiliateHomeAPI, affiliateDashboard]);
6994
+ return [affiliateHomeData, affiliateDashboardData]
6995
+ },
6996
+ postAffiliate: async (context, event) => {
6997
+ return await request.send(user.postAffiliate({ affiliateCode: context.bindingCode }))
6998
+ },
6999
+ awardPrize: async (context, event) => {
7000
+ const { activityNo, uidSite, bindingCode } = context;
7001
+ const { data } = await request.send(activity$2.sentAward({ activityNo, uidSite, affiliateCode: bindingCode, appSecret }));
7002
+ return data
7003
+ },
7004
+ fetchLevelDownLineList: async (context, event) => {
7005
+ const { currentLevel, page } = context;
7006
+ console.log('API:', currentLevel, page);
7007
+ return await request.send(user.getAffiliateDashboardList({ level: currentLevel, page, row: 10 }))
7008
+ }
7009
+ },
7010
+ }
7011
+ )
7012
+ }
6827
7013
 
6828
7014
  function ranking_activity (request) {
6829
7015
  const { appSecret } = request.config;
@@ -7687,6 +7873,7 @@ var activity = {
7687
7873
  diamond_shop_activity_vn,
7688
7874
  fafafa_activity,
7689
7875
  invite_friends_activity,
7876
+ affiliate_invite_friends_activity,
7690
7877
  ranking_activity,
7691
7878
  return_bonus_activity,
7692
7879
  specify_bets_activity,
@@ -7919,6 +8106,7 @@ function auth (request) {
7919
8106
  userInfo: {},
7920
8107
  redirectURL: null,
7921
8108
  reCaptchaToken: null,
8109
+ affiliate: null
7922
8110
  },
7923
8111
  states: {
7924
8112
  idle: {
@@ -8196,10 +8384,11 @@ function auth (request) {
8196
8384
  return { token }
8197
8385
  }),
8198
8386
  redirectTo3Party: async (context, event) => {
8199
- const { provider, channel, subchannel } = event.data;
8387
+ const { provider, channel, subchannel, affiliate } = event.data;
8200
8388
 
8201
8389
  const dt = await getDeviceToken({ fpToken, sentry, apiURL: request.config.apiURL });
8202
8390
  sentry.setTag('dt', dt);
8391
+
8203
8392
  const messages = {
8204
8393
  url: window.location.href,
8205
8394
  list: [
@@ -8220,8 +8409,10 @@ function auth (request) {
8220
8409
  subchannel: storage.get('subchannel') || subchannel || defaultSubchannel || 'pwa',
8221
8410
  // dt,
8222
8411
  platform: 'pwa',
8412
+ affiliate
8223
8413
  }).toString()
8224
8414
  );
8415
+
8225
8416
  window.location.href = redirectURL;
8226
8417
  },
8227
8418
  setUserInfo: assign((context, event) => {
@@ -12888,7 +13079,8 @@ function reward (request) {
12888
13079
  context: {
12889
13080
  otherRewardList: [],
12890
13081
  pointsRewardList: [],
12891
- callback: () => {},
13082
+ rewardList: [],
13083
+ callback: () => { },
12892
13084
  },
12893
13085
  states: {
12894
13086
  timer: {
@@ -12967,11 +13159,12 @@ function reward (request) {
12967
13159
  return {
12968
13160
  otherRewardList: event.data[0]?.data || [],
12969
13161
  pointsRewardList: event.data[1]?.data || [],
13162
+ rewardList: event.data[2]?.data || [],
12970
13163
  }
12971
13164
  }),
12972
13165
  setCallback: assign((context, event) => {
12973
13166
  return {
12974
- callback: event.data?.callback || (() => {}),
13167
+ callback: event.data?.callback || (() => { }),
12975
13168
  }
12976
13169
  }),
12977
13170
  doCallback: (context, event) => {
@@ -12980,10 +13173,11 @@ function reward (request) {
12980
13173
  },
12981
13174
  services: {
12982
13175
  fetchRewardList: async (context, event) => {
13176
+ const getRewardAPI = request.send(activity$2.getRewardList({ count: 30, appSecret }));
12983
13177
  const getPointsRewardAPI = request.send(activity$2.getRewardList({ rewardType: 'POINTS', count: 30, appSecret }));
12984
13178
  const getOtherRewardAPI = request.send(activity$2.getRewardList({ rewardType: 'CASH,FREE', count: 30, appSecret }));
12985
- const [otherRewardList, pointsRewardList] = await Promise.all([getOtherRewardAPI, getPointsRewardAPI]);
12986
- return [otherRewardList, pointsRewardList]
13179
+ const [otherRewardList, pointsRewardList, rewardList] = await Promise.all([getOtherRewardAPI, getPointsRewardAPI, getRewardAPI]);
13180
+ return [otherRewardList, pointsRewardList, rewardList]
12987
13181
  },
12988
13182
  receiveReward: async (context, event) => {
12989
13183
  const { activityNo, receiveNo, attended } = event.data;
@@ -13449,6 +13643,7 @@ function user_sign_up (request) {
13449
13643
  channel: null,
13450
13644
  subchannel: null,
13451
13645
  signUpData: {},
13646
+ affiliate: null,
13452
13647
  reCaptchaToken: null,
13453
13648
  registrationData: {
13454
13649
  account: null,
@@ -13463,11 +13658,11 @@ function user_sign_up (request) {
13463
13658
  on: {
13464
13659
  SIGN_UP_PHONE: {
13465
13660
  target: 'authentication',
13466
- actions: ['setReCaptchaToken', 'setSignUpPhone'],
13661
+ actions: ['setReCaptchaToken', 'setAffiliate', 'setSignUpPhone'],
13467
13662
  },
13468
13663
  SIGN_UP_EMAIL: {
13469
13664
  target: 'authentication',
13470
- actions: ['setReCaptchaToken', 'setSignUpEmail'],
13665
+ actions: ['setReCaptchaToken', 'setAffiliate', 'setSignUpEmail'],
13471
13666
  },
13472
13667
  },
13473
13668
  },
@@ -13494,6 +13689,12 @@ function user_sign_up (request) {
13494
13689
  reCaptchaToken,
13495
13690
  }
13496
13691
  }),
13692
+ setAffiliate: assign((context, event) => {
13693
+ const { affiliate } = event.data;
13694
+ return {
13695
+ affiliate,
13696
+ }
13697
+ }),
13497
13698
  setSignUpPhone: assign((context, event) => {
13498
13699
  const { countryCode, phone, password, channel, subchannel } = event.data;
13499
13700
  return {
@@ -13555,6 +13756,7 @@ function user_sign_up (request) {
13555
13756
  subchannel: storage.get('subchannel') || defaultSubchannel || subchannel,
13556
13757
  dt,
13557
13758
  reCaptchaToken: context.reCaptchaToken,
13759
+ affiliate: context.affiliate
13558
13760
  })
13559
13761
  )
13560
13762
  },
@@ -16127,7 +16329,10 @@ function deposit_fc (request) {
16127
16329
  },
16128
16330
  },
16129
16331
  checking: {
16130
- always: [{ target: 'debouncing', cond: 'isCalculable' }, { target: 'loaded' }],
16332
+ entry: 'clearCalculatedResult',
16333
+ always: [
16334
+ { target: 'debouncing', cond: 'isCalculable' },
16335
+ { target: 'loaded'}]
16131
16336
  },
16132
16337
  debouncing: {
16133
16338
  after: {
@@ -16252,6 +16457,11 @@ function deposit_fc (request) {
16252
16457
  submittedResult: event.data,
16253
16458
  }
16254
16459
  }),
16460
+ clearCalculatedResult: assign((context, event) => {
16461
+ return {
16462
+ calculatedResult: null,
16463
+ }
16464
+ }),
16255
16465
  toggleBonus: assign((context, event) => {
16256
16466
  const { bonus } = context;
16257
16467
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.0.203",
3
+ "version": "1.0.204",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -58,7 +58,10 @@ export default function (request) {
58
58
  },
59
59
  },
60
60
  checking: {
61
- always: [{ target: 'debouncing', cond: 'isCalculable' }, { target: 'loaded' }],
61
+ entry: 'clearCalculatedResult',
62
+ always: [
63
+ { target: 'debouncing', cond: 'isCalculable' },
64
+ { target: 'loaded'}]
62
65
  },
63
66
  debouncing: {
64
67
  after: {
@@ -183,6 +186,11 @@ export default function (request) {
183
186
  submittedResult: event.data,
184
187
  }
185
188
  }),
189
+ clearCalculatedResult: assign((context, event) => {
190
+ return {
191
+ calculatedResult: null,
192
+ }
193
+ }),
186
194
  toggleBonus: assign((context, event) => {
187
195
  const { bonus } = context
188
196
  return {