@jetthai/cuora 1.0.143 → 1.0.144-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.0.144-1](https://github.com/jetthai/cuora-module/compare/v1.0.144...v1.0.144-1) (2022-07-18)
|
|
6
|
+
|
|
7
|
+
### [1.0.144](https://github.com/jetthai/cuora-module/compare/v1.0.140-2...v1.0.144) (2022-07-17)
|
|
8
|
+
|
|
9
|
+
### [1.0.143](https://github.com/jetthai/cuora-module/compare/v1.0.141...v1.0.143) (2022-07-14)
|
|
10
|
+
|
|
11
|
+
### [1.0.141](https://github.com/jetthai/cuora-module/compare/v1.0.140-1...v1.0.141) (2022-07-05)
|
|
12
|
+
|
|
13
|
+
### [1.0.140-1](https://github.com/jetthai/cuora-module/compare/v1.0.140...v1.0.140-1) (2022-07-04)
|
|
14
|
+
|
|
5
15
|
### [1.0.143](https://github.com/jetthai/cuora-module/compare/v1.0.141...v1.0.143) (2022-07-14)
|
|
6
16
|
|
|
7
17
|
### [1.0.142](https://github.com/jetthai/cuora-module/compare/v1.0.141...v1.0.142) (2022-07-14)
|
package/package.json
CHANGED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import payment from '../../api/payment'
|
|
3
|
+
|
|
4
|
+
export default function (request) {
|
|
5
|
+
return createMachine(
|
|
6
|
+
{
|
|
7
|
+
id: 'direct',
|
|
8
|
+
initial: 'loading',
|
|
9
|
+
context: {
|
|
10
|
+
paymentDetails: [],
|
|
11
|
+
directs: [],
|
|
12
|
+
currentDirect: null,
|
|
13
|
+
banks: [],
|
|
14
|
+
selectedBank: null,
|
|
15
|
+
calculation: null,
|
|
16
|
+
currentCategory: 'direct',
|
|
17
|
+
currentMethod: null,
|
|
18
|
+
amount: null,
|
|
19
|
+
result: null
|
|
20
|
+
},
|
|
21
|
+
states: {
|
|
22
|
+
loading: {
|
|
23
|
+
initial: 'step1',
|
|
24
|
+
states: {
|
|
25
|
+
step1: {
|
|
26
|
+
invoke: {
|
|
27
|
+
src: 'fetchInitData',
|
|
28
|
+
onDone: {
|
|
29
|
+
target: 'step2',
|
|
30
|
+
actions: 'setInitData',
|
|
31
|
+
},
|
|
32
|
+
onError: {
|
|
33
|
+
target: '#direct.fail',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
step2: {
|
|
38
|
+
invoke: {
|
|
39
|
+
src: 'fetchBanksList',
|
|
40
|
+
onDone: {
|
|
41
|
+
target: '#direct.loaded',
|
|
42
|
+
actions: 'setBanks',
|
|
43
|
+
},
|
|
44
|
+
onError: {
|
|
45
|
+
target: '#direct.fail',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
loaded: {
|
|
52
|
+
on: {
|
|
53
|
+
SELECT_DIRECT: {
|
|
54
|
+
actions: ['setDirect', 'reset']
|
|
55
|
+
},
|
|
56
|
+
SELECT_BANK: {
|
|
57
|
+
actions: 'setSelectedBank',
|
|
58
|
+
},
|
|
59
|
+
SET_AMOUNT: {
|
|
60
|
+
actions: ['setAmount', 'clearCalculation'],
|
|
61
|
+
},
|
|
62
|
+
CLEAR_CALCULATION: {
|
|
63
|
+
actions: 'clearCalculation',
|
|
64
|
+
},
|
|
65
|
+
CALCULATE: {
|
|
66
|
+
target: 'calculating',
|
|
67
|
+
cond: 'isCalculable',
|
|
68
|
+
},
|
|
69
|
+
SUBMIT: {
|
|
70
|
+
target: 'submitting',
|
|
71
|
+
cond: 'isSubmittable',
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
calculating: {
|
|
76
|
+
invoke: {
|
|
77
|
+
src: 'fetchCalculation',
|
|
78
|
+
onDone: {
|
|
79
|
+
target: 'loaded',
|
|
80
|
+
actions: 'setCalculation',
|
|
81
|
+
},
|
|
82
|
+
onError: {
|
|
83
|
+
target: 'loaded',
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
submitting: {
|
|
88
|
+
invoke: {
|
|
89
|
+
src: 'submitDeposit',
|
|
90
|
+
onDone: {
|
|
91
|
+
target: 'submitted',
|
|
92
|
+
actions: 'setResult',
|
|
93
|
+
},
|
|
94
|
+
onError: {
|
|
95
|
+
target: 'loaded',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
submitted: {},
|
|
100
|
+
fail: {},
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
actions: {
|
|
105
|
+
reset: assign((context, event) => {
|
|
106
|
+
const { banks } = context
|
|
107
|
+
return {
|
|
108
|
+
amount: null,
|
|
109
|
+
selectedBank: banks[0],
|
|
110
|
+
calculation: null,
|
|
111
|
+
}
|
|
112
|
+
}),
|
|
113
|
+
setInitData: assign((context, event) => {
|
|
114
|
+
const paymentDetails = event.data
|
|
115
|
+
const directs = paymentDetails.filter((element) => element.category === context.currentCategory)
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
paymentDetails,
|
|
119
|
+
directs,
|
|
120
|
+
currentDirect: directs[0],
|
|
121
|
+
currentMethod: directs[0]?.method,
|
|
122
|
+
}
|
|
123
|
+
}),
|
|
124
|
+
setBanks: assign((context, event) => {
|
|
125
|
+
const banks = event.data
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
banks,
|
|
129
|
+
selectedBank: banks[0],
|
|
130
|
+
}
|
|
131
|
+
}),
|
|
132
|
+
setDirect: assign((context, event) => {
|
|
133
|
+
return {
|
|
134
|
+
currentDirect: event.data,
|
|
135
|
+
currentMethod: event.data.method,
|
|
136
|
+
}
|
|
137
|
+
}),
|
|
138
|
+
setSelectedBank: assign((context, event) => {
|
|
139
|
+
return {
|
|
140
|
+
selectedBank: event.data,
|
|
141
|
+
}
|
|
142
|
+
}),
|
|
143
|
+
setAmount: assign((context, event) => {
|
|
144
|
+
return {
|
|
145
|
+
amount: event.data
|
|
146
|
+
}
|
|
147
|
+
}),
|
|
148
|
+
setCalculation: assign((context, event) => {
|
|
149
|
+
return {
|
|
150
|
+
calculation: event.data,
|
|
151
|
+
}
|
|
152
|
+
}),
|
|
153
|
+
clearCalculation: assign((context, event) => {
|
|
154
|
+
return {
|
|
155
|
+
calculation: null,
|
|
156
|
+
}
|
|
157
|
+
}),
|
|
158
|
+
setResult: assign((context, event) => {
|
|
159
|
+
return {
|
|
160
|
+
result: event.data,
|
|
161
|
+
}
|
|
162
|
+
}),
|
|
163
|
+
},
|
|
164
|
+
guards: {
|
|
165
|
+
isCalculable: (context, event) => {
|
|
166
|
+
const {
|
|
167
|
+
amount,
|
|
168
|
+
currentDirect: { maximum, minimum },
|
|
169
|
+
} = context
|
|
170
|
+
|
|
171
|
+
return amount && minimum <= +amount && +amount <= maximum
|
|
172
|
+
},
|
|
173
|
+
isSubmittable: (context, event) => {
|
|
174
|
+
const { amount, currentMethod, selectedBank } = context
|
|
175
|
+
return amount && currentMethod && selectedBank?.bankCode
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
services: {
|
|
179
|
+
fetchInitData: async (context, event) => {
|
|
180
|
+
return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
|
|
181
|
+
},
|
|
182
|
+
fetchBanksList: async (context, event) => {
|
|
183
|
+
const { paymentDetails } = context
|
|
184
|
+
const method = paymentDetails.find((item) => item.category === 'manual')?.method
|
|
185
|
+
return await request.send(payment.getBankList(method))
|
|
186
|
+
},
|
|
187
|
+
fetchCalculation: async (context, event) => {
|
|
188
|
+
const { currentMethod, amount } = context
|
|
189
|
+
|
|
190
|
+
return await request.send(
|
|
191
|
+
payment.getDepositExpectedResult({
|
|
192
|
+
method: currentMethod,
|
|
193
|
+
amount,
|
|
194
|
+
})
|
|
195
|
+
)
|
|
196
|
+
},
|
|
197
|
+
submitDeposit: async (context, event) => {
|
|
198
|
+
const { currentMethod, amount, selectedBank } = context
|
|
199
|
+
return await request.send(
|
|
200
|
+
payment.submitDepositTransactionBank({
|
|
201
|
+
method: currentMethod,
|
|
202
|
+
amount,
|
|
203
|
+
applyerBankCode: selectedBank.bankCode
|
|
204
|
+
})
|
|
205
|
+
)
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
}
|
|
209
|
+
)
|
|
210
|
+
}
|
|
@@ -4,5 +4,6 @@ import qrcode_vn from './qrcode_vn'
|
|
|
4
4
|
import qrcode_v2 from './qrcode_v2'
|
|
5
5
|
import deposit_fc from './deposit_fc'
|
|
6
6
|
import crypto from './crypto'
|
|
7
|
+
import direct from './direct'
|
|
7
8
|
|
|
8
|
-
export default { manual_vn, loadcard_vn, qrcode_vn, qrcode_v2, deposit_fc, crypto }
|
|
9
|
+
export default { manual_vn, loadcard_vn, qrcode_vn, qrcode_v2, deposit_fc, crypto, direct }
|
|
@@ -194,6 +194,7 @@ export default function (request) {
|
|
|
194
194
|
}
|
|
195
195
|
}),
|
|
196
196
|
setBanks: assign((context, event) => {
|
|
197
|
+
const banks = event.data
|
|
197
198
|
const { playerBanks, houseBanks, selectedHouseBank } = context
|
|
198
199
|
|
|
199
200
|
const formattedPlayerBanks = playerBanks.map((bank) => {
|
|
@@ -202,7 +203,7 @@ export default function (request) {
|
|
|
202
203
|
return bank
|
|
203
204
|
})
|
|
204
205
|
|
|
205
|
-
const
|
|
206
|
+
const userBanks = [...formattedPlayerBanks, ...banks]
|
|
206
207
|
|
|
207
208
|
const newHouseBanks = houseBanks.map((houseBank) => {
|
|
208
209
|
return { ...houseBank, ...banks.find((bank) => houseBank.bankName === bank.bankCode) }
|
|
@@ -211,12 +212,12 @@ export default function (request) {
|
|
|
211
212
|
const newSelectedHouseBank = { ...selectedHouseBank, ...banks.find((bank) => selectedHouseBank.bankName === bank.bankCode) }
|
|
212
213
|
|
|
213
214
|
return {
|
|
214
|
-
banks,
|
|
215
|
+
banks: userBanks,
|
|
215
216
|
houseBanks: newHouseBanks,
|
|
216
217
|
selectedHouseBank: newSelectedHouseBank,
|
|
217
|
-
selectedUserBank:
|
|
218
|
-
userAccountNumber:
|
|
219
|
-
userAccountName:
|
|
218
|
+
selectedUserBank: userBanks[0],
|
|
219
|
+
userAccountNumber: userBanks[0].accountNumber,
|
|
220
|
+
userAccountName: userBanks[0].holderName,
|
|
220
221
|
}
|
|
221
222
|
}),
|
|
222
223
|
setHouseBank: assign((context, event) => {
|