@blocklet/launcher-ux 2.3.49 → 2.3.51

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.
@@ -93,6 +93,10 @@ function Component({
93
93
  minStakeAmount,
94
94
  isResume
95
95
  }) {
96
+ const theme = useTheme();
97
+ const {
98
+ isMobile
99
+ } = useMobile();
96
100
  const {
97
101
  getCurrency,
98
102
  getMethod
@@ -101,16 +105,9 @@ function Component({
101
105
  unitPrice: '',
102
106
  totalPrice: '',
103
107
  minStakeAmount: '',
104
- shouldStake: true
108
+ shouldStake: true,
109
+ freeTrial: null
105
110
  });
106
- const {
107
- isMobile
108
- } = useMobile();
109
- const theme = useTheme();
110
- const {
111
- isFreeTrial,
112
- duration: freeTrialDurationSeconds
113
- } = getProductFreeTrial('serverless', freeTrialProducts);
114
111
  const minimumWidth = useMediaQuery(theme.breakpoints.down(540));
115
112
  const components = (tempComponents || []).reduce((acc, x) => {
116
113
  if (acc.findIndex(y => y.did === x.did) === -1) {
@@ -164,11 +161,17 @@ function Component({
164
161
  let unitPrice = formatPrice(price, currency, UNIT_LABEL_PLACEHOLDER, 1, true, locale);
165
162
  unitPrice = unitPrice?.replace(new RegExp(`${UNIT_LABEL_PLACEHOLDER}\\s+\\/*`), '');
166
163
  const paymentMethod = getMethod(paymentMethodId);
164
+ const freeTrial = getProductFreeTrial({
165
+ typeName: 'serverless',
166
+ freeTrialProducts,
167
+ currencyId: currency.id
168
+ });
167
169
  setState({
168
170
  unitPrice,
169
171
  totalPrice,
170
172
  minStakeAmount: `${minStakeAmount} ${currency.symbol}`,
171
- shouldStake: paymentMethod?.type === 'arcblock'
173
+ shouldStake: paymentMethod?.type === 'arcblock',
174
+ freeTrial
172
175
  });
173
176
  } catch (error) {
174
177
  console.error('calculate failed error', error);
@@ -181,7 +184,7 @@ function Component({
181
184
  width: '100%',
182
185
  height: '100%'
183
186
  },
184
- children: [isFreeTrial && /*#__PURE__*/_jsx(Box, {
187
+ children: [state.freeTrial && /*#__PURE__*/_jsx(Box, {
185
188
  sx: {
186
189
  display: 'flex',
187
190
  justifyContent: 'flex-start'
@@ -189,7 +192,7 @@ function Component({
189
192
  children: /*#__PURE__*/_jsx(Chip, {
190
193
  icon: /*#__PURE__*/_jsx(RocketLaunchIcon, {}),
191
194
  label: t('checkout.freeTrialHint', {
192
- duration: prettyMs(freeTrialDurationSeconds * 1000, {
195
+ duration: prettyMs(state.freeTrial.duration * 1000, {
193
196
  locale: locale === 'zh' ? 'zh_CN' : 'en_US',
194
197
  compact: true,
195
198
  verbose: true,
@@ -336,10 +339,10 @@ function Component({
336
339
  value: state.minStakeAmount,
337
340
  highlight: false
338
341
  }, {
339
- label: isFreeTrial ? t('checkout.estimatedCostFreeTrial') : t('checkout.estimatedCost'),
342
+ label: state.isFreeTrial ? t('checkout.estimatedCostFreeTrial') : t('checkout.estimatedCost'),
340
343
  value: state.totalPrice,
341
344
  hint: t('checkout.estimatedCostHint'),
342
- highlight: isFreeTrial
345
+ highlight: state.isFreeTrial
343
346
  }].map(item => {
344
347
  if (!item) {
345
348
  return null;
@@ -106,6 +106,10 @@ function Component(_ref2) {
106
106
  minStakeAmount,
107
107
  isResume
108
108
  } = _ref2;
109
+ const theme = (0, _styles.useTheme)();
110
+ const {
111
+ isMobile
112
+ } = (0, _useMobile.default)();
109
113
  const {
110
114
  getCurrency,
111
115
  getMethod
@@ -114,16 +118,9 @@ function Component(_ref2) {
114
118
  unitPrice: '',
115
119
  totalPrice: '',
116
120
  minStakeAmount: '',
117
- shouldStake: true
121
+ shouldStake: true,
122
+ freeTrial: null
118
123
  });
119
- const {
120
- isMobile
121
- } = (0, _useMobile.default)();
122
- const theme = (0, _styles.useTheme)();
123
- const {
124
- isFreeTrial,
125
- duration: freeTrialDurationSeconds
126
- } = (0, _util.getProductFreeTrial)('serverless', freeTrialProducts);
127
124
  const minimumWidth = (0, _useMediaQuery.default)(theme.breakpoints.down(540));
128
125
  const components = (tempComponents || []).reduce((acc, x) => {
129
126
  if (acc.findIndex(y => y.did === x.did) === -1) {
@@ -179,11 +176,17 @@ function Component(_ref2) {
179
176
  let unitPrice = (0, _paymentReact.formatPrice)(price, currency, UNIT_LABEL_PLACEHOLDER, 1, true, locale);
180
177
  unitPrice = (_unitPrice = unitPrice) === null || _unitPrice === void 0 ? void 0 : _unitPrice.replace(new RegExp("".concat(UNIT_LABEL_PLACEHOLDER, "\\s+\\/*")), '');
181
178
  const paymentMethod = getMethod(paymentMethodId);
179
+ const freeTrial = (0, _util.getProductFreeTrial)({
180
+ typeName: 'serverless',
181
+ freeTrialProducts,
182
+ currencyId: currency.id
183
+ });
182
184
  setState({
183
185
  unitPrice,
184
186
  totalPrice,
185
187
  minStakeAmount: "".concat(minStakeAmount, " ").concat(currency.symbol),
186
- shouldStake: (paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.type) === 'arcblock'
188
+ shouldStake: (paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.type) === 'arcblock',
189
+ freeTrial
187
190
  });
188
191
  } catch (error) {
189
192
  console.error('calculate failed error', error);
@@ -196,7 +199,7 @@ function Component(_ref2) {
196
199
  width: '100%',
197
200
  height: '100%'
198
201
  },
199
- children: [isFreeTrial && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
202
+ children: [state.freeTrial && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
200
203
  sx: {
201
204
  display: 'flex',
202
205
  justifyContent: 'flex-start'
@@ -204,7 +207,7 @@ function Component(_ref2) {
204
207
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Chip.default, {
205
208
  icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_RocketLaunch.default, {}),
206
209
  label: t('checkout.freeTrialHint', {
207
- duration: (0, _prettyMsI18n.default)(freeTrialDurationSeconds * 1000, {
210
+ duration: (0, _prettyMsI18n.default)(state.freeTrial.duration * 1000, {
208
211
  locale: locale === 'zh' ? 'zh_CN' : 'en_US',
209
212
  compact: true,
210
213
  verbose: true,
@@ -352,10 +355,10 @@ function Component(_ref2) {
352
355
  value: state.minStakeAmount,
353
356
  highlight: false
354
357
  }, {
355
- label: isFreeTrial ? t('checkout.estimatedCostFreeTrial') : t('checkout.estimatedCost'),
358
+ label: state.isFreeTrial ? t('checkout.estimatedCostFreeTrial') : t('checkout.estimatedCost'),
356
359
  value: state.totalPrice,
357
360
  hint: t('checkout.estimatedCostHint'),
358
- highlight: isFreeTrial
361
+ highlight: state.isFreeTrial
359
362
  }].map(item => {
360
363
  if (!item) {
361
364
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/launcher-ux",
3
- "version": "2.3.49",
3
+ "version": "2.3.51",
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.23",
57
- "@blocklet/launcher-util": "2.3.49",
58
- "@blocklet/payment-react": "^1.14.32",
57
+ "@blocklet/launcher-util": "2.3.51",
58
+ "@blocklet/payment-react": "^1.14.34",
59
59
  "@emotion/styled": "^11.13.0",
60
60
  "@mui/icons-material": "^5.16.7",
61
61
  "@mui/material": "^5.16.7",
@@ -93,5 +93,5 @@
93
93
  "require": "./lib/use-mobile/index.js"
94
94
  }
95
95
  },
96
- "gitHead": "823c6e1af3fb5e3f8bb4cc451bc7667fcc8a235e"
96
+ "gitHead": "73a28e39959b50167e326ed83161fb4dc6cd09f7"
97
97
  }