@blocklet/launcher-ux 2.3.35 → 2.3.37

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);
@@ -319,7 +324,7 @@ function Component({
319
324
  }), /*#__PURE__*/_jsx(List, {
320
325
  dense: true,
321
326
  disablePadding: true,
322
- children: [{
327
+ children: [state.shouldStake && {
323
328
  label: t('checkout.stakeAmount'),
324
329
  value: state.minStakeAmount,
325
330
  highlight: false
@@ -329,6 +334,9 @@ function Component({
329
334
  hint: t('checkout.estimatedCostHint'),
330
335
  highlight: isFreeTrial
331
336
  }].map(item => {
337
+ if (!item) {
338
+ return null;
339
+ }
332
340
  return /*#__PURE__*/_jsx(ListItem, {
333
341
  disablePadding: true,
334
342
  disableGutters: true,
@@ -391,7 +399,7 @@ function Component({
391
399
  })
392
400
  }, item.label);
393
401
  })
394
- }), /*#__PURE__*/_jsx(Alert, {
402
+ }), state.shouldStake && /*#__PURE__*/_jsx(Alert, {
395
403
  severity: "info",
396
404
  sx: {
397
405
  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);
@@ -335,7 +340,7 @@ function Component(_ref2) {
335
340
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.List, {
336
341
  dense: true,
337
342
  disablePadding: true,
338
- children: [{
343
+ children: [state.shouldStake && {
339
344
  label: t('checkout.stakeAmount'),
340
345
  value: state.minStakeAmount,
341
346
  highlight: false
@@ -345,6 +350,9 @@ function Component(_ref2) {
345
350
  hint: t('checkout.estimatedCostHint'),
346
351
  highlight: isFreeTrial
347
352
  }].map(item => {
353
+ if (!item) {
354
+ return null;
355
+ }
348
356
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.ListItem, {
349
357
  disablePadding: true,
350
358
  disableGutters: true,
@@ -407,7 +415,7 @@ function Component(_ref2) {
407
415
  })
408
416
  }, item.label);
409
417
  })
410
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Alert, {
418
+ }), state.shouldStake && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Alert, {
411
419
  severity: "info",
412
420
  sx: {
413
421
  mt: 2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/launcher-ux",
3
- "version": "2.3.35",
3
+ "version": "2.3.37",
4
4
  "description": "Launcher UX lib",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -46,19 +46,19 @@
46
46
  "devDependencies": {
47
47
  "@babel/cli": "^7.24.8",
48
48
  "@babel/core": "^7.25.2",
49
- "@babel/preset-env": "^7.25.2",
49
+ "@babel/preset-env": "^7.25.3",
50
50
  "@babel/preset-react": "^7.24.7",
51
51
  "@storybook/react": "^6.5.16",
52
52
  "babel-plugin-inline-react-svg": "^2.0.2",
53
53
  "glob": "^10.4.5"
54
54
  },
55
55
  "dependencies": {
56
- "@arcblock/ux": "^2.10.10",
57
- "@blocklet/launcher-util": "2.3.35",
58
- "@blocklet/payment-react": "^1.14.6",
56
+ "@arcblock/ux": "^2.10.12",
57
+ "@blocklet/launcher-util": "2.3.37",
58
+ "@blocklet/payment-react": "^1.14.11",
59
59
  "@emotion/styled": "^11.13.0",
60
- "@mui/icons-material": "^5.16.5",
61
- "@mui/material": "^5.16.5",
60
+ "@mui/icons-material": "^5.16.6",
61
+ "@mui/material": "^5.16.6",
62
62
  "ahooks": "^3.8.0",
63
63
  "pretty-ms-i18n": "^1.0.3",
64
64
  "react-use": "^17.5.1"
@@ -93,5 +93,5 @@
93
93
  "require": "./lib/use-mobile/index.js"
94
94
  }
95
95
  },
96
- "gitHead": "e911a8f6561282c5d6173098d1666725d1e7f1d1"
96
+ "gitHead": "0513d4f7afcaa4a4b87953f17d88d592969d3150"
97
97
  }