@blocklet/launcher-workflow 2.0.3 → 2.0.5

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 CHANGED
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
- var _jsCookie = _interopRequireDefault(require("js-cookie"));
9
8
  var _urlJoin = _interopRequireDefault(require("url-join"));
10
9
  var _reactRouterDom = require("react-router-dom");
11
10
  var _styled = _interopRequireDefault(require("@emotion/styled"));
@@ -84,6 +83,7 @@ function CheckoutPage() {
84
83
  } = (0, _session.useSessionContext)();
85
84
  const [paying, setPaying] = (0, _react.useState)(false);
86
85
  const [showAgreement, setShowAgreement] = (0, _react.useState)(false);
86
+ const [showPayment, setShowPayment] = (0, _react.useState)(false);
87
87
  const [agree, setAgree] = (0, _react.useState)(false);
88
88
  const navigate = (0, _reactRouterDom.useNavigate)();
89
89
  const {
@@ -132,22 +132,32 @@ function CheckoutPage() {
132
132
  const switchPayment = method => {
133
133
  setPaymentMethod(method);
134
134
  };
135
- const handlePay = () => {
136
- if (!(session !== null && session !== void 0 && session.user)) {
137
- session.login(() => setPaying(true));
135
+ const handlePay = async () => {
136
+ if (session.user) {
137
+ setShowPayment(true);
138
138
  return;
139
139
  }
140
140
  setPaying(true);
141
+ if (!(session !== null && session !== void 0 && session.user)) {
142
+ const paymentTokenURL = (0, _urlJoin.default)(didPayPrefix, "/did/purchase/token?productId=".concat(planId, "&paymentMethodId=").concat(paymentMethod._id));
143
+ const {
144
+ data
145
+ } = await api.get(paymentTokenURL);
146
+ session.login((results, decrypt) => {
147
+ const [, purchaseResult] = results;
148
+ return handlePaid(purchaseResult, decrypt);
149
+ }, {
150
+ nw: data.url,
151
+ forceConnected: false,
152
+ saveConnect: false
153
+ });
154
+ }
141
155
  };
142
156
  const handleCancelPay = () => setPaying(false);
143
- const handlePaid = async (_ref, decrypt) => {
157
+ const handlePaid = async _ref => {
144
158
  let {
145
- nftId,
146
- launchToken
159
+ nftId
147
160
  } = _ref;
148
- if (launchToken) {
149
- _jsCookie.default.set('launch-token', decrypt(launchToken));
150
- }
151
161
  const nftState = await (0, _util.getAsset)(window.blocklet.CHAIN_HOST, nftId);
152
162
  if ((nftState.tags || []).includes(_constant.NFT_TYPE_SERVERLESS)) {
153
163
  searchParams.set('launchType', 'serverless');
@@ -285,13 +295,13 @@ function CheckoutPage() {
285
295
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.default, {
286
296
  loading: paying,
287
297
  className: "button-pay",
288
- disabled: paying || !planId || !paymentMethod || !agree,
298
+ disabled: paying || showPayment || !planId || !paymentMethod || !agree,
289
299
  variant: "contained",
290
300
  onClick: handlePay,
291
301
  children: t('common.pay')
292
302
  })
293
303
  })]
294
- }), paying && /*#__PURE__*/(0, _jsxRuntime.jsx)(_payment.default, {
304
+ }), showPayment && /*#__PURE__*/(0, _jsxRuntime.jsx)(_payment.default, {
295
305
  baseURL: didPayPrefix,
296
306
  method: paymentMethod,
297
307
  userDid: session === null || session === void 0 ? void 0 : (_session$user = session.user) === null || _session$user === void 0 ? void 0 : _session$user.did,
@@ -262,7 +262,7 @@ function Plan(_ref2) {
262
262
  }));
263
263
  }
264
264
  const Outer = _styled.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n\n .recommend-icon {\n display: none;\n }\n\n &.card-recommend {\n margin-right: 8px;\n\n .recommend-icon {\n display: block;\n position: absolute;\n top: -8px;\n right: -8px;\n }\n"])));
265
- const Container = _styled.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n flex-direction: column;\n border-radius: 12px;\n overflow: hidden;\n min-height: 400px;\n margin-top: 8px;\n white-space: nowrap;\n padding: 16px;\n\n .toc__title {\n font-weight: bolder;\n align-items: flex-start;\n }\n\n &:not(.toc) {\n color: #000;\n background-color: ", ";\n cursor: pointer;\n }\n\n &:not(.toc, .checked):hover {\n color: #000;\n background-color: #ddf6f8;\n cursor: pointer;\n }\n\n &.checked {\n color: #fff;\n background-color: ", ";\n cursor: pointer;\n }\n\n .basic {\n width: 100%;\n height: 8em;\n\n .header {\n text-align: center;\n .header__title {\n color: ", ";\n }\n\n .header__name {\n font-weight: bolder;\n }\n }\n\n .price-info {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n height: 6.5em;\n\n .price {\n font-size: 1.5em;\n font-weight: bolder;\n }\n\n .period {\n color: ", ";\n }\n }\n }\n\n .features {\n display: flex;\n flex-direction: column;\n width: 100%;\n margin-top: auto;\n\n .feature {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 48px;\n\n @media (min-width: ", "px) {\n margin-left: 28px;\n }\n\n @media (max-width: ", "px) {\n justify-content: flex-start;\n }\n\n &:not(:last-child) {\n border-bottom: 1px solid;\n border-bottom-color: ", ";\n }\n }\n }\n"])), props => props.theme.palette.secondary.main, props => props.theme.palette.primary.main, props => props.checked ? '#ffffff' : '#9397a1', props => props.checked ? '#ffffff' : '#9397a1', props => props.theme.breakpoints.values.md, props => props.theme.breakpoints.values.md, props => props.checked || props.hovered ? 'rgba(255, 255, 255, 0.2)' : '#f6f6f6');
265
+ const Container = _styled.default.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n flex-direction: column;\n border-radius: 12px;\n overflow: hidden;\n min-height: 400px;\n margin-top: 8px;\n white-space: nowrap;\n padding: 16px;\n\n .toc__title {\n font-weight: bolder;\n align-items: flex-start;\n }\n\n &:not(.toc) {\n color: #000;\n background-color: ", ";\n cursor: pointer;\n }\n\n &:not(.toc, .checked):hover {\n color: #000;\n background-color: #ddf6f8;\n cursor: pointer;\n }\n\n &.checked {\n color: #fff;\n background-color: ", ";\n cursor: pointer;\n }\n\n .basic {\n width: 100%;\n height: 8em;\n\n .header {\n text-align: center;\n .header__title {\n color: ", ";\n }\n\n .header__name {\n font-weight: bolder;\n }\n }\n\n .price-info {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n height: 6.5em;\n\n .price {\n font-size: 1.5em;\n font-weight: bolder;\n }\n\n .period {\n color: ", ";\n }\n }\n }\n\n .features {\n display: flex;\n flex-direction: column;\n width: 100%;\n margin-top: auto;\n\n .feature {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 48px;\n\n @media (max-width: 768px) {\n margin-left: 28px;\n justify-content: flex-start;\n }\n\n &:not(:last-child) {\n border-bottom: 1px solid;\n border-bottom-color: ", ";\n }\n }\n }\n"])), props => props.theme.palette.secondary.main, props => props.theme.palette.primary.main, props => props.checked ? '#ffffff' : '#9397a1', props => props.checked ? '#ffffff' : '#9397a1', props => props.checked || props.hovered ? 'rgba(255, 255, 255, 0.2)' : '#f6f6f6');
266
266
  Plan.propTypes = {
267
267
  plan: _propTypes.default.object,
268
268
  productFeatures: _propTypes.default.array,
package/lib/locales/en.js CHANGED
@@ -39,7 +39,7 @@ module.exports = {
39
39
  }
40
40
  },
41
41
  launch: {
42
- pageTitle: 'Launch',
42
+ pageTitle: 'Prepare Space',
43
43
  invalidFftId: 'Invalid Purchase NFT ID',
44
44
  launchApp: 'Launch Application',
45
45
  launching: 'Your Blocklet Server is being baked, please be patient, it usually takes about 5 minutes',
@@ -95,7 +95,7 @@ module.exports = {
95
95
  }
96
96
  },
97
97
  purchase: {
98
- pageTitle: 'Purchase',
98
+ pageTitle: 'Purchase Space',
99
99
  selectSpaceHint: 'Already have dedicated space? Click here to select >',
100
100
  dialog: {
101
101
  title: 'Purchase Blocklet Server NFT',
package/lib/locales/zh.js CHANGED
@@ -39,7 +39,7 @@ module.exports = {
39
39
  }
40
40
  },
41
41
  launch: {
42
- pageTitle: '启动',
42
+ pageTitle: '准备空间',
43
43
  invalidFftId: '无效的购买凭证',
44
44
  launchApp: '启动应用',
45
45
  launching: '节点正在启动中, 大约需要 5 分钟',
@@ -95,7 +95,7 @@ module.exports = {
95
95
  }
96
96
  },
97
97
  purchase: {
98
- pageTitle: '选购',
98
+ pageTitle: '选购空间',
99
99
  selectSpaceHint: '已有专用空间?点击这里选择 >',
100
100
  dialog: {
101
101
  title: '购买 Blocklet Server NFT',
package/lib/purchase.js CHANGED
@@ -170,13 +170,13 @@ function PurchasePage(_ref) {
170
170
  children: [embed && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
171
171
  className: "select-space",
172
172
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRouterDom.Link, {
173
- to: (0, _urlJoin.default)(routerPrefix, "/select".concat(window.location.search)),
173
+ to: (0, _urlJoin.default)(routerPrefix, "/purchase/select".concat(window.location.search)),
174
174
  children: t('purchase.selectSpaceHint')
175
175
  })
176
176
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
177
177
  component: _reactRouterDom.Link,
178
178
  disabled: planState.loading || !selectedPlanId,
179
- to: (0, _urlJoin.default)(routerPrefix, "/checkout?".concat(params.toString())),
179
+ to: (0, _urlJoin.default)(routerPrefix, "/purchase/checkout?".concat(params.toString())),
180
180
  className: "button-next",
181
181
  variant: "contained",
182
182
  children: t('common.next')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/launcher-workflow",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "description": "Purchase components for Launcher UI",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -36,24 +36,24 @@
36
36
  "react": ">=18.1.0"
37
37
  },
38
38
  "dependencies": {
39
- "@arcblock/did-connect": "^2.4.68",
40
- "@arcblock/icons": "^2.4.68",
41
- "@arcblock/license": "^2.4.68",
42
- "@arcblock/ux": "^2.4.68",
43
- "@blocklet/launcher-layout": "2.0.3",
44
- "@blocklet/launcher-util": "2.0.3",
45
- "@blocklet/launcher-ux": "2.0.3",
46
- "@did-pay/react": "^1.9.38",
47
- "@emotion/react": "^11.10.5",
48
- "@emotion/styled": "^11.10.5",
49
- "@mui/icons-material": "^5.11.0",
50
- "@mui/material": "^5.11.8",
51
- "@ocap/util": "^1.18.39",
39
+ "@arcblock/did-connect": "^2.5.10",
40
+ "@arcblock/icons": "^2.5.10",
41
+ "@arcblock/license": "^2.5.10",
42
+ "@arcblock/ux": "^2.5.10",
43
+ "@blocklet/launcher-layout": "2.0.5",
44
+ "@blocklet/launcher-util": "2.0.5",
45
+ "@blocklet/launcher-ux": "2.0.5",
46
+ "@did-pay/react": "^1.9.41",
47
+ "@emotion/react": "^11.10.6",
48
+ "@emotion/styled": "^11.10.6",
49
+ "@mui/icons-material": "^5.11.11",
50
+ "@mui/material": "^5.11.13",
51
+ "@ocap/util": "^1.18.58",
52
52
  "@splidejs/react-splide": "^0.7.12",
53
53
  "@splidejs/splide": "^4.1.4",
54
54
  "@splidejs/splide-extension-grid": "^0.4.1",
55
- "@stripe/react-stripe-js": "^1.16.4",
56
- "@stripe/stripe-js": "^1.46.0",
55
+ "@stripe/react-stripe-js": "^1.16.5",
56
+ "@stripe/stripe-js": "^1.49.0",
57
57
  "axios": "^0.26.1",
58
58
  "flat": "^5.0.2",
59
59
  "js-cookie": "^3.0.1",
@@ -61,16 +61,16 @@
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.8.1",
64
+ "react-router-dom": "^6.9.0",
65
65
  "react-use": "^17.4.0",
66
66
  "url-join": "^4.0.1"
67
67
  },
68
68
  "devDependencies": {
69
- "@babel/cli": "^7.20.7",
70
- "@babel/core": "^7.20.12",
69
+ "@babel/cli": "^7.21.0",
70
+ "@babel/core": "^7.21.3",
71
71
  "@babel/preset-env": "^7.20.2",
72
72
  "@babel/preset-react": "^7.18.6",
73
- "babel-plugin-inline-react-svg": "^2.0.1"
73
+ "babel-plugin-inline-react-svg": "^2.0.2"
74
74
  },
75
- "gitHead": "a296cb39be055fc2797a360505bfc7b662b09b92"
75
+ "gitHead": "e8dfa1e5aa7384efbd60c38a73fdec4e5bdbdc25"
76
76
  }