@blocklet/launcher-workflow 2.0.35 → 2.0.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.
- package/lib/checkout.js +2 -2
- package/lib/locales/en.js +1 -0
- package/lib/locales/zh.js +1 -0
- package/lib/purchase.js +73 -6
- package/package.json +19 -19
package/lib/checkout.js
CHANGED
|
@@ -197,9 +197,9 @@ function CheckoutPage(_ref) {
|
|
|
197
197
|
};
|
|
198
198
|
const handlePaid = async _ref2 => {
|
|
199
199
|
let {
|
|
200
|
-
nftId
|
|
200
|
+
nftId,
|
|
201
|
+
nftState
|
|
201
202
|
} = _ref2;
|
|
202
|
-
const nftState = await (0, _util2.getAsset)(window.blocklet.CHAIN_HOST, nftId);
|
|
203
203
|
if ((nftState.tags || []).includes(_constant.NFT_TYPE_SERVERLESS)) {
|
|
204
204
|
if (!embed) {
|
|
205
205
|
setShowPaidDialog({
|
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
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.
|
|
216
|
-
className: "
|
|
217
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
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 .
|
|
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.
|
|
3
|
+
"version": "2.0.37",
|
|
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.
|
|
40
|
-
"@arcblock/icons": "^2.5.
|
|
41
|
-
"@arcblock/license": "^2.5.
|
|
42
|
-
"@arcblock/ux": "^2.5.
|
|
43
|
-
"@blocklet/launcher-layout": "2.0.
|
|
44
|
-
"@blocklet/launcher-util": "2.0.
|
|
45
|
-
"@blocklet/launcher-ux": "2.0.
|
|
46
|
-
"@did-pay/react": "^1.9.
|
|
47
|
-
"@emotion/react": "^11.10.
|
|
48
|
-
"@emotion/styled": "^11.10.
|
|
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.37",
|
|
44
|
+
"@blocklet/launcher-util": "2.0.37",
|
|
45
|
+
"@blocklet/launcher-ux": "2.0.37",
|
|
46
|
+
"@did-pay/react": "^1.9.53",
|
|
47
|
+
"@emotion/react": "^11.10.8",
|
|
48
|
+
"@emotion/styled": "^11.10.8",
|
|
49
49
|
"@mui/icons-material": "^5.11.16",
|
|
50
|
-
"@mui/material": "^5.12.
|
|
51
|
-
"@ocap/util": "^1.18.
|
|
50
|
+
"@mui/material": "^5.12.3",
|
|
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",
|
|
@@ -56,21 +56,21 @@
|
|
|
56
56
|
"@stripe/stripe-js": "^1.52.1",
|
|
57
57
|
"axios": "^0.26.1",
|
|
58
58
|
"flat": "^5.0.2",
|
|
59
|
-
"js-cookie": "^3.0.
|
|
59
|
+
"js-cookie": "^3.0.5",
|
|
60
60
|
"lodash.get": "^4.4.2",
|
|
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.
|
|
64
|
+
"react-router-dom": "^6.11.1",
|
|
65
65
|
"react-use": "^17.4.0",
|
|
66
66
|
"url-join": "^4.0.1"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@babel/cli": "^7.21.
|
|
70
|
-
"@babel/core": "^7.21.
|
|
71
|
-
"@babel/preset-env": "^7.21.
|
|
69
|
+
"@babel/cli": "^7.21.5",
|
|
70
|
+
"@babel/core": "^7.21.8",
|
|
71
|
+
"@babel/preset-env": "^7.21.5",
|
|
72
72
|
"@babel/preset-react": "^7.18.6",
|
|
73
73
|
"babel-plugin-inline-react-svg": "^2.0.2"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "17c9e53b70490fc22fbfe43c1a841431c2234d97"
|
|
76
76
|
}
|