@blocklet/launcher-ux 2.3.36 → 2.3.38

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.
@@ -89,12 +89,14 @@ function Component({
89
89
  minStakeAmount
90
90
  }) {
91
91
  const {
92
- getCurrency
92
+ getCurrency,
93
+ getMethod
93
94
  } = usePaymentContext();
94
95
  const [state, setState] = useSetState({
95
96
  unitPrice: '',
96
97
  totalPrice: '',
97
- minStakeAmount: ''
98
+ minStakeAmount: '',
99
+ shouldStake: true
98
100
  });
99
101
  const {
100
102
  isMobile
@@ -145,7 +147,8 @@ function Component({
145
147
  price
146
148
  } = checkoutState.value;
147
149
  const handleChange = ({
148
- payment_currency: currencyId
150
+ payment_currency: currencyId,
151
+ payment_method: paymentMethodId
149
152
  } = {}) => {
150
153
  try {
151
154
  const currency = getCurrency(currencyId);
@@ -154,10 +157,12 @@ function Component({
154
157
  totalPrice = totalPrice?.replace(new RegExp(`${UNIT_LABEL_PLACEHOLDER}\\s+\\/*`), '');
155
158
  let unitPrice = formatPrice(price, currency, UNIT_LABEL_PLACEHOLDER, 1, true, locale);
156
159
  unitPrice = unitPrice?.replace(new RegExp(`${UNIT_LABEL_PLACEHOLDER}\\s+\\/*`), '');
160
+ const paymentMethod = getMethod(paymentMethodId);
157
161
  setState({
158
162
  unitPrice,
159
163
  totalPrice,
160
- minStakeAmount: `${minStakeAmount} ${currency.symbol}`
164
+ minStakeAmount: `${minStakeAmount} ${currency.symbol}`,
165
+ shouldStake: paymentMethod?.type === 'arcblock'
161
166
  });
162
167
  } catch (error) {
163
168
  console.error('calculate failed error', error);
@@ -181,7 +186,8 @@ function Component({
181
186
  duration: prettyMs(freeTrialDurationSeconds * 1000, {
182
187
  locale: locale === 'zh' ? 'zh_CN' : 'en_US',
183
188
  compact: true,
184
- verbose: false
189
+ verbose: true,
190
+ unitCount: 1
185
191
  })
186
192
  }),
187
193
  color: "success",
@@ -319,7 +325,7 @@ function Component({
319
325
  }), /*#__PURE__*/_jsx(List, {
320
326
  dense: true,
321
327
  disablePadding: true,
322
- children: [{
328
+ children: [state.shouldStake && {
323
329
  label: t('checkout.stakeAmount'),
324
330
  value: state.minStakeAmount,
325
331
  highlight: false
@@ -329,6 +335,9 @@ function Component({
329
335
  hint: t('checkout.estimatedCostHint'),
330
336
  highlight: isFreeTrial
331
337
  }].map(item => {
338
+ if (!item) {
339
+ return null;
340
+ }
332
341
  return /*#__PURE__*/_jsx(ListItem, {
333
342
  disablePadding: true,
334
343
  disableGutters: true,
@@ -391,7 +400,7 @@ function Component({
391
400
  })
392
401
  }, item.label);
393
402
  })
394
- }), /*#__PURE__*/_jsx(Alert, {
403
+ }), state.shouldStake && /*#__PURE__*/_jsx(Alert, {
395
404
  severity: "info",
396
405
  sx: {
397
406
  mt: 2,
@@ -102,12 +102,14 @@ function Component(_ref2) {
102
102
  minStakeAmount
103
103
  } = _ref2;
104
104
  const {
105
- getCurrency
105
+ getCurrency,
106
+ getMethod
106
107
  } = (0, _paymentReact.usePaymentContext)();
107
108
  const [state, setState] = (0, _ahooks.useSetState)({
108
109
  unitPrice: '',
109
110
  totalPrice: '',
110
- minStakeAmount: ''
111
+ minStakeAmount: '',
112
+ shouldStake: true
111
113
  });
112
114
  const {
113
115
  isMobile
@@ -159,7 +161,8 @@ function Component(_ref2) {
159
161
  } = checkoutState.value;
160
162
  const handleChange = function handleChange() {
161
163
  let {
162
- payment_currency: currencyId
164
+ payment_currency: currencyId,
165
+ payment_method: paymentMethodId
163
166
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
164
167
  try {
165
168
  var _totalPrice, _unitPrice;
@@ -169,10 +172,12 @@ function Component(_ref2) {
169
172
  totalPrice = (_totalPrice = totalPrice) === null || _totalPrice === void 0 ? void 0 : _totalPrice.replace(new RegExp("".concat(UNIT_LABEL_PLACEHOLDER, "\\s+\\/*")), '');
170
173
  let unitPrice = (0, _paymentReact.formatPrice)(price, currency, UNIT_LABEL_PLACEHOLDER, 1, true, locale);
171
174
  unitPrice = (_unitPrice = unitPrice) === null || _unitPrice === void 0 ? void 0 : _unitPrice.replace(new RegExp("".concat(UNIT_LABEL_PLACEHOLDER, "\\s+\\/*")), '');
175
+ const paymentMethod = getMethod(paymentMethodId);
172
176
  setState({
173
177
  unitPrice,
174
178
  totalPrice,
175
- minStakeAmount: "".concat(minStakeAmount, " ").concat(currency.symbol)
179
+ minStakeAmount: "".concat(minStakeAmount, " ").concat(currency.symbol),
180
+ shouldStake: (paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.type) === 'arcblock'
176
181
  });
177
182
  } catch (error) {
178
183
  console.error('calculate failed error', error);
@@ -196,7 +201,8 @@ function Component(_ref2) {
196
201
  duration: (0, _prettyMsI18n.default)(freeTrialDurationSeconds * 1000, {
197
202
  locale: locale === 'zh' ? 'zh_CN' : 'en_US',
198
203
  compact: true,
199
- verbose: false
204
+ verbose: true,
205
+ unitCount: 1
200
206
  })
201
207
  }),
202
208
  color: "success",
@@ -335,7 +341,7 @@ function Component(_ref2) {
335
341
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.List, {
336
342
  dense: true,
337
343
  disablePadding: true,
338
- children: [{
344
+ children: [state.shouldStake && {
339
345
  label: t('checkout.stakeAmount'),
340
346
  value: state.minStakeAmount,
341
347
  highlight: false
@@ -345,6 +351,9 @@ function Component(_ref2) {
345
351
  hint: t('checkout.estimatedCostHint'),
346
352
  highlight: isFreeTrial
347
353
  }].map(item => {
354
+ if (!item) {
355
+ return null;
356
+ }
348
357
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItem, {
349
358
  disablePadding: true,
350
359
  disableGutters: true,
@@ -407,7 +416,7 @@ function Component(_ref2) {
407
416
  })
408
417
  }, item.label);
409
418
  })
410
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Alert, {
419
+ }), state.shouldStake && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Alert, {
411
420
  severity: "info",
412
421
  sx: {
413
422
  mt: 2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/launcher-ux",
3
- "version": "2.3.36",
3
+ "version": "2.3.38",
4
4
  "description": "Launcher UX lib",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -54,8 +54,8 @@
54
54
  },
55
55
  "dependencies": {
56
56
  "@arcblock/ux": "^2.10.12",
57
- "@blocklet/launcher-util": "2.3.36",
58
- "@blocklet/payment-react": "^1.14.8",
57
+ "@blocklet/launcher-util": "2.3.38",
58
+ "@blocklet/payment-react": "^1.14.11",
59
59
  "@emotion/styled": "^11.13.0",
60
60
  "@mui/icons-material": "^5.16.6",
61
61
  "@mui/material": "^5.16.6",
@@ -93,5 +93,5 @@
93
93
  "require": "./lib/use-mobile/index.js"
94
94
  }
95
95
  },
96
- "gitHead": "55fe474e79787d4314b3e6be089e9aef5036e58b"
96
+ "gitHead": "e0bc571eb6b0c54e0180312515b85663d90e06f8"
97
97
  }