@blocklet/launcher-workflow 2.0.36 → 2.0.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.
package/lib/locales/en.js CHANGED
@@ -98,6 +98,7 @@ module.exports = {
98
98
  pageTitle: 'Purchase Space',
99
99
  selectSpaceHint: 'Already have dedicated space? Click here to select >',
100
100
  morePlanPrompt: 'Flip the page to see more plans',
101
+ redeem: 'I have purchased an NFT, Redeem',
101
102
  dialog: {
102
103
  title: 'Purchase Blocklet Space NFT',
103
104
  scan: 'Scan the QR code below with your DID wallet to complete purchase',
package/lib/locales/zh.js CHANGED
@@ -98,6 +98,7 @@ module.exports = {
98
98
  pageTitle: '选购空间',
99
99
  selectSpaceHint: '已有专用空间?点击这里选择 >',
100
100
  morePlanPrompt: '翻页看更多方案',
101
+ redeem: '我已购买 NFT, 兑换',
101
102
  dialog: {
102
103
  title: '购买 Blocklet Server NFT',
103
104
  scan: '用您的 DID 钱包扫描下面的二维码完成购买',
package/lib/purchase.js CHANGED
@@ -5,9 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
+ var _Connect = _interopRequireDefault(require("@arcblock/did-connect/lib/Connect"));
8
9
  var _Button = _interopRequireDefault(require("@arcblock/ux/lib/Button"));
9
10
  var _Center = _interopRequireDefault(require("@arcblock/ux/lib/Center"));
10
11
  var _compactLayout = _interopRequireDefault(require("@blocklet/launcher-layout/lib/compact-layout"));
12
+ var _constant = require("@blocklet/launcher-util/lib/constant");
11
13
  var _useMobile = _interopRequireDefault(require("@blocklet/launcher-ux/lib/use-mobile"));
12
14
  var _styled = _interopRequireDefault(require("@emotion/styled"));
13
15
  var _CircularProgress = _interopRequireDefault(require("@mui/material/CircularProgress"));
@@ -28,6 +30,7 @@ var _header = _interopRequireDefault(require("./components/layout/header"));
28
30
  var _plan = _interopRequireDefault(require("./components/plan"));
29
31
  var _locale = require("./contexts/locale");
30
32
  var _request = _interopRequireDefault(require("./contexts/request"));
33
+ var _session = require("./contexts/session");
31
34
  var _workflow = require("./contexts/workflow");
32
35
  var _jsxRuntime = require("react/jsx-runtime");
33
36
  var _templateObject;
@@ -72,7 +75,8 @@ function PurchasePage(_ref) {
72
75
  disableBack
73
76
  } = _ref;
74
77
  const {
75
- t
78
+ t,
79
+ locale
76
80
  } = (0, _locale.useLocaleContext)();
77
81
  const {
78
82
  create
@@ -80,6 +84,10 @@ function PurchasePage(_ref) {
80
84
  const {
81
85
  isMobile
82
86
  } = (0, _useMobile.default)();
87
+ const navigate = (0, _reactRouterDom.useNavigate)();
88
+ const {
89
+ session
90
+ } = (0, _session.useSessionContext)();
83
91
  const [searchParams] = (0, _reactRouterDom.useSearchParams)();
84
92
  const [selectedPlanId, setSelectedPlanId] = (0, _react.useState)();
85
93
  const [openMorePlanPrompt, setOpenMorePlanPrompt] = (0, _react.useState)(false);
@@ -97,6 +105,7 @@ function PurchasePage(_ref) {
97
105
  const [planListRef, {
98
106
  width: planListWidth
99
107
  }] = (0, _useMeasure.default)();
108
+ const [showRedeem, setShowRedeem] = (0, _react.useState)(false);
100
109
  const api = create({
101
110
  baseURL: didPayPrefix
102
111
  });
@@ -192,6 +201,41 @@ function PurchasePage(_ref) {
192
201
  console.error('parse product feature failed:', error);
193
202
  }
194
203
  }
204
+ const handleRedeem = async () => {
205
+ if (session.user) {
206
+ setShowRedeem(true);
207
+ return;
208
+ }
209
+ const redeemConnectURL = (0, _urlJoin.default)(routerPrefix, '/did/redeem/token');
210
+ const {
211
+ data
212
+ } = await api.get(redeemConnectURL);
213
+ session.login({
214
+ onSuccess: results => {
215
+ const [, redeemResult] = results;
216
+ handleRedeemed(redeemResult);
217
+ },
218
+ oncancel: () => setShowRedeem(false),
219
+ extraParams: {
220
+ nw: data.url,
221
+ forceConnected: false,
222
+ saveConnect: false
223
+ }
224
+ });
225
+ };
226
+ const handleRedeemed = _ref2 => {
227
+ let {
228
+ nftId,
229
+ type
230
+ } = _ref2;
231
+ if (type === _constant.NFT_TYPE_SERVERLESS) {
232
+ searchParams.set('launchType', 'serverless');
233
+ }
234
+ navigate({
235
+ pathname: (0, _urlJoin.default)(routerPrefix, "/launch/".concat(nftId)),
236
+ search: searchParams.toString()
237
+ });
238
+ };
195
239
  searchParams.set('planId', selectedPlanId);
196
240
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Container, {
197
241
  embed: embed,
@@ -212,12 +256,18 @@ function PurchasePage(_ref) {
212
256
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_compactLayout.default, {
213
257
  bottom: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_footer.default, {
214
258
  className: "footer",
215
- children: [embed && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
216
- className: "select-space",
217
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Link, {
259
+ children: [embed && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
260
+ className: "footer-left",
261
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
262
+ onClick: () => handleRedeem(),
263
+ className: "redeem-button",
264
+ variant: "outlined",
265
+ children: t('purchase.redeem')
266
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Link, {
267
+ className: "select-space",
218
268
  to: (0, _urlJoin.default)(routerPrefix, "/purchase/select".concat(window.location.search)),
219
269
  children: t('purchase.selectSpaceHint')
220
- })
270
+ })]
221
271
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
222
272
  component: _reactRouterDom.Link,
223
273
  disabled: planState.loading || !selectedPlanId,
@@ -314,10 +364,27 @@ function PurchasePage(_ref) {
314
364
  })
315
365
  })
316
366
  })
367
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Connect.default, {
368
+ open: showRedeem,
369
+ popup: true,
370
+ useSocket: false,
371
+ locale: locale,
372
+ action: "redeem",
373
+ checkFn: api.create().get,
374
+ onSuccess: handleRedeemed,
375
+ onClose: () => setShowRedeem(false),
376
+ checkTimeout: 60 * 5000,
377
+ showDownload: false,
378
+ messages: {
379
+ title: t('redeem.dialog.title'),
380
+ scan: t('redeem.dialog.scan'),
381
+ confirm: t('redeem.dialog.confirm'),
382
+ success: t('redeem.dialog.success')
383
+ }
317
384
  })]
318
385
  });
