@pisell/private-materials 3.0.22 → 3.0.24

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.
@@ -39,6 +39,7 @@ import { formatProductBundle } from "../components/footer/utils";
39
39
  import { formatProductListByCategory, getProductTotalPrice } from "../utils";
40
40
  import { locales, getUniqueId } from "@pisell/utils";
41
41
  import "./index.less";
42
+ import useEngineContext from "../../../hooks/useEngineContext";
42
43
  export var formatProducts = function formatProducts(values) {
43
44
  var arr = [];
44
45
  arr = values.map(function (item) {
@@ -109,7 +110,7 @@ var formatProductValues = function formatProductValues(data) {
109
110
  });
110
111
  };
111
112
  var Addons = Provider(function (props) {
112
- var _state$addons2, _state$addons4;
113
+ var _context$appHelper, _state$addons2, _state$addons4;
113
114
  var globalState = props.globalState;
114
115
  var _useContext = useContext(Context),
115
116
  state = _useContext.state,
@@ -122,6 +123,10 @@ var Addons = Provider(function (props) {
122
123
  _useState4 = _slicedToArray(_useState3, 2),
123
124
  search = _useState4[0],
124
125
  setSearch = _useState4[1];
126
+ var context = useEngineContext();
127
+ var _ref = ((_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.utils) || {},
128
+ isTerminal = _ref.isTerminal,
129
+ interaction = _ref.interaction;
125
130
  useEffect(function () {
126
131
  dispatch({
127
132
  type: "setState",
@@ -154,6 +159,14 @@ var Addons = Provider(function (props) {
154
159
  init();
155
160
  }
156
161
  }, [state.bookingDetail]);
162
+ useEffect(function () {
163
+ if (isTerminal !== null && isTerminal !== void 0 && isTerminal()) {
164
+ var _interaction$utils;
165
+ interaction === null || interaction === void 0 ? void 0 : (_interaction$utils = interaction.utils) === null || _interaction$utils === void 0 ? void 0 : _interaction$utils.mountFunction("booking", "refreshBookingDetailAddons", function () {
166
+ init();
167
+ });
168
+ }
169
+ }, [state]);
157
170
 
158
171
  /**
159
172
  * @title: 通过订单id 获取addons
@@ -163,7 +176,7 @@ var Addons = Provider(function (props) {
163
176
  * @Date: 2024-01-30 16:35
164
177
  */
165
178
  var getAddonsByOrderId = /*#__PURE__*/function () {
166
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
179
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
167
180
  var data;
168
181
  return _regeneratorRuntime().wrap(function _callee$(_context) {
169
182
  while (1) switch (_context.prev = _context.next) {
@@ -189,7 +202,7 @@ var Addons = Provider(function (props) {
189
202
  }, _callee);
190
203
  }));
191
204
  return function getAddonsByOrderId() {
192
- return _ref.apply(this, arguments);
205
+ return _ref2.apply(this, arguments);
193
206
  };
194
207
  }();
195
208
 
@@ -201,7 +214,7 @@ var Addons = Provider(function (props) {
201
214
  * @Date: 2024-01-30 16:36
202
215
  */
203
216
  var getProducts = /*#__PURE__*/function () {
204
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
217
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
205
218
  var data;
206
219
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
207
220
  while (1) switch (_context2.prev = _context2.next) {
@@ -234,7 +247,7 @@ var Addons = Provider(function (props) {
234
247
  }, _callee2);
235
248
  }));
236
249
  return function getProducts() {
237
- return _ref2.apply(this, arguments);
250
+ return _ref3.apply(this, arguments);
238
251
  };
239
252
  }();
240
253
 
@@ -374,6 +387,16 @@ var Addons = Provider(function (props) {
374
387
  * @Date: 2024-01-30 16:40
375
388
  */
376
389
  var handleOpenAdd = function handleOpenAdd() {
390
+ if (isTerminal !== null && isTerminal !== void 0 && isTerminal()) {
391
+ var _interaction$utils2, _interaction$utils2$p;
392
+ return interaction === null || interaction === void 0 ? void 0 : (_interaction$utils2 = interaction.utils) === null || _interaction$utils2 === void 0 ? void 0 : (_interaction$utils2$p = _interaction$utils2.postMessageToApp) === null || _interaction$utils2$p === void 0 ? void 0 : _interaction$utils2$p.call(_interaction$utils2, {
393
+ module: "booking",
394
+ key: "edit_order",
395
+ data: {
396
+ order_id: state.bookingId
397
+ }
398
+ });
399
+ }
377
400
  setSearch("");
378
401
  dispatch({
379
402
  type: "setAddons",
@@ -28,6 +28,7 @@ import { formatValues } from "./utils";
28
28
  import { getSumTotal, is_price_include_tax } from "./amount";
29
29
  import FooterMenus from "./FooterMenus";
30
30
  import "./index.less";
31
+ import useEngineContext from "../../../../hooks/useEngineContext";
31
32
 
32
33
  /**
33
34
  * @title: 底部
@@ -38,7 +39,7 @@ import "./index.less";
38
39
  * @Date: 2024-01-30 16:51
39
40
  */
40
41
  var Footer = function Footer(props) {
41
- var _state$bookingConfig2, _state$bookingConfig3, _state$bookingConfig4, _state$addons2, _state$addons4, _state$bookingDetail3;
42
+ var _context$appHelper, _state$bookingConfig2, _state$bookingConfig3, _state$bookingConfig4, _state$addons2, _state$addons4, _state$bookingDetail3;
42
43
  var state = props.state,
43
44
  buttons = props.buttons,
44
45
  dispatch = props.dispatch,
@@ -58,6 +59,10 @@ var Footer = function Footer(props) {
58
59
  _useState6 = _slicedToArray(_useState5, 2),
59
60
  checkoutLoading = _useState6[0],
60
61
  setCheckoutLoading = _useState6[1];
62
+ var context = useEngineContext();
63
+ var _context$appHelper$ut = (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.utils,
64
+ isTerminal = _context$appHelper$ut.isTerminal,
65
+ interaction = _context$appHelper$ut.interaction;
61
66
 
62
67
  // board 配置
63
68
  var params = useMemo(function () {
@@ -148,9 +153,22 @@ var Footer = function Footer(props) {
148
153
  */
149
154
  var goCheckout = /*#__PURE__*/function () {
150
155
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(order_id) {
156
+ var _interaction$utils, _interaction$utils$po;
151
157
  return _regeneratorRuntime().wrap(function _callee$(_context) {
152
158
  while (1) switch (_context.prev = _context.next) {
153
159
  case 0:
160
+ if (!(isTerminal !== null && isTerminal !== void 0 && isTerminal())) {
161
+ _context.next = 2;
162
+ break;
163
+ }
164
+ return _context.abrupt("return", interaction === null || interaction === void 0 ? void 0 : (_interaction$utils = interaction.utils) === null || _interaction$utils === void 0 ? void 0 : (_interaction$utils$po = _interaction$utils.postMessageToApp) === null || _interaction$utils$po === void 0 ? void 0 : _interaction$utils$po.call(_interaction$utils, {
165
+ module: 'booking',
166
+ key: 'booking_checkout',
167
+ data: {
168
+ order_id: order_id
169
+ }
170
+ }));
171
+ case 2:
154
172
  state.action({
155
173
  type: "pisell1.handlePayment",
156
174
  data: {
@@ -160,7 +178,7 @@ var Footer = function Footer(props) {
160
178
  state === null || state === void 0 ? void 0 : state.callback();
161
179
  }
162
180
  });
163
- case 1:
181
+ case 3:
164
182
  case "end":
165
183
  return _context.stop();
166
184
  }
@@ -101,7 +101,7 @@ var DateCom = function DateCom() {
101
101
  bordered: false,
102
102
  suffixIcon: !modal.state.disabledEdit ? /*#__PURE__*/React.createElement(ChevronDown, null) : null,
103
103
  disabledDate: disabledDate,
104
- format: modal.state.locale === "en" ? "dddd, MM DD YYYY" : "YYYY年MM月DD日",
104
+ format: modal.state.locale === "en" ? "dddd, DD MMM YYYY" : "YYYY年MM月DD日",
105
105
  value: modal.state.date.value,
106
106
  onChange: dateChange,
107
107
  disabled: modal.state.disabledEdit
@@ -21,7 +21,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
21
21
  import React, { useContext, useEffect, useMemo, useState } from "react";
22
22
  import User01 from "@pisell/icon/es/User01";
23
23
  import { Context } from "../model";
24
- import { Avatar } from "antd";
24
+ import { Avatar, Skeleton } from "antd";
25
25
  import "./index.less";
26
26
  import { locales } from "@pisell/utils";
27
27
  import FormsCom from "../../forms/forms";
@@ -327,6 +327,10 @@ var Pet = function Pet() {
327
327
  }, [state.bookingId, state.bookingDetail, params.form_id, params.type, (_state$client8 = state.client) === null || _state$client8 === void 0 ? void 0 : (_state$client8$value = _state$client8.value) === null || _state$client8$value === void 0 ? void 0 : _state$client8$value.id]);
328
328
  return /*#__PURE__*/React.createElement("div", {
329
329
  className: "pisell-lowcode__booking-pet-wraps"
330
+ }, /*#__PURE__*/React.createElement(Skeleton, {
331
+ loading: loading,
332
+ active: true,
333
+ round: true
330
334
  }, /*#__PURE__*/React.createElement(FormsCom, {
331
335
  hideTitle: true,
332
336
  watch: {
@@ -386,6 +390,6 @@ var Pet = function Pet() {
386
390
  margin: 0
387
391
  }
388
392
  }
389
- }));
393
+ })));
390
394
  };
391
395
  export default Pet;
@@ -47,6 +47,7 @@ var import_utils = require("../components/footer/utils");
47
47
  var import_utils2 = require("../utils");
48
48
  var import_utils3 = require("@pisell/utils");
49
49
  var import_index = require("./index.less");
50
+ var import_useEngineContext = __toESM(require("../../../hooks/useEngineContext"));
50
51
  var formatProducts = (values) => {
51
52
  let arr = [];
52
53
  arr = values.map((item) => {
@@ -118,11 +119,13 @@ var formatProductValues = (data) => {
118
119
  });
119
120
  };
120
121
  var Addons = (0, import_model.Provider)((props) => {
121
- var _a, _b;
122
+ var _a, _b, _c;
122
123
  const { globalState } = props;
123
124
  const { state, dispatch } = (0, import_react.useContext)(import_model.Context);
124
125
  const [loading, setLoading] = (0, import_react.useState)(false);
125
126
  const [search, setSearch] = (0, import_react.useState)("");
127
+ const context = (0, import_useEngineContext.default)();
128
+ const { isTerminal, interaction } = ((_a = context.appHelper) == null ? void 0 : _a.utils) || {};
126
129
  (0, import_react.useEffect)(() => {
127
130
  dispatch({
128
131
  type: "setState",
@@ -148,6 +151,18 @@ var Addons = (0, import_model.Provider)((props) => {
148
151
  init();
149
152
  }
150
153
  }, [state.bookingDetail]);
154
+ (0, import_react.useEffect)(() => {
155
+ var _a2;
156
+ if (isTerminal == null ? void 0 : isTerminal()) {
157
+ (_a2 = interaction == null ? void 0 : interaction.utils) == null ? void 0 : _a2.mountFunction(
158
+ "booking",
159
+ "refreshBookingDetailAddons",
160
+ () => {
161
+ init();
162
+ }
163
+ );
164
+ }
165
+ }, [state]);
151
166
  const getAddonsByOrderId = async () => {
152
167
  setLoading(true);
153
168
  let data = await state.apis.getAddonsByOrderId();
@@ -271,12 +286,22 @@ var Addons = (0, import_model.Provider)((props) => {
271
286
  _list,
272
287
  search ? (item) => isIncludes(item.title) : void 0
273
288
  );
274
- }, [search, (_a = state.addons) == null ? void 0 : _a.originData]);
289
+ }, [search, (_b = state.addons) == null ? void 0 : _b.originData]);
275
290
  const isEdit = (0, import_react.useMemo)(() => {
276
291
  var _a2;
277
292
  return (_a2 = state == null ? void 0 : state.addons) == null ? void 0 : _a2.edit;
278
- }, [(_b = state == null ? void 0 : state.addons) == null ? void 0 : _b.edit]);
293
+ }, [(_c = state == null ? void 0 : state.addons) == null ? void 0 : _c.edit]);
279
294
  const handleOpenAdd = () => {
295
+ var _a2, _b2;
296
+ if (isTerminal == null ? void 0 : isTerminal()) {
297
+ return (_b2 = (_a2 = interaction == null ? void 0 : interaction.utils) == null ? void 0 : _a2.postMessageToApp) == null ? void 0 : _b2.call(_a2, {
298
+ module: "booking",
299
+ key: "edit_order",
300
+ data: {
301
+ order_id: state.bookingId
302
+ }
303
+ });
304
+ }
280
305
  setSearch("");
281
306
  dispatch({
282
307
  type: "setAddons",
@@ -43,23 +43,26 @@ var import_utils2 = require("./utils");
43
43
  var import_amount = require("./amount");
44
44
  var import_FooterMenus = __toESM(require("./FooterMenus"));
45
45
  var import_index = require("./index.less");
46
+ var import_useEngineContext = __toESM(require("../../../../hooks/useEngineContext"));
46
47
  var Footer = (props) => {
47
- var _a, _b, _c, _d, _e, _f;
48
+ var _a, _b, _c, _d, _e, _f, _g;
48
49
  const { state, buttons, dispatch, source } = props;
49
50
  const [showDetail, setShowDetail] = (0, import_react.useState)(false);
50
51
  const [loading, setLoading] = (0, import_react.useState)(false);
51
52
  const [checkoutLoading, setCheckoutLoading] = (0, import_react.useState)(false);
53
+ const context = (0, import_useEngineContext.default)();
54
+ const { isTerminal, interaction } = (_a = context.appHelper) == null ? void 0 : _a.utils;
52
55
  const params = (0, import_react.useMemo)(() => {
53
56
  var _a2, _b2, _c2;
54
57
  return ((_c2 = (_b2 = (_a2 = state == null ? void 0 : state.bookingConfig) == null ? void 0 : _a2.config) == null ? void 0 : _b2.basic) == null ? void 0 : _c2.appointment_subject) || {};
55
- }, [(_c = (_b = (_a = state == null ? void 0 : state.bookingConfig) == null ? void 0 : _a.config) == null ? void 0 : _b.basic) == null ? void 0 : _c.appointment_subject]);
58
+ }, [(_d = (_c = (_b = state == null ? void 0 : state.bookingConfig) == null ? void 0 : _b.config) == null ? void 0 : _c.basic) == null ? void 0 : _d.appointment_subject]);
56
59
  const addonsEdit = (0, import_react.useMemo)(() => {
57
60
  var _a2;
58
61
  if ((_a2 = state.addons) == null ? void 0 : _a2.edit) {
59
62
  return true;
60
63
  }
61
64
  return false;
62
- }, [(_d = state.addons) == null ? void 0 : _d.edit]);
65
+ }, [(_e = state.addons) == null ? void 0 : _e.edit]);
63
66
  const infoEdit = (0, import_react.useMemo)(() => {
64
67
  var _a2, _b2, _c2, _d2, _e2, _f2;
65
68
  if (!state.bookingId) {
@@ -108,6 +111,16 @@ var Footer = (props) => {
108
111
  return false;
109
112
  }, [state, params]);
110
113
  const goCheckout = async (order_id) => {
114
+ var _a2, _b2;
115
+ if (isTerminal == null ? void 0 : isTerminal()) {
116
+ return (_b2 = (_a2 = interaction == null ? void 0 : interaction.utils) == null ? void 0 : _a2.postMessageToApp) == null ? void 0 : _b2.call(_a2, {
117
+ module: "booking",
118
+ key: "booking_checkout",
119
+ data: {
120
+ order_id
121
+ }
122
+ });
123
+ }
111
124
  state.action({
112
125
  type: "pisell1.handlePayment",
113
126
  data: {
@@ -392,7 +405,7 @@ var Footer = (props) => {
392
405
  }
393
406
  }
394
407
  return false;
395
- }, [state.bookingId, state.bookingDetail, (_e = state.addons) == null ? void 0 : _e.load, state.renderType]);
408
+ }, [state.bookingId, state.bookingDetail, (_f = state.addons) == null ? void 0 : _f.load, state.renderType]);
396
409
  return /* @__PURE__ */ import_react.default.createElement(import_antd.Skeleton, { title: false, round: true, loading: showFooter, active: true }, /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-footer-total" }, /* @__PURE__ */ import_react.default.createElement("span", { className: "pisell-lowcode__booking-footer-left" }, /* @__PURE__ */ import_react.default.createElement("span", { className: "pisell-lowcode__booking-footer-left-total" }, totalText), /* @__PURE__ */ import_react.default.createElement("span", { className: "pisell-lowcode__booking-footer-left-arrears" }, arrearsText)), /* @__PURE__ */ import_react.default.createElement(
397
410
  "span",
398
411
  {
@@ -420,7 +433,7 @@ var Footer = (props) => {
420
433
  },
421
434
  /* @__PURE__ */ import_react.default.createElement("div", { className: "order-total-item-border" }),
422
435
  /* @__PURE__ */ import_react.default.createElement("div", { className: "order-total-item" }, /* @__PURE__ */ import_react.default.createElement("span", { className: "order-total-item-label" }, import_utils.locales.getText("pisell1.text.subtotal")), /* @__PURE__ */ import_react.default.createElement("span", { className: "order-total-item-value" }, (0, import_utils.formatAmount)(total.productAmount, 2, (state == null ? void 0 : state.amountSymbol) || "$"))),
423
- (((_f = state.bookingDetail) == null ? void 0 : _f.surcharge) || []).map((d) => {
436
+ (((_g = state.bookingDetail) == null ? void 0 : _g.surcharge) || []).map((d) => {
424
437
  return /* @__PURE__ */ import_react.default.createElement("div", { className: "order-total-item", key: d.id }, /* @__PURE__ */ import_react.default.createElement("span", { className: "order-total-item-label" }, d.name[state.locale]), /* @__PURE__ */ import_react.default.createElement("span", { className: "order-total-item-value" }, (0, import_utils.formatAmount)(d.amount, 2, (state == null ? void 0 : state.amountSymbol) || "$")));
425
438
  }),
426
439
  state.bookingId ? /* @__PURE__ */ import_react.default.createElement("div", { className: "order-total-item" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "order-total-item-label" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "" }, import_utils.locales.getText("pisell1.text.tax")), /* @__PURE__ */ import_react.default.createElement("div", { className: "", style: { fontSize: 14 } }, taxText)), /* @__PURE__ */ import_react.default.createElement("span", { className: "order-total-item-value" }, (0, import_utils.formatAmount)(total.tax, 2, (state == null ? void 0 : state.amountSymbol) || "$"))) : null,
@@ -119,7 +119,7 @@ var DateCom = () => {
119
119
  bordered: false,
120
120
  suffixIcon: !modal.state.disabledEdit ? /* @__PURE__ */ import_react.default.createElement(import_ChevronDown.default, null) : null,
121
121
  disabledDate,
122
- format: modal.state.locale === "en" ? "dddd, MM DD YYYY" : "YYYY年MM月DD日",
122
+ format: modal.state.locale === "en" ? "dddd, DD MMM YYYY" : "YYYY年MM月DD日",
123
123
  value: modal.state.date.value,
124
124
  onChange: dateChange,
125
125
  disabled: modal.state.disabledEdit
@@ -213,7 +213,7 @@ var Pet = () => {
213
213
  params.type,
214
214
  (_f = (_e = state.client) == null ? void 0 : _e.value) == null ? void 0 : _f.id
215
215
  ]);
216
- return /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-pet-wraps" }, /* @__PURE__ */ import_react.default.createElement(
216
+ return /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-lowcode__booking-pet-wraps" }, /* @__PURE__ */ import_react.default.createElement(import_antd.Skeleton, { loading, active: true, round: true }, /* @__PURE__ */ import_react.default.createElement(
217
217
  import_forms.default,
218
218
  {
219
219
  hideTitle: true,
@@ -268,6 +268,6 @@ var Pet = () => {
268
268
  },
269
269
  addButtonProps: { style: { margin: 0 } }
270
270
  }
271
- ));
271
+ )));
272
272
  };
273
273
  var pet_default = Pet;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/private-materials",
3
- "version": "3.0.22",
3
+ "version": "3.0.24",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",