@pisell/private-materials 3.0.106 → 3.0.108

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.
@@ -4,7 +4,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
4
4
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
5
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
6
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
- import React, { useEffect, useContext } from "react";
7
+ import React, { useEffect, useContext } from 'react';
8
8
  import { Provider, Context } from "./model";
9
9
  import Info from "./info";
10
10
  import Notes from "./notes";
@@ -17,7 +17,7 @@ var Booking = Provider(function () {
17
17
  useEffect(function () {}, []);
18
18
  var setState = function setState(payload) {
19
19
  dispatch({
20
- type: "setState",
20
+ type: 'setState',
21
21
  payload: _objectSpread({}, payload)
22
22
  });
23
23
  };
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { FormState } from "../model";
2
+ import { FormState } from '../model';
3
3
  export declare const walkInData: {
4
4
  id: number;
5
5
  nickname: string;
@@ -4,14 +4,15 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
4
4
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
5
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
6
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
- import { miniRedux } from "@pisell/utils";
7
+ import { miniRedux } from '@pisell/utils';
8
+ import { formatServiceListByTime } from "./utils";
8
9
  export var walkInData = {
9
10
  id: 1,
10
- nickname: "Select a customer"
11
+ nickname: 'Select a customer'
11
12
  };
12
13
  var defaultState = {};
13
14
  var _miniRedux = miniRedux({
14
- namespace: "state",
15
+ namespace: 'state',
15
16
  state: defaultState,
16
17
  reducers: {
17
18
  setStateFn: function setStateFn(state, payload) {
@@ -27,8 +28,14 @@ var _miniRedux = miniRedux({
27
28
  // return { ...state, client: { ...state.client, ...payload } };
28
29
  },
29
30
  setService: function setService(state, payload) {
31
+ var obj = {};
32
+
33
+ // 拦截, 如果服务列表里 有两个相近时间的服务, 删除最后一个
34
+ if (payload.value) {
35
+ obj.value = formatServiceListByTime(payload.value);
36
+ }
30
37
  state.setGlobalState({
31
- service: _objectSpread(_objectSpread({}, state.service), payload)
38
+ service: _objectSpread(_objectSpread(_objectSpread({}, state.service), payload), obj)
32
39
  });
33
40
  },
34
41
  setDate: function setDate(state, payload) {
@@ -58,7 +65,7 @@ var _miniRedux = miniRedux({
58
65
  var _val = {
59
66
  appointment_status: payload
60
67
  };
61
- if (payload === "cancelled") {
68
+ if (payload === 'cancelled') {
62
69
  _val.disabledEdit = true;
63
70
  } else {
64
71
  _val.disabledEdit = false;
@@ -34,7 +34,6 @@ import { getErrorList, getServiceTimes, deleteCacheParams } from "../../../utils
34
34
  import Like from "../like";
35
35
  import { getNoResource } from "../../../mock";
36
36
  import { formatResources, getDurationProps, getFlexibleOption, getTimeObj } from "../addService/utils";
37
- import { checkProductByTime } from "../../utils";
38
37
  var submitLock = false;
39
38
  var Info = function Info() {
40
39
  var _state$bookingConfig2, _state$bookingConfig3, _state$bookingConfig4, _state$service$cacheI6, _state$service3, _state$service3$cache, _state$service5, _state$service5$cache, _state$service5$cache2, _state$service5$cache3, _window$BaseMaterials, _state$service$cacheI7, _state$service6, _state$service6$cache, _state$service6$cache2, _state$service$cacheI8, _state$service$cacheI9, _state$service$cacheI10, _state$service$cacheI11, _state$bookingConfig5, _state$bookingConfig6, _state$bookingConfig7, _state$bookingConfig8;
@@ -378,10 +377,7 @@ var Info = function Info() {
378
377
  if (!_list.some(function (d) {
379
378
  return d._id === _id;
380
379
  })) {
381
- // 检查列表最后的商品添加时间是否在指定间隔内 如果在 则不添加新商品
382
- if (checkProductByTime(_list)) {
383
- _list.push(_item);
384
- }
380
+ _list.push(_item);
385
381
  } else {
386
382
  _list = _list.map(function (d) {
387
383
  return d._id === _id ? _objectSpread(_objectSpread({}, _item), {}, {
@@ -1,13 +1,5 @@
1
1
  export declare const getIsBundleOrCombination: (productDetail: any) => boolean;
2
2
  export declare const uniqueByField: (arr: any[], field: string) => any[];
3
3
  export declare const moveItemToFront: (arr: any[], targetId: string | number) => any[];
4
- /**
5
- * @title: 检查列表最后的商品添加时间是否在指定间隔内
6
- * @description:
7
- * @param {any} list
8
- * @param {number} interval
9
- * @return {*}
10
- * @Author: zhiwei.Wang
11
- * @Date: 2024-08-13 18:35
12
- */
13
- export declare const checkProductByTime: (list: any[], interval?: number) => boolean;
4
+ export declare const isInterval: (time1: number, time2: number, interval?: number) => boolean;
5
+ export declare const formatServiceListByTime: (list: any[]) => any[];
@@ -1,3 +1,9 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
1
7
  // 商品是套餐或单规格多规格
2
8
  export var getIsBundleOrCombination = function getIsBundleOrCombination(productDetail) {
3
9
  var _productDetail$bundle;
@@ -29,28 +35,28 @@ export var moveItemToFront = function moveItemToFront(arr, targetId) {
29
35
  }
30
36
  return arr;
31
37
  };
32
-
33
- /**
34
- * @title: 检查列表最后的商品添加时间是否在指定间隔内
35
- * @description:
36
- * @param {any} list
37
- * @param {number} interval
38
- * @return {*}
39
- * @Author: zhiwei.Wang
40
- * @Date: 2024-08-13 18:35
41
- */
42
- export var checkProductByTime = function checkProductByTime(list) {
43
- var interval = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
44
- var bol = true;
38
+ export var isInterval = function isInterval(time1, time2) {
39
+ var interval = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1000;
40
+ return time2 - time1 < interval;
41
+ };
42
+ export var formatServiceListByTime = function formatServiceListByTime(list) {
45
43
  try {
46
- if (list.length) {
47
- var _list;
48
- var last = (_list = list[list.length - 1]) === null || _list === void 0 ? void 0 : _list._time;
49
- var currentTime = new Date().getTime();
50
- if (last && currentTime - last < interval) {
51
- bol = false;
44
+ var _list = _toConsumableArray(list);
45
+ var length = _list.length;
46
+ if (length > 1) {
47
+ var _list2, _list3;
48
+ var start = (_list2 = _list[length - 2]) === null || _list2 === void 0 ? void 0 : _list2._time;
49
+ var end = (_list3 = _list[length - 1]) === null || _list3 === void 0 ? void 0 : _list3._time;
50
+ if (start && end && isInterval(start, end)) {
51
+ _list.pop();
52
+ return _list;
53
+ } else {
54
+ return list;
52
55
  }
56
+ } else {
57
+ return list;
53
58
  }
54
- } catch (err) {}
55
- return bol;
59
+ } catch (err) {
60
+ return list;
61
+ }
56
62
  };
@@ -149,7 +149,7 @@ export var getServiceTime = function getServiceTime(item, currentDate) {
149
149
  var startTime = startDate.format("HH:mm");
150
150
  var endTime = startDate.add(flexibleObj.getValue(item._extend.duration), "minute").format("HH:mm");
151
151
  var duration = getDiscountTime(flexibleObj.getValue(item._extend.duration));
152
- return "".concat(startTime, " - ").concat(endTime, " (").concat(duration, ")");
152
+ return "".concat(startTime, " - ").concat(endTime, " ( ").concat(duration, " )");
153
153
  };
154
154
  export var findNextSlice = function findNextSlice(_ref) {
155
155
  var _ref$timeSlices = _ref.timeSlices,
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { FormState } from "../model";
2
+ import { FormState } from '../model';
3
3
  export declare const walkInData: {
4
4
  id: number;
5
5
  nickname: string;
@@ -25,6 +25,7 @@ __export(model_exports, {
25
25
  });
26
26
  module.exports = __toCommonJS(model_exports);
27
27
  var import_utils = require("@pisell/utils");
28
+ var import_utils2 = require("./utils");
28
29
  var walkInData = {
29
30
  id: 1,
30
31
  nickname: "Select a customer"
@@ -44,7 +45,13 @@ var { Provider, Context } = (0, import_utils.miniRedux)({
44
45
  state.setGlobalState({ client: { ...state.client, ...payload } });
45
46
  },
46
47
  setService(state, payload) {
47
- state.setGlobalState({ service: { ...state.service, ...payload } });
48
+ let obj = {};
49
+ if (payload.value) {
50
+ obj.value = (0, import_utils2.formatServiceListByTime)(payload.value);
51
+ }
52
+ state.setGlobalState({
53
+ service: { ...state.service, ...payload, ...obj }
54
+ });
48
55
  },
49
56
  setDate(state, payload) {
50
57
  state.setGlobalState({ date: { ...state.date, ...payload } });
@@ -47,7 +47,6 @@ var import_utils3 = require("../../../utils");
47
47
  var import_like = __toESM(require("../like"));
48
48
  var import_mock = require("../../../mock");
49
49
  var import_utils4 = require("../addService/utils");
50
- var import_utils5 = require("../../utils");
51
50
  var submitLock = false;
52
51
  var Info = () => {
53
52
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
@@ -247,9 +246,7 @@ var Info = () => {
247
246
  _item._time = (/* @__PURE__ */ new Date()).getTime();
248
247
  let _id = _item == null ? void 0 : _item._id;
249
248
  if (!_list.some((d) => d._id === _id)) {
250
- if ((0, import_utils5.checkProductByTime)(_list)) {
251
- _list.push(_item);
252
- }
249
+ _list.push(_item);
253
250
  } else {
254
251
  _list = _list.map((d) => d._id === _id ? { ..._item, new: 0 } : d);
255
252
  }
@@ -1,13 +1,5 @@
1
1
  export declare const getIsBundleOrCombination: (productDetail: any) => boolean;
2
2
  export declare const uniqueByField: (arr: any[], field: string) => any[];
3
3
  export declare const moveItemToFront: (arr: any[], targetId: string | number) => any[];
4
- /**
5
- * @title: 检查列表最后的商品添加时间是否在指定间隔内
6
- * @description:
7
- * @param {any} list
8
- * @param {number} interval
9
- * @return {*}
10
- * @Author: zhiwei.Wang
11
- * @Date: 2024-08-13 18:35
12
- */
13
- export declare const checkProductByTime: (list: any[], interval?: number) => boolean;
4
+ export declare const isInterval: (time1: number, time2: number, interval?: number) => boolean;
5
+ export declare const formatServiceListByTime: (list: any[]) => any[];
@@ -19,8 +19,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // src/components/booking/info/utils.ts
20
20
  var utils_exports = {};
21
21
  __export(utils_exports, {
22
- checkProductByTime: () => checkProductByTime,
22
+ formatServiceListByTime: () => formatServiceListByTime,
23
23
  getIsBundleOrCombination: () => getIsBundleOrCombination,
24
+ isInterval: () => isInterval,
24
25
  moveItemToFront: () => moveItemToFront,
25
26
  uniqueByField: () => uniqueByField
26
27
  });
@@ -53,25 +54,35 @@ var moveItemToFront = (arr, targetId) => {
53
54
  }
54
55
  return arr;
55
56
  };
56
- var checkProductByTime = (list, interval = 1e3) => {
57
- var _a;
58
- let bol = true;
57
+ var isInterval = (time1, time2, interval = 1e3) => {
58
+ return time2 - time1 < interval;
59
+ };
60
+ var formatServiceListByTime = (list) => {
61
+ var _a, _b;
59
62
  try {
60
- if (list.length) {
61
- let last = (_a = list[list.length - 1]) == null ? void 0 : _a._time;
62
- let currentTime = (/* @__PURE__ */ new Date()).getTime();
63
- if (last && currentTime - last < interval) {
64
- bol = false;
63
+ let _list = [...list];
64
+ const length = _list.length;
65
+ if (length > 1) {
66
+ let start = (_a = _list[length - 2]) == null ? void 0 : _a._time;
67
+ let end = (_b = _list[length - 1]) == null ? void 0 : _b._time;
68
+ if (start && end && isInterval(start, end)) {
69
+ _list.pop();
70
+ return _list;
71
+ } else {
72
+ return list;
65
73
  }
74
+ } else {
75
+ return list;
66
76
  }
67
77
  } catch (err) {
78
+ return list;
68
79
  }
69
- return bol;
70
80
  };
71
81
  // Annotate the CommonJS export names for ESM import in node:
72
82
  0 && (module.exports = {
73
- checkProductByTime,
83
+ formatServiceListByTime,
74
84
  getIsBundleOrCombination,
85
+ isInterval,
75
86
  moveItemToFront,
76
87
  uniqueByField
77
88
  });
@@ -139,7 +139,7 @@ var getServiceTime = (item, currentDate) => {
139
139
  const startTime = startDate.format("HH:mm");
140
140
  const endTime = startDate.add(flexibleObj.getValue(item._extend.duration), "minute").format("HH:mm");
141
141
  const duration = getDiscountTime(flexibleObj.getValue(item._extend.duration));
142
- return `${startTime} - ${endTime} (${duration})`;
142
+ return `${startTime} - ${endTime} ( ${duration} )`;
143
143
  };
144
144
  var findNextSlice = ({
145
145
  timeSlices = [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/private-materials",
3
- "version": "3.0.106",
3
+ "version": "3.0.108",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -59,9 +59,9 @@
59
59
  "react-infinite-scroll-component": "^6.1.0",
60
60
  "rc-virtual-list": "^3.11.3",
61
61
  "decimal.js": "^10.4.3",
62
- "@pisell/icon": "0.0.11",
62
+ "@pisell/utils": "1.0.27",
63
63
  "@pisell/date-picker": "1.0.91",
64
- "@pisell/utils": "1.0.27"
64
+ "@pisell/icon": "0.0.11"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "react": "^18.0.0",