319
386
  }
320
- const Container = (0, _styled.default)(_layout.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .container-inner {\n position: absolute;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n }\n\n .plan-list {\n display: flex;\n justify-content: center;\n align-items: center;\n\n @media (min-width: 900px) {\n margin-top: 20px;\n }\n\n @media (min-width: 680px) and (max-width: 899px) {\n justify-content: center;\n }\n\n .toc {\n min-width: 180px;\n margin-right: 20px;\n }\n\n button.splide__pagination__page.is-active {\n background: #9397a1;\n }\n }\n\n .splide__pagination-custom {\n bottom: -24px;\n }\n\n .footer {\n display: flex;\n justify-content: ", ";\n align-item: center;\n margin-top: auto;\n padding-top: 16px;\n\n > * {\n margin: 0 8px;\n ", " {\n margin: 0 16px;\n }\n }\n\n @media (max-width: ", "px) {\n flex-direction: column;\n align-items: center;\n }\n\n .select-space {\n a {\n color: #000;\n }\n\n & > a:hover {\n text-decoration: underline !important;\n }\n }\n\n .button-next {\n width: 200px;\n\n @media (max-width: ", "px) {\n width: 100%;\n margin-top: 20px;\n }\n }\n }\n"])), props => props.embed ? 'space-between' : 'flex-end', props => props.theme.breakpoints.up('md'), props => props.theme.breakpoints.values.sm, props => props.theme.breakpoints.values.sm);
387
+ const Container = (0, _styled.default)(_layout.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .container-inner {\n position: absolute;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n }\n\n .plan-list {\n display: flex;\n justify-content: center;\n align-items: center;\n\n @media (min-width: 900px) {\n margin-top: 20px;\n }\n\n @media (min-width: 680px) and (max-width: 899px) {\n justify-content: center;\n }\n\n .toc {\n min-width: 180px;\n margin-right: 20px;\n }\n\n button.splide__pagination__page.is-active {\n background: #9397a1;\n }\n }\n\n .splide__pagination-custom {\n bottom: -24px;\n }\n\n .footer {\n display: flex;\n justify-content: ", ";\n align-item: center;\n margin-top: auto;\n padding-top: 16px;\n\n > * {\n margin: 0 8px;\n ", " {\n margin: 0 16px;\n }\n }\n\n @media (max-width: ", "px) {\n flex-direction: column;\n align-items: center;\n }\n\n .footer-left {\n display: flex;\n gap: 16px;\n align-items: center;\n justify-content: space-between;\n\n .select-space {\n order: 1;\n color: #000;\n\n &:hover {\n text-decoration: underline !important;\n }\n }\n\n .redeem-button {\n order: 1;\n }\n\n @media (max-width: ", "px) {\n width: 100%;\n flex-direction: column;\n\n .redeem-button {\n width: 100%;\n order: 2;\n }\n }\n }\n\n .button-next {\n width: 200px;\n\n @media (max-width: ", "px) {\n width: 100%;\n margin-top: 20px;\n }\n }\n }\n"])), props => props.embed ? 'space-between' : 'flex-end', props => props.theme.breakpoints.up('md'), props => props.theme.breakpoints.values.sm, props => props.theme.breakpoints.values.sm, props => props.theme.breakpoints.values.sm);
321
388
  PurchasePage.propTypes = {
322
389
  disableBack: _propTypes.default.bool
323
390
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/launcher-workflow",
3
- "version": "2.0.36",
3
+ "version": "2.0.38",
4
4
  "description": "Purchase components for Launcher UI",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -36,19 +36,19 @@
36
36
  "react": ">=18.1.0"
37
37
  },
38
38
  "dependencies": {
39
- "@arcblock/did-connect": "^2.5.36",
40
- "@arcblock/icons": "^2.5.36",
41
- "@arcblock/license": "^2.5.36",
42
- "@arcblock/ux": "^2.5.36",
43
- "@blocklet/launcher-layout": "2.0.36",
44
- "@blocklet/launcher-util": "2.0.36",
45
- "@blocklet/launcher-ux": "2.0.36",
39
+ "@arcblock/did-connect": "^2.5.37",
40
+ "@arcblock/icons": "^2.5.37",
41
+ "@arcblock/license": "^2.5.37",
42
+ "@arcblock/ux": "^2.5.37",
43
+ "@blocklet/launcher-layout": "2.0.38",
44
+ "@blocklet/launcher-util": "2.0.38",
45
+ "@blocklet/launcher-ux": "2.0.38",
46
46
  "@did-pay/react": "^1.9.53",
47
47
  "@emotion/react": "^11.10.8",
48
48
  "@emotion/styled": "^11.10.8",
49
49
  "@mui/icons-material": "^5.11.16",
50
50
  "@mui/material": "^5.12.3",
51
- "@ocap/util": "^1.18.76",
51
+ "@ocap/util": "^1.18.77",
52
52
  "@splidejs/react-splide": "^0.7.12",
53
53
  "@splidejs/splide": "^4.1.4",
54
54
  "@splidejs/splide-extension-grid": "^0.4.1",
@@ -61,7 +61,7 @@
61
61
  "lodash.throttle": "^4.1.1",
62
62
  "prop-types": "^15.8.1",
63
63
  "react-lottie-player": "^1.5.4",
64
- "react-router-dom": "^6.11.0",
64
+ "react-router-dom": "^6.11.1",
65
65
  "react-use": "^17.4.0",
66
66
  "url-join": "^4.0.1"
67
67
  },
@@ -72,5 +72,5 @@
72
72
  "@babel/preset-react": "^7.18.6",
73
73
  "babel-plugin-inline-react-svg": "^2.0.2"
74
74
  },
75
- "gitHead": "c0fad1d756b0c8b997ac43056d460b9a93b7bedb"
75
+ "gitHead": "7298526de007c142f12ebcccd8d213e3b4366d90"
76
76
  }