@jetthai/cuora 1.1.46 → 1.1.48-1

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,16 @@
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.48-1](https://github.com/jetthai/cuora-module/compare/v1.1.48...v1.1.48-1) (2023-02-17)
6
+
7
+ ### [1.1.48-1](https://github.com/jetthai/cuora-module/compare/v1.1.48...v1.1.48-1) (2023-02-17)
8
+
9
+ ### [1.1.48](https://github.com/jetthai/cuora-module/compare/v1.1.47...v1.1.48) (2023-02-10)
10
+
11
+ ### [1.1.47](https://github.com/jetthai/cuora-module/compare/v1.1.45-1...v1.1.47) (2023-02-08)
12
+
13
+ ### [1.1.35-roulette](https://github.com/jetthai/cuora-module/compare/v1.1.45...v1.1.35-roulette) (2023-02-07)
14
+
5
15
  ### [1.1.46](https://github.com/jetthai/cuora-module/compare/v1.1.35-roulette...v1.1.46) (2023-02-07)
6
16
 
7
17
  ### [1.1.44](https://github.com/jetthai/cuora-module/compare/v1.1.43...v1.1.44) (2023-01-20)
@@ -26,6 +36,8 @@ All notable changes to this project will be documented in this file. See [standa
26
36
 
27
37
  ### [1.1.36](https://github.com/jetthai/cuora-module/compare/v1.1.35...v1.1.36) (2023-01-12)
28
38
 
39
+ ### [1.1.45-1](https://github.com/jetthai/cuora-module/compare/v1.1.45...v1.1.45-1) (2023-02-08)
40
+
29
41
  ### [1.1.45](https://github.com/jetthai/cuora-module/compare/v1.1.44...v1.1.45) (2023-02-03)
30
42
 
31
43
  ### [1.1.44](https://github.com/jetthai/cuora-module/compare/v1.1.43...v1.1.44) (2023-01-20)
package/dist/bundle.mjs CHANGED
@@ -11408,7 +11408,7 @@ function game_v2 (request) {
11408
11408
  lang: 'en_US',
11409
11409
  isMobile: new UAParser().getResult().device.type,
11410
11410
  gameURL: null,
11411
- ...oldContext,
11411
+ ...oldContext$1,
11412
11412
  },
11413
11413
  states: {
11414
11414
  flow: {
@@ -11640,12 +11640,419 @@ function game_v2 (request) {
11640
11640
  const lang = event.data.locale.replace('-', '_');
11641
11641
  return { lang }
11642
11642
  }),
11643
- ...oldActions,
11643
+ ...oldActions$1,
11644
11644
  },
11645
11645
  guards: {
11646
11646
  isDifferentRoom: (context, event) => context.room?.categoryId !== event.data?.categoryId,
11647
11647
  hasNext: (context, event) => context.index < context?.content?.totalPage - 1,
11648
11648
  hasRoom: (context, event) => context.room?.categoryId,
11649
+ ...oldGuards$1,
11650
+ },
11651
+ services: {
11652
+ getPageContent: async (context, event) => {
11653
+ const { room, index } = context;
11654
+ if (room.categoryId === GAME_SEARCH) {
11655
+ return
11656
+ } else {
11657
+ const param = { categoryId: room.categoryId, index };
11658
+ return await Promise.all([request.send(game$1.getListCategory(param)), request.send(game$1.getListAddition(param))])
11659
+ }
11660
+ },
11661
+ updatePageContent: async (context, event) => {
11662
+ const { room, content, index } = context;
11663
+ if (room.categoryId === GAME_SEARCH) {
11664
+ return
11665
+ } else {
11666
+ return await Promise.all([
11667
+ request.send(
11668
+ game$1.getListCategoryByRange({
11669
+ categoryId: room.categoryId,
11670
+ end: index,
11671
+ timestamp: content.timestamp,
11672
+ })
11673
+ ),
11674
+ request.send(
11675
+ game$1.getListAdditionByRange({
11676
+ categoryId: room.categoryId,
11677
+ end: index,
11678
+ timestamp: content.timestamp,
11679
+ })
11680
+ ),
11681
+ ])
11682
+ }
11683
+ },
11684
+ connectGame: async (context, event) => {
11685
+ const { lang, isMobile } = context;
11686
+ const { providerId, gameId, gameTypeId, mappingId } = context.game;
11687
+ const params = {
11688
+ provider_id: providerId,
11689
+ game_id: gameId,
11690
+ gametype_id: gameTypeId,
11691
+ mapping_id: mappingId,
11692
+ is_demo: false,
11693
+ is_mobile: isMobile,
11694
+ lang,
11695
+ return_url: window.location.href,
11696
+ };
11697
+ const { redirect_url } = await request.send(game$1.playGame(params));
11698
+ return { gameURL: redirect_url }
11699
+ },
11700
+ disconnectGame: async (context, event) => {
11701
+ const uid_site = event.data;
11702
+ const provider_id = context.game.providerId;
11703
+ return await request.send(game$1.logoutGame({ uid_site, provider_id }))
11704
+ },
11705
+ ...oldServices$1(request),
11706
+ },
11707
+ }
11708
+ )
11709
+ }
11710
+
11711
+ const oldContext$1 = {
11712
+ sha: {
11713
+ status: null,
11714
+ },
11715
+ isStatusChanged: false,
11716
+ statusMap: {},
11717
+ optionMap: {},
11718
+ };
11719
+
11720
+ const oldActions$1 = {
11721
+ setGameSHA: assign((context, event) => {
11722
+ const { sha } = context;
11723
+ const newSha = event.data;
11724
+ return {
11725
+ sha: newSha,
11726
+ isStatusChanged: !sha.status || sha.status !== newSha.status,
11727
+ }
11728
+ }),
11729
+ setStatus: assign((context, event) => {
11730
+ return {
11731
+ statusMap: event.data,
11732
+ }
11733
+ }),
11734
+ mergeOption: assign((context, event) => {
11735
+ const { optionMap } = context;
11736
+ return {
11737
+ optionMap: { ...optionMap, ...event.data },
11738
+ }
11739
+ }),
11740
+ };
11741
+
11742
+ const oldGuards$1 = {
11743
+ isStatusChanged: (context, event) => context.isStatusChanged,
11744
+ };
11745
+
11746
+ const oldServices$1 = (request) => ({
11747
+ fetchOption: async (context, event) => {
11748
+ return await request.send(game$1.getOptionMap())
11749
+ },
11750
+ fetchGameSHA: async (context, event) => {
11751
+ return await request.send(game$1.getGameSHA())
11752
+ },
11753
+ fetchStatus: async (context, event) => {
11754
+ return await request.send(game$1.getGameStatus())
11755
+ },
11756
+ });
11757
+
11758
+ // 對應 intersectionObserver 版本
11759
+ function game_v2_1 (request) {
11760
+ return createMachine(
11761
+ {
11762
+ id: 'game',
11763
+ type: 'parallel',
11764
+ context: {
11765
+ loadable: false,
11766
+ isLastPage: false,
11767
+ room: null,
11768
+ index: -1,
11769
+ content: {
11770
+ data: [],
11771
+ timestamp: null,
11772
+ parentCategoryId: null,
11773
+ totalPage: 0,
11774
+ },
11775
+ addition: {
11776
+ data: [],
11777
+ timestamp: null,
11778
+ totalPage: 0,
11779
+ },
11780
+ // play params
11781
+ game: {
11782
+ providerId: null,
11783
+ gameId: null,
11784
+ gameTypeId: null,
11785
+ mappingId: null,
11786
+ portrait: null,
11787
+ },
11788
+ lang: 'en_US',
11789
+ isMobile: new UAParser().getResult().device.type,
11790
+ gameURL: null,
11791
+ ...oldContext,
11792
+ },
11793
+ states: {
11794
+ flow: {
11795
+ initial: 'idle',
11796
+ states: {
11797
+ idle: {
11798
+ enter: 'clearGameInfo',
11799
+ on: {
11800
+ LOAD: {
11801
+ target: 'routing',
11802
+ actions: 'setLoadable',
11803
+ },
11804
+ SET_ROOM: {
11805
+ cond: 'isDifferentRoom',
11806
+ actions: ['setRoom', 'resetContent'],
11807
+ },
11808
+ ENTER_GAME: {
11809
+ target: 'connecting',
11810
+ actions: ['setGameInfo', 'setLang'],
11811
+ },
11812
+ },
11813
+ },
11814
+ loading: {
11815
+ entry: 'increaseIndex',
11816
+ invoke: {
11817
+ src: 'getPageContent',
11818
+ onDone: {
11819
+ target: 'routing',
11820
+ actions: ['appendContent', 'setLastPage'],
11821
+ },
11822
+ onError: {
11823
+ target: 'idle',
11824
+ },
11825
+ },
11826
+ on: {
11827
+ LOAD: { actions: 'setLoadable' },
11828
+ },
11829
+ },
11830
+ routing: {
11831
+ always: [
11832
+ {
11833
+ target: 'loading',
11834
+ cond: 'hasNext',
11835
+ },
11836
+ { target: 'idle' },
11837
+ ],
11838
+ },
11839
+ connecting: {
11840
+ invoke: {
11841
+ src: 'connectGame',
11842
+ onDone: {
11843
+ target: 'playing',
11844
+ actions: 'setGameURL',
11845
+ },
11846
+ onError: {
11847
+ target: 'idle',
11848
+ },
11849
+ },
11850
+ },
11851
+ playing: {
11852
+ on: {
11853
+ EXIT_GAME: {
11854
+ target: 'disconnect',
11855
+ },
11856
+ },
11857
+ },
11858
+ disconnect: {
11859
+ invoke: {
11860
+ src: 'disconnectGame',
11861
+ onDone: {
11862
+ target: 'idle',
11863
+ },
11864
+ onError: {
11865
+ target: 'idle',
11866
+ },
11867
+ },
11868
+ },
11869
+ },
11870
+ },
11871
+ timer: {
11872
+ initial: 'pending',
11873
+ states: {
11874
+ pending: {
11875
+ after: {
11876
+ 20000: [
11877
+ {
11878
+ target: 'updating',
11879
+ cond: 'hasRoom',
11880
+ },
11881
+ {
11882
+ target: 'pending',
11883
+ },
11884
+ ],
11885
+ },
11886
+ },
11887
+ updating: {
11888
+ invoke: {
11889
+ src: 'updatePageContent',
11890
+ onDone: {
11891
+ target: 'pending',
11892
+ actions: 'swapContent',
11893
+ },
11894
+ onError: {
11895
+ target: 'pending',
11896
+ },
11897
+ },
11898
+ },
11899
+ },
11900
+ },
11901
+ oldTimer: {
11902
+ initial: 'fetchingGameSHA',
11903
+ states: {
11904
+ fetchingGameSHA: {
11905
+ invoke: {
11906
+ src: 'fetchGameSHA',
11907
+ onDone: {
11908
+ target: 'checking',
11909
+ actions: 'setGameSHA',
11910
+ },
11911
+ onError: {
11912
+ target: 'pending',
11913
+ },
11914
+ },
11915
+ },
11916
+ checking: {
11917
+ always: [{ target: 'updatingStatus', cond: 'isStatusChanged' }, { target: 'pending' }],
11918
+ },
11919
+ updatingStatus: {
11920
+ invoke: {
11921
+ src: 'fetchStatus',
11922
+ onDone: {
11923
+ target: 'updatingOption',
11924
+ actions: ['setStatus'],
11925
+ },
11926
+ onError: {
11927
+ target: 'pending',
11928
+ },
11929
+ },
11930
+ },
11931
+ updatingOption: {
11932
+ invoke: {
11933
+ src: 'fetchOption',
11934
+ onDone: {
11935
+ target: 'pending',
11936
+ actions: 'mergeOption',
11937
+ },
11938
+ onError: {
11939
+ target: 'pending',
11940
+ },
11941
+ },
11942
+ },
11943
+ pending: {
11944
+ after: {
11945
+ 20000: {
11946
+ target: 'fetchingGameSHA',
11947
+ },
11948
+ },
11949
+ },
11950
+ },
11951
+ },
11952
+ },
11953
+ },
11954
+ {
11955
+ actions: {
11956
+ setLoadable: assign((context, event) => {
11957
+ return {
11958
+ loadable: event.data,
11959
+ }
11960
+ }),
11961
+ setLastPage: assign((context, event) => {
11962
+ const { index, content } = context;
11963
+ return {
11964
+ isLastPage: index >= content?.totalPage - 1,
11965
+ }
11966
+ }),
11967
+ setFavoriteList: assign((context, event) => {
11968
+ return {
11969
+ favoriteList: event.data.data || [],
11970
+ }
11971
+ }),
11972
+ setRoom: assign((context, event) => {
11973
+ return {
11974
+ room: event.data,
11975
+ }
11976
+ }),
11977
+ resetContent: assign((context, event) => {
11978
+ return {
11979
+ loadable: false,
11980
+ isLastPage: false,
11981
+ index: -1,
11982
+ content: {
11983
+ data: [],
11984
+ timestamp: null,
11985
+ parentCategoryId: null,
11986
+ totalPage: 0,
11987
+ },
11988
+ addition: {
11989
+ data: [],
11990
+ timestamp: null,
11991
+ totalPage: 0,
11992
+ },
11993
+ }
11994
+ }),
11995
+ appendContent: assign((context, event) => {
11996
+ const { room, favoriteList } = context;
11997
+ if (room.categoryId === GAME_SEARCH) {
11998
+ return
11999
+ } else {
12000
+ const [content, addition] = event.data;
12001
+ return {
12002
+ content: {
12003
+ ...context.content,
12004
+ ...content,
12005
+ data: context.content.data.concat(content.data),
12006
+ },
12007
+ addition: {
12008
+ ...context.addition,
12009
+ ...addition,
12010
+ data: context.addition.data.concat(addition.data),
12011
+ },
12012
+ }
12013
+ }
12014
+ }),
12015
+ swapContent: assign((context, event) => {
12016
+ const [content, addition] = event.data;
12017
+ let result = {};
12018
+ if (content?.data?.length) {
12019
+ result.content = content;
12020
+ }
12021
+ if (addition?.data?.length) {
12022
+ result.addition = addition;
12023
+ }
12024
+ return result
12025
+ }),
12026
+ increaseIndex: assign((context, event) => {
12027
+ return {
12028
+ index: context.index + 1,
12029
+ }
12030
+ }),
12031
+ setGameURL: assign({
12032
+ gameURL: (context, event) => {
12033
+ return event.data.gameURL
12034
+ },
12035
+ }),
12036
+ clearGameInfo: assign((context, event) => {
12037
+ return { game: { providerId: null, gameId: null, gameTypeId: null, mappingId: null } }
12038
+ }),
12039
+ setGameInfo: assign((context, event) => {
12040
+ const { providerId, gameId, gameTypeId, mappingId, portrait } = event.data.game;
12041
+ return { game: { providerId, gameId, gameTypeId, mappingId, portrait: portrait ? 1 : 0 } }
12042
+ }),
12043
+ setLang: assign((context, event) => {
12044
+ const lang = event.data.locale.replace('-', '_');
12045
+ return { lang }
12046
+ }),
12047
+ ...oldActions,
12048
+ },
12049
+ guards: {
12050
+ isDifferentRoom: (context, event) => context.room?.categoryId !== event.data?.categoryId,
12051
+ hasNext: (context, event) => {
12052
+ const { loadable, isLastPage } = context;
12053
+ return loadable && !isLastPage
12054
+ },
12055
+ hasRoom: (context, event) => context.room?.categoryId,
11649
12056
  ...oldGuards,
11650
12057
  },
11651
12058
  services: {
@@ -14960,6 +15367,7 @@ function withdraw_vn (request) {
14960
15367
  maximumWithdrawAmount: 0,
14961
15368
  enableWithdrawAmount: 0,
14962
15369
  enableWithdraw: false,
15370
+ withdrawRules: [],
14963
15371
 
14964
15372
  amount: null,
14965
15373
  bank: null,
@@ -14967,9 +15375,6 @@ function withdraw_vn (request) {
14967
15375
  accountNumber: null,
14968
15376
  holderName: null,
14969
15377
 
14970
- withdrawDistance: null,
14971
- withdrawAmount: null,
14972
-
14973
15378
  // otp
14974
15379
  requestId: null,
14975
15380
  status: null,
@@ -15449,6 +15854,7 @@ function withdraw_crypto (request) {
15449
15854
  maxWithdrawAmount: null,
15450
15855
  availableWithdrawAmount: null,
15451
15856
  enableWithdraw: false,
15857
+ withdrawRules: [],
15452
15858
 
15453
15859
  attachmentType: null, // null | 'withdraw' | 'pool'
15454
15860
 
@@ -15771,13 +16177,28 @@ function withdraw_crypto (request) {
15771
16177
  const { differAmountLimit, enableWithdraw, enableWithdrawAmount, maxWithdrawStatus, maximumWithdrawAmount, minimumWithdrawAmount } =
15772
16178
  event.data?.withdrawRule;
15773
16179
 
16180
+ const withdrawRules = event.data?.withdrawRule?.rules || [];
16181
+ const rules = withdrawRules.filter((rule) => rule.maxWithdrawAmount > 0);
16182
+
16183
+ const { balance } = context;
16184
+ const lastMatchedIndex = findLastIndex_1(rules, (rule) => balance >= rule.greaterEqualThen);
16185
+
16186
+ let maxWithdrawAmount = 0;
16187
+
16188
+ if (lastMatchedIndex > -1) {
16189
+ rules[lastMatchedIndex].match = true;
16190
+ maxWithdrawAmount = rules[lastMatchedIndex].maxWithdrawAmount;
16191
+ } else if (rules.length > 0) {
16192
+ maxWithdrawAmount = rules[0].maxWithdrawAmount;
16193
+ } else {
16194
+ maxWithdrawAmount = balance;
16195
+ }
16196
+
15774
16197
  return {
15775
- // maxWithdrawAmount: maximumWithdrawAmount,
15776
- // availableWithdrawAmount: enableWithdrawAmount,
15777
- maximumWithdrawAmount: +maximumWithdrawAmount,
16198
+ maxWithdrawAmount,
15778
16199
  enableWithdrawAmount: +enableWithdrawAmount,
15779
- amount: +enableWithdrawAmount,
15780
16200
  enableWithdraw,
16201
+ withdrawRules,
15781
16202
  }
15782
16203
 
15783
16204
  // const rules = event.data.rules.filter((rule) => rule.maxWithdrawAmount > 0)
@@ -17166,6 +17587,7 @@ function qrcode_v2 (request) {
17166
17587
  },
17167
17588
  ],
17168
17589
  KEY_IN: {
17590
+ target: 'pending',
17169
17591
  actions: 'setAmount',
17170
17592
  },
17171
17593
  },
@@ -21021,6 +21443,7 @@ var index$1 = {
21021
21443
  setting,
21022
21444
  side,
21023
21445
  side_v2,
21446
+ game_v2_1,
21024
21447
  user_info,
21025
21448
  user_sign_up,
21026
21449
  user_reset_password,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.46",
3
+ "version": "1.1.48-1",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -74,6 +74,7 @@ export default function (request) {
74
74
  },
75
75
  ],
76
76
  KEY_IN: {
77
+ target: 'pending',
77
78
  actions: 'setAmount',
78
79
  },
79
80
  },
@@ -0,0 +1,411 @@
1
+ import { assign, createMachine } from 'xstate'
2
+ import api from '../api/game.js'
3
+ import UAParser from 'ua-parser-js'
4
+ import { GAME_SEARCH } from '../util/constant.js'
5
+
6
+ // 對應 intersectionObserver 版本
7
+ export default function (request) {
8
+ return createMachine(
9
+ {
10
+ id: 'game',
11
+ type: 'parallel',
12
+ context: {
13
+ loadable: false,
14
+ isLastPage: false,
15
+ room: null,
16
+ index: -1,
17
+ content: {
18
+ data: [],
19
+ timestamp: null,
20
+ parentCategoryId: null,
21
+ totalPage: 0,
22
+ },
23
+ addition: {
24
+ data: [],
25
+ timestamp: null,
26
+ totalPage: 0,
27
+ },
28
+ // play params
29
+ game: {
30
+ providerId: null,
31
+ gameId: null,
32
+ gameTypeId: null,
33
+ mappingId: null,
34
+ portrait: null,
35
+ },
36
+ lang: 'en_US',
37
+ isMobile: new UAParser().getResult().device.type,
38
+ gameURL: null,
39
+ ...oldContext,
40
+ },
41
+ states: {
42
+ flow: {
43
+ initial: 'idle',
44
+ states: {
45
+ idle: {
46
+ enter: 'clearGameInfo',
47
+ on: {
48
+ LOAD: {
49
+ target: 'routing',
50
+ actions: 'setLoadable',
51
+ },
52
+ SET_ROOM: {
53
+ cond: 'isDifferentRoom',
54
+ actions: ['setRoom', 'resetContent'],
55
+ },
56
+ ENTER_GAME: {
57
+ target: 'connecting',
58
+ actions: ['setGameInfo', 'setLang'],
59
+ },
60
+ },
61
+ },
62
+ loading: {
63
+ entry: 'increaseIndex',
64
+ invoke: {
65
+ src: 'getPageContent',
66
+ onDone: {
67
+ target: 'routing',
68
+ actions: ['appendContent', 'setLastPage'],
69
+ },
70
+ onError: {
71
+ target: 'idle',
72
+ },
73
+ },
74
+ on: {
75
+ LOAD: { actions: 'setLoadable' },
76
+ },
77
+ },
78
+ routing: {
79
+ always: [
80
+ {
81
+ target: 'loading',
82
+ cond: 'hasNext',
83
+ },
84
+ { target: 'idle' },
85
+ ],
86
+ },
87
+ connecting: {
88
+ invoke: {
89
+ src: 'connectGame',
90
+ onDone: {
91
+ target: 'playing',
92
+ actions: 'setGameURL',
93
+ },
94
+ onError: {
95
+ target: 'idle',
96
+ },
97
+ },
98
+ },
99
+ playing: {
100
+ on: {
101
+ EXIT_GAME: {
102
+ target: 'disconnect',
103
+ },
104
+ },
105
+ },
106
+ disconnect: {
107
+ invoke: {
108
+ src: 'disconnectGame',
109
+ onDone: {
110
+ target: 'idle',
111
+ },
112
+ onError: {
113
+ target: 'idle',
114
+ },
115
+ },
116
+ },
117
+ },
118
+ },
119
+ timer: {
120
+ initial: 'pending',
121
+ states: {
122
+ pending: {
123
+ after: {
124
+ 20000: [
125
+ {
126
+ target: 'updating',
127
+ cond: 'hasRoom',
128
+ },
129
+ {
130
+ target: 'pending',
131
+ },
132
+ ],
133
+ },
134
+ },
135
+ updating: {
136
+ invoke: {
137
+ src: 'updatePageContent',
138
+ onDone: {
139
+ target: 'pending',
140
+ actions: 'swapContent',
141
+ },
142
+ onError: {
143
+ target: 'pending',
144
+ },
145
+ },
146
+ },
147
+ },
148
+ },
149
+ oldTimer: {
150
+ initial: 'fetchingGameSHA',
151
+ states: {
152
+ fetchingGameSHA: {
153
+ invoke: {
154
+ src: 'fetchGameSHA',
155
+ onDone: {
156
+ target: 'checking',
157
+ actions: 'setGameSHA',
158
+ },
159
+ onError: {
160
+ target: 'pending',
161
+ },
162
+ },
163
+ },
164
+ checking: {
165
+ always: [{ target: 'updatingStatus', cond: 'isStatusChanged' }, { target: 'pending' }],
166
+ },
167
+ updatingStatus: {
168
+ invoke: {
169
+ src: 'fetchStatus',
170
+ onDone: {
171
+ target: 'updatingOption',
172
+ actions: ['setStatus'],
173
+ },
174
+ onError: {
175
+ target: 'pending',
176
+ },
177
+ },
178
+ },
179
+ updatingOption: {
180
+ invoke: {
181
+ src: 'fetchOption',
182
+ onDone: {
183
+ target: 'pending',
184
+ actions: 'mergeOption',
185
+ },
186
+ onError: {
187
+ target: 'pending',
188
+ },
189
+ },
190
+ },
191
+ pending: {
192
+ after: {
193
+ 20000: {
194
+ target: 'fetchingGameSHA',
195
+ },
196
+ },
197
+ },
198
+ },
199
+ },
200
+ },
201
+ },
202
+ {
203
+ actions: {
204
+ setLoadable: assign((context, event) => {
205
+ return {
206
+ loadable: event.data,
207
+ }
208
+ }),
209
+ setLastPage: assign((context, event) => {
210
+ const { index, content } = context
211
+ return {
212
+ isLastPage: index >= content?.totalPage - 1,
213
+ }
214
+ }),
215
+ setFavoriteList: assign((context, event) => {
216
+ return {
217
+ favoriteList: event.data.data || [],
218
+ }
219
+ }),
220
+ setRoom: assign((context, event) => {
221
+ return {
222
+ room: event.data,
223
+ }
224
+ }),
225
+ resetContent: assign((context, event) => {
226
+ return {
227
+ loadable: false,
228
+ isLastPage: false,
229
+ index: -1,
230
+ content: {
231
+ data: [],
232
+ timestamp: null,
233
+ parentCategoryId: null,
234
+ totalPage: 0,
235
+ },
236
+ addition: {
237
+ data: [],
238
+ timestamp: null,
239
+ totalPage: 0,
240
+ },
241
+ }
242
+ }),
243
+ appendContent: assign((context, event) => {
244
+ const { room, favoriteList } = context
245
+ if (room.categoryId === GAME_SEARCH) {
246
+ return
247
+ } else {
248
+ const [content, addition] = event.data
249
+ return {
250
+ content: {
251
+ ...context.content,
252
+ ...content,
253
+ data: context.content.data.concat(content.data),
254
+ },
255
+ addition: {
256
+ ...context.addition,
257
+ ...addition,
258
+ data: context.addition.data.concat(addition.data),
259
+ },
260
+ }
261
+ }
262
+ }),
263
+ swapContent: assign((context, event) => {
264
+ const [content, addition] = event.data
265
+ let result = {}
266
+ if (content?.data?.length) {
267
+ result.content = content
268
+ }
269
+ if (addition?.data?.length) {
270
+ result.addition = addition
271
+ }
272
+ return result
273
+ }),
274
+ increaseIndex: assign((context, event) => {
275
+ return {
276
+ index: context.index + 1,
277
+ }
278
+ }),
279
+ setGameURL: assign({
280
+ gameURL: (context, event) => {
281
+ return event.data.gameURL
282
+ },
283
+ }),
284
+ clearGameInfo: assign((context, event) => {
285
+ return { game: { providerId: null, gameId: null, gameTypeId: null, mappingId: null } }
286
+ }),
287
+ setGameInfo: assign((context, event) => {
288
+ const { providerId, gameId, gameTypeId, mappingId, portrait } = event.data.game
289
+ return { game: { providerId, gameId, gameTypeId, mappingId, portrait: portrait ? 1 : 0 } }
290
+ }),
291
+ setLang: assign((context, event) => {
292
+ const lang = event.data.locale.replace('-', '_')
293
+ return { lang }
294
+ }),
295
+ ...oldActions,
296
+ },
297
+ guards: {
298
+ isDifferentRoom: (context, event) => context.room?.categoryId !== event.data?.categoryId,
299
+ hasNext: (context, event) => {
300
+ const { loadable, isLastPage } = context
301
+ return loadable && !isLastPage
302
+ },
303
+ hasRoom: (context, event) => context.room?.categoryId,
304
+ ...oldGuards,
305
+ },
306
+ services: {
307
+ getPageContent: async (context, event) => {
308
+ const { room, index } = context
309
+ if (room.categoryId === GAME_SEARCH) {
310
+ return
311
+ } else {
312
+ const param = { categoryId: room.categoryId, index }
313
+ return await Promise.all([request.send(api.getListCategory(param)), request.send(api.getListAddition(param))])
314
+ }
315
+ },
316
+ updatePageContent: async (context, event) => {
317
+ const { room, content, index } = context
318
+ if (room.categoryId === GAME_SEARCH) {
319
+ return
320
+ } else {
321
+ return await Promise.all([
322
+ request.send(
323
+ api.getListCategoryByRange({
324
+ categoryId: room.categoryId,
325
+ end: index,
326
+ timestamp: content.timestamp,
327
+ })
328
+ ),
329
+ request.send(
330
+ api.getListAdditionByRange({
331
+ categoryId: room.categoryId,
332
+ end: index,
333
+ timestamp: content.timestamp,
334
+ })
335
+ ),
336
+ ])
337
+ }
338
+ },
339
+ connectGame: async (context, event) => {
340
+ const { lang, isMobile } = context
341
+ const { providerId, gameId, gameTypeId, mappingId } = context.game
342
+ const params = {
343
+ provider_id: providerId,
344
+ game_id: gameId,
345
+ gametype_id: gameTypeId,
346
+ mapping_id: mappingId,
347
+ is_demo: false,
348
+ is_mobile: isMobile,
349
+ lang,
350
+ return_url: window.location.href,
351
+ }
352
+ const { redirect_url } = await request.send(api.playGame(params))
353
+ return { gameURL: redirect_url }
354
+ },
355
+ disconnectGame: async (context, event) => {
356
+ const uid_site = event.data
357
+ const provider_id = context.game.providerId
358
+ return await request.send(api.logoutGame({ uid_site, provider_id }))
359
+ },
360
+ ...oldServices(request),
361
+ },
362
+ }
363
+ )
364
+ }
365
+
366
+ const oldContext = {
367
+ sha: {
368
+ status: null,
369
+ },
370
+ isStatusChanged: false,
371
+ statusMap: {},
372
+ optionMap: {},
373
+ }
374
+
375
+ const oldActions = {
376
+ setGameSHA: assign((context, event) => {
377
+ const { sha } = context
378
+ const newSha = event.data
379
+ return {
380
+ sha: newSha,
381
+ isStatusChanged: !sha.status || sha.status !== newSha.status,
382
+ }
383
+ }),
384
+ setStatus: assign((context, event) => {
385
+ return {
386
+ statusMap: event.data,
387
+ }
388
+ }),
389
+ mergeOption: assign((context, event) => {
390
+ const { optionMap } = context
391
+ return {
392
+ optionMap: { ...optionMap, ...event.data },
393
+ }
394
+ }),
395
+ }
396
+
397
+ const oldGuards = {
398
+ isStatusChanged: (context, event) => context.isStatusChanged,
399
+ }
400
+
401
+ const oldServices = (request) => ({
402
+ fetchOption: async (context, event) => {
403
+ return await request.send(api.getOptionMap())
404
+ },
405
+ fetchGameSHA: async (context, event) => {
406
+ return await request.send(api.getGameSHA())
407
+ },
408
+ fetchStatus: async (context, event) => {
409
+ return await request.send(api.getGameStatus())
410
+ },
411
+ })
@@ -5,6 +5,7 @@ import common from './common.js'
5
5
  import error from './error.js'
6
6
  import game from './game.js'
7
7
  import game_v2 from './game_v2.js'
8
+ import game_v2_1 from './game_v2_1.js'
8
9
  import game_favorite from './game_favorite.js'
9
10
  import game_favorite_v2 from './game_favorite_v2.js'
10
11
  import game_search from './game_search.js'
@@ -58,6 +59,7 @@ export default {
58
59
  setting,
59
60
  side,
60
61
  side_v2,
62
+ game_v2_1,
61
63
  user_info,
62
64
  user_sign_up,
63
65
  user_reset_password,
@@ -25,6 +25,7 @@ export default function (request) {
25
25
  maxWithdrawAmount: null,
26
26
  availableWithdrawAmount: null,
27
27
  enableWithdraw: false,
28
+ withdrawRules: [],
28
29
 
29
30
  attachmentType: null, // null | 'withdraw' | 'pool'
30
31
 
@@ -347,13 +348,28 @@ export default function (request) {
347
348
  const { differAmountLimit, enableWithdraw, enableWithdrawAmount, maxWithdrawStatus, maximumWithdrawAmount, minimumWithdrawAmount } =
348
349
  event.data?.withdrawRule
349
350
 
351
+ const withdrawRules = event.data?.withdrawRule?.rules || []
352
+ const rules = withdrawRules.filter((rule) => rule.maxWithdrawAmount > 0)
353
+
354
+ const { balance } = context
355
+ const lastMatchedIndex = findLastIndex(rules, (rule) => balance >= rule.greaterEqualThen)
356
+
357
+ let maxWithdrawAmount = 0
358
+
359
+ if (lastMatchedIndex > -1) {
360
+ rules[lastMatchedIndex].match = true
361
+ maxWithdrawAmount = rules[lastMatchedIndex].maxWithdrawAmount
362
+ } else if (rules.length > 0) {
363
+ maxWithdrawAmount = rules[0].maxWithdrawAmount
364
+ } else {
365
+ maxWithdrawAmount = balance
366
+ }
367
+
350
368
  return {
351
- // maxWithdrawAmount: maximumWithdrawAmount,
352
- // availableWithdrawAmount: enableWithdrawAmount,
353
- maximumWithdrawAmount: +maximumWithdrawAmount,
369
+ maxWithdrawAmount,
354
370
  enableWithdrawAmount: +enableWithdrawAmount,
355
- amount: +enableWithdrawAmount,
356
371
  enableWithdraw,
372
+ withdrawRules,
357
373
  }
358
374
 
359
375
  // const rules = event.data.rules.filter((rule) => rule.maxWithdrawAmount > 0)
@@ -27,6 +27,7 @@ export default function (request) {
27
27
  maximumWithdrawAmount: 0,
28
28
  enableWithdrawAmount: 0,
29
29
  enableWithdraw: false,
30
+ withdrawRules: [],
30
31
 
31
32
  amount: null,
32
33
  bank: null,
@@ -34,9 +35,6 @@ export default function (request) {
34
35
  accountNumber: null,
35
36
  holderName: null,
36
37
 
37
- withdrawDistance: null,
38
- withdrawAmount: null,
39
-
40
38
  // otp
41
39
  requestId: null,
42
40
  status: null,