@jetthai/cuora 1.1.264 → 1.1.266

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.266](https://github.com/jetthai/cuora-module/compare/v1.1.265...v1.1.266) (2024-05-14)
6
+
7
+ ### [1.1.265](https://github.com/jetthai/cuora-module/compare/v1.1.264...v1.1.265) (2024-05-14)
8
+
5
9
  ### [1.1.264](https://github.com/jetthai/cuora-module/compare/v1.1.263...v1.1.264) (2024-05-11)
6
10
 
7
11
  ### [1.1.263](https://github.com/jetthai/cuora-module/compare/v1.1.262...v1.1.263) (2024-05-10)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.264",
3
+ "version": "1.1.266",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -29,6 +29,7 @@ export default function (request) {
29
29
 
30
30
  depositTime: null,
31
31
  receipt: null,
32
+ proofOptional: false,
32
33
 
33
34
  // use for wallet mode 4
34
35
  promotion: null,
@@ -132,6 +133,9 @@ export default function (request) {
132
133
  target: '.loaded',
133
134
  actions: ['setAmount', 'clearCalculation'],
134
135
  },
136
+ SET_PROOF_OPTIONAL: {
137
+ actions: 'setProofOptional',
138
+ },
135
139
  CALCULATE: {
136
140
  target: '.debouncing',
137
141
  actions: 'clearCalculation',
@@ -242,6 +246,11 @@ export default function (request) {
242
246
  result: event.data,
243
247
  }
244
248
  }),
249
+ setProofOptional: assign((context, event) => {
250
+ return {
251
+ proofOptional: event.data,
252
+ }
253
+ }),
245
254
  setDepositTime: assign((context, event) => {
246
255
  return {
247
256
  depositTime: event.data,
@@ -265,8 +274,8 @@ export default function (request) {
265
274
  return selectedCrypto && selectedAddress && amount && cryptoBank.minimum <= +amount && +amount <= cryptoBank.maximum
266
275
  },
267
276
  isSubmittable: (context, event) => {
268
- const { selectedCrypto, selectedAddress, amount, depositTime, receipt } = context
269
- return selectedCrypto && selectedAddress && amount && depositTime && receipt
277
+ const { selectedCrypto, selectedAddress, amount, depositTime, receipt, proofOptional } = context
278
+ return selectedCrypto && selectedAddress && amount && depositTime && (receipt || proofOptional)
270
279
  },
271
280
  isProcessing: (context, event) => {
272
281
  return context.processing
@@ -3,7 +3,7 @@ import payment from '@jetthai/cuora/src/api/payment.js'
3
3
  import { max } from '../../util/index.js'
4
4
 
5
5
  export default function (request, context) {
6
- const { paymentDetail = [], promotion, selectedAmount } = context || {}
6
+ const { paymentDetail = [], promotion, selectedAmount, siteConfig } = context || {}
7
7
  return createMachine(
8
8
  {
9
9
  id: 'crypto_cash',
@@ -12,6 +12,7 @@ export default function (request, context) {
12
12
  paymentDetail,
13
13
  promotion,
14
14
  selectedAmount,
15
+ siteConfig,
15
16
 
16
17
  cryptos: [],
17
18
  addresses: [],
@@ -241,8 +242,11 @@ export default function (request, context) {
241
242
  return selectedCrypto && selectedAddress && selectedAmount && cryptoBank.minimum <= +selectedAmount && +selectedAmount <= cryptoBank.maximum
242
243
  },
243
244
  isSubmittable: (context, event) => {
244
- const { selectedCrypto, selectedAddress, selectedAmount, depositTime, receipt, calculation } = context
245
- return selectedCrypto && selectedAddress && selectedAmount && depositTime && receipt && calculation
245
+ const { selectedCrypto, selectedAddress, selectedAmount, depositTime, receipt, calculation, siteConfig } = context
246
+ const { bankDepositProofIsOptional = '0' } = siteConfig
247
+ return (
248
+ selectedCrypto && selectedAddress && selectedAmount && depositTime && calculation && (receipt || !(bankDepositProofIsOptional === '1'))
249
+ )
246
250
  },
247
251
  },
248
252
  services: {
@@ -75,19 +75,19 @@ export default function (request) {
75
75
  actions: {
76
76
  setInitData: assign((context, event) => {
77
77
  const paymentDetail = event.data || []
78
- const currentPayment = paymentDetail.find((item) => item.transferType === 'deposit' && item.category === context.currentCategory)
79
- const cryptos = currentPayment?.cryptoOptional?.map((value, i) => {
78
+ const payments = paymentDetail.filter((item) => item.transferType === 'deposit' && item.category === context.currentCategory)
79
+ const cryptos = payments?.map((value, i) => {
80
80
  return {
81
- ...currentPayment,
82
- label: value,
83
- network: currentPayment?.networkName[i],
84
- icon: currentPayment.channel,
81
+ ...value,
82
+ label: value?.cryptoOptional[0],
83
+ network: value?.networkName[0],
84
+ icon: value?.channel,
85
85
  }
86
86
  })
87
87
  return {
88
88
  cryptos,
89
89
  selectedCrypto: cryptos[0],
90
- currentPayment,
90
+ currentPayment: cryptos[0],
91
91
  }
92
92
  }),
93
93
  setCrypto: assign((context, event) => {
@@ -8,7 +8,6 @@ export default function (request) {
8
8
  initial: 'loading',
9
9
  context: {
10
10
  currentCategory: 'cryptoQrcode',
11
- currentPayment: null,
12
11
  cryptos: [],
13
12
  selectedCrypto: null,
14
13
  resultMap: {},
@@ -69,20 +68,18 @@ export default function (request) {
69
68
  actions: {
70
69
  setInitData: assign((context, event) => {
71
70
  const paymentDetail = event.data || []
72
- const currentPayment = paymentDetail.find((item) => item.category === context.currentCategory)
73
- const cryptos = currentPayment?.cryptoOptional?.map((value, i) => {
74
- return {
75
- ...currentPayment,
76
- label: value,
77
- network: currentPayment?.networkName[i],
78
- icon: currentPayment.channel,
79
- }
80
- })
71
+ const payments = paymentDetail.filter((item) => item.category === context.currentCategory)
72
+ const cryptos = payments.map((payment) => ({
73
+ ...payment,
74
+ label: payment.cryptoOptional?.[0],
75
+ network: payment.networkName?.[0],
76
+ value: payment.method,
77
+ icon: payment.channel,
78
+ }))
81
79
 
82
80
  return {
83
81
  cryptos,
84
82
  selectedCrypto: cryptos[0],
85
- currentPayment,
86
83
  }
87
84
  }),
88
85
  setCrypto: assign((context, event) => {
@@ -122,19 +122,19 @@ export default function (request) {
122
122
  {
123
123
  actions: {
124
124
  setPayment: assign((context, event) => {
125
- const currentPayment = event.data.find((item) => item.category === context.currentCategory)
126
- const cryptos = currentPayment?.cryptoOptional?.map((value, i) => {
125
+ const payments = event.data.filter((item) => item.category === context.currentCategory)
126
+ const cryptos = payments?.map((value, i) => {
127
127
  return {
128
- ...currentPayment,
129
- label: value,
130
- network: currentPayment?.networkName[i],
131
- icon: currentPayment.channel,
128
+ ...value,
129
+ label: value?.cryptoOptional[0],
130
+ network: value?.networkName[0],
131
+ icon: value?.channel,
132
132
  }
133
133
  })
134
134
  return {
135
135
  cryptos,
136
136
  selectedCrypto: cryptos[0],
137
- currentPayment,
137
+ currentPayment: cryptos[0],
138
138
  }
139
139
  }),
140
140
  setCrypto: assign((context, event) => {
@@ -180,12 +180,8 @@ export default function (request) {
180
180
  },
181
181
  guards: {
182
182
  isCalculable: (context, event) => {
183
- const {
184
- selectedCrypto,
185
- amount,
186
- currentPayment: { maximum, minimum },
187
- } = context
188
- return selectedCrypto && amount && minimum <= +amount && +amount <= maximum
183
+ const { selectedCrypto, amount } = context
184
+ return selectedCrypto && amount && selectedCrypto?.minimum <= +amount && +amount <= selectedCrypto?.maximum
189
185
  },
190
186
  isSubmittable: (context, event) => {
191
187
  const { selectedCrypto, amount } = context
@@ -124,15 +124,15 @@ export default function (request, context) {
124
124
  actions: {
125
125
  setInitData: assign((context, event) => {
126
126
  const { paymentDetail } = context
127
- const currentPayment = paymentDetail.find((item) => item.transferType === 'deposit' && item.category === context.currentCategory)
128
- const cryptos = currentPayment?.cryptoOptional?.map((value, i) => {
129
- return {
130
- ...currentPayment,
131
- label: value,
132
- network: currentPayment?.networkName[i],
133
- icon: currentPayment.channel,
134
- }
135
- })
127
+ const payments = paymentDetail.filter((item) => item.category === context.currentCategory)
128
+ const cryptos = payments.map((payment) => ({
129
+ ...payment,
130
+ label: payment.cryptoOptional?.[0],
131
+ network: payment.networkName?.[0],
132
+ value: payment.method,
133
+ icon: payment.channel,
134
+ }))
135
+
136
136
  return {
137
137
  cryptos,
138
138
  selectedCrypto: cryptos[0],