@jetthai/cuora 1.1.252 → 1.1.253

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,8 @@
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.253](https://github.com/jetthai/cuora-module/compare/v1.1.252...v1.1.253) (2024-05-02)
6
+
5
7
  ### [1.1.252](https://github.com/jetthai/cuora-module/compare/v1.1.251...v1.1.252) (2024-04-17)
6
8
 
7
9
  ### [1.1.251](https://github.com/jetthai/cuora-module/compare/v1.1.250...v1.1.251) (2024-04-17)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.1.252",
3
+ "version": "1.1.253",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "type": "module",
@@ -10,6 +10,7 @@ export default function (request) {
10
10
  paymentDetails: [],
11
11
  currentCategory: 'cryptoQrcode',
12
12
  currentPayment: null,
13
+ cryptos: [],
13
14
  networks: [],
14
15
  selectedCrypto: null,
15
16
  selectedNetwork: null,
@@ -28,10 +29,10 @@ export default function (request) {
28
29
  states: {
29
30
  loading: {
30
31
  invoke: {
31
- src: 'fetchPayments',
32
+ src: 'fetchPaymentDetail',
32
33
  onDone: {
33
34
  target: 'fetching',
34
- actions: 'setPayment',
35
+ actions: 'setInitData',
35
36
  },
36
37
  onError: {
37
38
  target: 'fail',
@@ -66,6 +67,10 @@ export default function (request) {
66
67
  fail: {},
67
68
  },
68
69
  on: {
70
+ SET_CRYPTO: {
71
+ target: '.finding',
72
+ actions: 'setCrypto',
73
+ },
69
74
  SET_NETWORK: {
70
75
  target: '.finding',
71
76
  actions: 'setNetwork',
@@ -74,26 +79,42 @@ export default function (request) {
74
79
  },
75
80
  {
76
81
  actions: {
77
- setPayment: assign((context, event) => {
78
- const cryptos =
79
- event.data
80
- .filter((element) => element.category === context.currentCategory)
81
- .map?.((crypto) => ({ ...crypto, label: crypto.channel, value: crypto.method, icon: crypto.channel })) || []
82
- const currentPayment = event.data.find((element) => element.category === context.currentCategory)
83
- const defaultNetworks =
84
- currentPayment.networkName.map((value, i) => {
82
+ setInitData: assign((context, event) => {
83
+ const paymentDetail = event.data || []
84
+ const payments = paymentDetail.filter((item) => item.category === context.currentCategory)
85
+ const currentPayment = payments[0]
86
+ const cryptos = payments.map((payment) => ({ ...payment, label: payment.channel, value: payment.method, icon: payment.channel }))
87
+ const networks = currentPayment?.networkName.map((value, i) => {
88
+ return {
89
+ label: currentPayment.networkOptional?.[i],
90
+ value,
91
+ icon: value,
92
+ }
93
+ })
94
+
95
+ return {
96
+ cryptos,
97
+ networks,
98
+ selectedCrypto: cryptos[0],
99
+ selectedNetwork: networks[0],
100
+ currentPayment,
101
+ }
102
+ }),
103
+ setCrypto: assign((context, event) => {
104
+ const { cryptos } = context
105
+ const selectedCrypto = cryptos.find((crypto) => crypto.channel === event.data.channel)
106
+ const networks =
107
+ selectedCrypto?.networkName.map((value, i) => {
85
108
  return {
86
- label: currentPayment.networkOptional?.[i],
109
+ label: selectedCrypto?.networkOptional?.[i],
87
110
  value,
88
111
  icon: value,
89
112
  }
90
113
  }) || []
91
-
92
114
  return {
93
- networks: defaultNetworks,
94
- selectedNetwork: defaultNetworks[0],
95
- currentPayment,
96
- selectedCrypto: cryptos[0],
115
+ networks,
116
+ selectedCrypto,
117
+ selectedNetwork: networks[0],
97
118
  }
98
119
  }),
99
120
  setNetwork: assign((context, event) => {
@@ -132,7 +153,7 @@ export default function (request) {
132
153
  },
133
154
  },
134
155
  services: {
135
- fetchPayments: async (context, event) => {
156
+ fetchPaymentDetail: async (context, event) => {
136
157
  return await request.send(payment.getPaymentDetail({ transferType: 'DEPOSIT' }))
137
158
  },
138
159
  submitDeposit: async (context, event) => {
@@ -12,13 +12,11 @@ export default function (request) {
12
12
  context: {
13
13
  paymentDetails: [],
14
14
 
15
- channels: [],
16
15
  cryptos: [],
17
16
  networks: [],
18
17
  sourceAddress: '',
19
18
 
20
19
  amount: null,
21
- selectedChannel: null,
22
20
  selectedCrypto: null,
23
21
  selectedNetwork: null,
24
22
 
@@ -103,10 +101,6 @@ export default function (request) {
103
101
  fail: {},
104
102
  },
105
103
  on: {
106
- SET_CHANNEL: {
107
- target: '.loaded',
108
- actions: 'setChannel',
109
- },
110
104
  SET_CRYPTO: {
111
105
  target: '.loaded',
112
106
  actions: 'setCrypto',
@@ -139,7 +133,6 @@ export default function (request) {
139
133
  .filter((element) => element.category === context.currentCategory)
140
134
  .map?.((crypto) => ({ ...crypto, label: crypto.channel, value: crypto.method, icon: crypto.channel })) || []
141
135
  const currentPayment = cryptos.find((element) => element.category === context.currentCategory)
142
- const channels = cryptos.map((item, i) => ({ ...item, label: `Channel ${padStart(String(i + 1), 2, '0')}`, icon: 'channel' }))
143
136
  const defaultNetworks =
144
137
  cryptos[0].networkName.map((value, i) => {
145
138
  return {
@@ -149,35 +142,13 @@ export default function (request) {
149
142
  }
150
143
  }) || []
151
144
  return {
152
- channels,
153
145
  cryptos,
154
146
  networks: defaultNetworks,
155
- selectedChannel: channels[0],
156
147
  selectedCrypto: cryptos[0],
157
148
  selectedNetwork: defaultNetworks[0],
158
149
  currentPayment,
159
150
  }
160
151
  }),
161
- setChannel: assign((context, event) => {
162
- const { cryptos } = context
163
- const selectedCrypto = cryptos.find((crypto) => crypto.method === event.data.value)
164
- const networks =
165
- selectedCrypto?.networkName.map((value, i) => {
166
- return {
167
- label: selectedCrypto?.networkOptional?.[i],
168
- value,
169
- icon: value,
170
- }
171
- }) || []
172
- return {
173
- networks,
174
- selectedChannel: event.data,
175
- selectedCrypto: selectedCrypto,
176
- selectedNetwork: networks[0],
177
- amount: null,
178
- calculation: null,
179
- }
180
- }),
181
152
  setCrypto: assign((context, event) => {
182
153
  const { cryptos, selectedNetwork } = context
183
154
  const method = cryptos.find((crypto) => crypto.method === event.data.value)