@jetthai/cuora 1.1.237 → 1.1.239

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,10 @@
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.239](https://github.com/jetthai/cuora-module/compare/v1.1.238...v1.1.239) (2024-03-29)
6
+
7
+ ### [1.1.238](https://github.com/jetthai/cuora-module/compare/v1.1.237...v1.1.238) (2024-03-28)
8
+
5
9
  ### [1.1.237](https://github.com/jetthai/cuora-module/compare/v1.1.236...v1.1.237) (2024-03-27)
6
10
 
7
11
  ### [1.1.236](https://github.com/jetthai/cuora-module/compare/v1.1.235...v1.1.236) (2024-03-25)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.237",
3
+ "version": "1.1.239",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -134,8 +134,11 @@ export default function (request) {
134
134
  actions: {
135
135
  setInitData: assign((context, event) => {
136
136
  const { siteConfig, paymentDetail } = event.data
137
- const cryptos = paymentDetail.map?.((crypto) => ({ ...crypto, label: crypto.channel, value: crypto.method, icon: crypto.channel })) || []
138
- const currentPayment = cryptos.find((element) => element.category === context.currentCategory)
137
+ const cryptos =
138
+ paymentDetail
139
+ .find((element) => element.category === context.currentCategory)
140
+ .map?.((crypto) => ({ ...crypto, label: crypto.channel, value: crypto.method, icon: crypto.channel })) || []
141
+ const currentPayment = cryptos[0]
139
142
  const channels = cryptos.map((item, i) => ({ ...item, label: `Channel ${padStart(String(i + 1), 2, '0')}`, icon: 'channel' }))
140
143
  const defaultNetworks =
141
144
  cryptos[0].networkName.map((value, i) => {
@@ -11,19 +11,13 @@ export default function (request) {
11
11
  context: {
12
12
  paymentDetails: [],
13
13
 
14
- channels: [],
15
14
  cryptos: [],
16
15
  networks: [],
17
- sourceAddress: '',
18
-
19
- houseBanks: [],
20
- banks: [],
21
16
 
22
17
  amount: null,
23
- selectedHouseBank: null,
24
- selectedChannel: null,
25
18
  selectedCrypto: null,
26
19
  selectedNetwork: null,
20
+ selectedBank: null,
27
21
 
28
22
  currentCategory: 'cryptoBank',
29
23
  currentPayment: null,
@@ -125,10 +119,6 @@ export default function (request) {
125
119
  fail: {},
126
120
  },
127
121
  on: {
128
- SET_CHANNEL: {
129
- target: '.loaded',
130
- actions: 'setChannel',
131
- },
132
122
  SET_CRYPTO: {
133
123
  target: '.loaded',
134
124
  actions: 'setCrypto',
@@ -137,9 +127,6 @@ export default function (request) {
137
127
  target: '.loaded',
138
128
  actions: 'setNetwork',
139
129
  },
140
- SET_ADDRESS: {
141
- actions: 'setAddress',
142
- },
143
130
  SET_AMOUNT: {
144
131
  target: '.loaded',
145
132
  actions: ['setAmount', 'clearCalculation'],
@@ -166,12 +153,13 @@ export default function (request) {
166
153
  event.data
167
154
  .filter((element) => element.category === context.currentCategory)
168
155
  .map?.((crypto) => ({ ...crypto, label: crypto.channel, value: crypto.method, icon: crypto.channel })) || []
169
- const currentPayment = cryptos.find((element) => element.category === context.currentCategory)
170
- const houseBanks = currentPayment.banks?.map((item) => {
171
- item.bankCode = item.bankName
172
- return item
156
+ const currentPayment = cryptos[0].networkName.map((value, i) => {
157
+ return {
158
+ label: cryptos[0].networkOptional?.[i],
159
+ value,
160
+ icon: value,
161
+ }
173
162
  })
174
- const channels = cryptos.map((item, i) => ({ ...item, label: `Channel ${padStart(String(i + 1), 2, '0')}`, icon: 'channel' }))
175
163
  const defaultNetworks =
176
164
  cryptos[0].networkName.map((value, i) => {
177
165
  return {
@@ -180,81 +168,46 @@ export default function (request) {
180
168
  icon: value,
181
169
  }
182
170
  }) || []
183
- const selectedHouseBank = houseBanks.find((element) => element.network === defaultNetworks[0]?.value) || {}
171
+ const selectedBank = (cryptos[0]?.banks || []).find((item) => item.network === defaultNetworks[0].value)
172
+
184
173
  return {
185
- channels,
186
174
  cryptos,
187
175
  networks: defaultNetworks,
188
- selectedChannel: channels[0],
189
176
  selectedCrypto: cryptos[0],
190
177
  selectedNetwork: defaultNetworks[0],
178
+ selectedBank: selectedBank,
179
+ options: cryptos[0].optional,
191
180
  currentPayment,
192
- houseBanks,
193
- selectedHouseBank,
194
181
  processing: currentPayment.processing?.[0],
195
182
  }
196
183
  }),
197
- setChannel: assign((context, event) => {
184
+ setCrypto: assign((context, event) => {
198
185
  const { cryptos } = context
199
186
  const selectedCrypto = cryptos.find((crypto) => crypto.method === event.data.value)
200
- const networks =
201
- selectedCrypto?.networkName.map((value, i) => {
202
- return {
203
- label: selectedCrypto?.networkOptional?.[i],
204
- value,
205
- icon: value,
206
- }
207
- }) || []
187
+ const networks = selectedCrypto?.networkName.map((value, i) => {
188
+ return {
189
+ label: selectedCrypto?.networkOptional?.[i],
190
+ value,
191
+ icon: value,
192
+ }
193
+ })
208
194
  return {
209
195
  networks,
210
- selectedChannel: event.data,
211
196
  selectedCrypto: selectedCrypto,
212
197
  selectedNetwork: networks[0],
213
- amount: null,
198
+ selectedAmount: null,
214
199
  calculation: null,
200
+ options: selectedCrypto.optional,
215
201
  }
216
202
  }),
217
- setCrypto: assign((context, event) => {
218
- const { cryptos, selectedNetwork } = context
219
- const method = cryptos.find((crypto) => crypto.method === event.data.value)
220
- const networks =
221
- method?.networkName.map((value, i) => {
222
- return {
223
- label: method?.networkOptional?.[i],
224
- value,
225
- icon: value,
226
- }
227
- }) || []
228
-
229
- const properties = {
230
- selectedCrypto: event.data,
231
- networks,
232
- }
233
-
234
- if (!networks.includes(selectedNetwork)) {
235
- properties.selectedNetwork = null
236
- properties.amount = null
237
- properties.calculation = null
238
- }
239
-
240
- return properties
241
- }),
242
203
  setNetwork: assign((context, event) => {
243
- const { houseBanks } = context
244
- const currentNetwork = houseBanks.find((element) => element.network === event.data.value) || houseBanks[0]
245
-
246
- return { selectedNetwork: event.data, selectedHouseBank: currentNetwork }
204
+ return { selectedNetwork: event.data }
247
205
  }),
248
206
  setAmount: assign((context, event) => {
249
207
  return {
250
208
  amount: event.data,
251
209
  }
252
210
  }),
253
- setAddress: assign((context, event) => {
254
- return {
255
- sourceAddress: event.data,
256
- }
257
- }),
258
211
  setCalculation: assign((context, event) => {
259
212
  return {
260
213
  calculation: event.data,
@@ -249,8 +249,11 @@ export default function (request) {
249
249
  }),
250
250
  setInitData: assign((context, event) => {
251
251
  const { siteConfig, paymentDetail } = event.data
252
- const cryptos = paymentDetail?.map?.((crypto) => ({ ...crypto, label: crypto.channel, value: crypto.method, icon: crypto.channel })) || []
253
- const currentPayment = cryptos.find((element) => element.category === context.currentCategory)
252
+ const cryptos =
253
+ paymentDetail
254
+ ?.filter((element) => element.category === context.currentCategory)
255
+ ?.map((crypto) => ({ ...crypto, label: crypto.channel, value: crypto.method, icon: crypto.channel })) || []
256
+ const currentPayment = cryptos[0]
254
257
  const channels = cryptos.map((item, i) => ({ ...item, label: `Channel ${padStart(String(i + 1), 2, '0')}`, icon: 'channel' }))
255
258
  const defaultNetworks =
256
259
  cryptos[0].networkName.map((value, i) => {