@jetthai/cuora 1.1.265 → 1.1.267

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.267](https://github.com/jetthai/cuora-module/compare/v1.1.266...v1.1.267) (2024-05-14)
6
+
7
+ ### [1.1.266](https://github.com/jetthai/cuora-module/compare/v1.1.265...v1.1.266) (2024-05-14)
8
+
5
9
  ### [1.1.265](https://github.com/jetthai/cuora-module/compare/v1.1.264...v1.1.265) (2024-05-14)
6
10
 
7
11
  ### [1.1.264](https://github.com/jetthai/cuora-module/compare/v1.1.263...v1.1.264) (2024-05-11)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.265",
3
+ "version": "1.1.267",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -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,9 @@ 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 = '1' } = siteConfig
247
+ return selectedCrypto && selectedAddress && selectedAmount && depositTime && calculation && (receipt || bankDepositProofIsOptional === '0')
246
248
  },
247
249
  },
248
250
  services: {
@@ -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) => {
@@ -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],