@pisell/private-materials 3.3.72 → 3.3.73

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.
@@ -13,7 +13,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
13
13
  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; }
14
14
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
15
15
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
- import React, { useState, useEffect, useMemo, forwardRef, useImperativeHandle } from 'react';
16
+ import React, { useState, useEffect, useMemo, forwardRef, useImperativeHandle, useRef } from 'react';
17
17
  import { Skeleton } from 'antd';
18
18
  import Dayjs from 'dayjs';
19
19
  import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
@@ -29,6 +29,7 @@ import { localeTypes } from "./state";
29
29
  import "./index.less";
30
30
  var Date = /*#__PURE__*/forwardRef(function (props, ref) {
31
31
  var _context$engine2, _Dayjs$locale;
32
+ var isFetchingDates = useRef(false);
32
33
  var _useState = useState(false),
33
34
  _useState2 = _slicedToArray(_useState, 2),
34
35
  loading = _useState2[0],
@@ -223,7 +224,7 @@ var Date = /*#__PURE__*/forwardRef(function (props, ref) {
223
224
  }();
224
225
  var getDates = /*#__PURE__*/function () {
225
226
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(date) {
226
- var startDate, endDate, params, data, selected, _selected$, firstAvailableDate, baseMonthData, updatedDates;
227
+ var startDate, endDate, params, data, firstAvailableDate, nextMonthDate, selected, _selected$, baseMonthData, updatedDates;
227
228
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
228
229
  while (1) switch (_context4.prev = _context4.next) {
229
230
  case 0:
@@ -238,19 +239,29 @@ var Date = /*#__PURE__*/forwardRef(function (props, ref) {
238
239
  return getDateData(params);
239
240
  case 6:
240
241
  data = _context4.sent;
241
- _context4.next = 9;
242
+ firstAvailableDate = (data || []).find(function (d) {
243
+ return d.status === 'available';
244
+ }); // 如果当前月没有可用日期,并且这是第一次尝试,则自动查询下一个月
245
+ if (!(!firstAvailableDate && !isFetchingDates.current)) {
246
+ _context4.next = 14;
247
+ break;
248
+ }
249
+ isFetchingDates.current = true;
250
+ nextMonthDate = Dayjs(date).add(1, 'month');
251
+ setCurrentMonth(nextMonthDate);
252
+ setLoading(true);
253
+ return _context4.abrupt("return");
254
+ case 14:
255
+ _context4.next = 16;
242
256
  return appointmentBooking.getDateRange();
243
- case 9:
257
+ case 16:
244
258
  selected = _context4.sent;
245
259
  console.log(data, selected, customPageId, 'getDates');
246
260
  if ((selected === null || selected === void 0 ? void 0 : selected.length) > 0) {
247
261
  setCurrentDate(selected === null || selected === void 0 || (_selected$ = selected[0]) === null || _selected$ === void 0 ? void 0 : _selected$.date);
248
262
  } else if (!isDateSelectedFirst) {
249
263
  // 当前月则默认选中当前第一个可用的
250
- if (date.format('YYYY-MM') === Dayjs().format('YYYY-MM')) {
251
- firstAvailableDate = (data || []).find(function (d) {
252
- return d.status === 'available';
253
- });
264
+ if (date.format('YYYY-MM') === Dayjs().format('YYYY-MM') || isFetchingDates.current) {
254
265
  if (firstAvailableDate) {
255
266
  setCurrentDate(firstAvailableDate === null || firstAvailableDate === void 0 ? void 0 : firstAvailableDate.date);
256
267
  appointmentBooking.setDateRange([firstAvailableDate]);
@@ -273,19 +284,18 @@ var Date = /*#__PURE__*/forwardRef(function (props, ref) {
273
284
  });
274
285
  setLoading(false);
275
286
  setDateMonthList(updatedDates);
276
- _context4.next = 23;
287
+ _context4.next = 29;
277
288
  break;
278
- case 18:
279
- _context4.prev = 18;
289
+ case 25:
290
+ _context4.prev = 25;
280
291
  _context4.t0 = _context4["catch"](0);
281
292
  setLoading(false);
282
293
  setDateMonthList([]);
283
- console.log(_context4.t0, 'wh978968234234');
284
- case 23:
294
+ case 29:
285
295
  case "end":
286
296
  return _context4.stop();
287
297
  }
288
- }, _callee4, null, [[0, 18]]);
298
+ }, _callee4, null, [[0, 25]]);
289
299
  }));
290
300
  return function getDates(_x2) {
291
301
  return _ref4.apply(this, arguments);
@@ -33,6 +33,7 @@ import { isWalkIn as getIsWalkIn } from "../../utils";
33
33
  import { getFranchiseeCustomerInfo, getFranchiseeCustomerList } from "./serve";
34
34
  import { useMemoizedFn } from 'ahooks';
35
35
  import { getWaiverTitle } from "../clientVariant/utils";
36
+ import useGetHolderList from "../hooks/useGetHolderList";
36
37
  var isLoadClient = false;
37
38
  var Client = function Client() {
38
39
  var _state$client$value2, _state$client$value3, _state$client$value4, _state$client$value5, _state$client$value6, _state$client$value7, _state$client$value8, _state$client$value9, _state$client$value10, _state$client$value11;
@@ -52,6 +53,7 @@ var Client = function Client() {
52
53
  _useState6 = _slicedToArray(_useState5, 2),
53
54
  franchiseeLoading = _useState6[0],
54
55
  setFranchiseeLoading = _useState6[1];
56
+ var getHolders = useGetHolderList(state, dispatch);
55
57
  var _useState7 = useState({
56
58
  skip: 1,
57
59
  num: 10,
@@ -281,6 +283,7 @@ var Client = function Client() {
281
283
  if (data) {
282
284
  handleSelectClient([data]);
283
285
  }
286
+ getHolders();
284
287
  getClients(_objectSpread(_objectSpread({}, state.client.clientsParams), {}, {
285
288
  search: '',
286
289
  customer_id: data === null || data === void 0 ? void 0 : data.id,
@@ -298,14 +301,20 @@ var Client = function Client() {
298
301
  showAcceptsMarketing: false
299
302
  },
300
303
  callback: function callback(customer_id, params) {
301
- var _params$, _params$2, _state$client2;
304
+ var _state$client2, _state$client2$map, _params$, _params$2, _state$client3;
305
+ var waiverForm = ((_state$client2 = state.client) === null || _state$client2 === void 0 || (_state$client2 = _state$client2.clients) === null || _state$client2 === void 0 || (_state$client2 = _state$client2[0].waiver_form) === null || _state$client2 === void 0 || (_state$client2$map = _state$client2.map) === null || _state$client2$map === void 0 ? void 0 : _state$client2$map.call(_state$client2, function (item) {
306
+ return _objectSpread(_objectSpread({}, item), {}, {
307
+ is_filled: 0
308
+ });
309
+ })) || [];
302
310
  // 创建后本地数据处理到数组
303
311
  dispatch({
304
312
  type: 'setClient',
305
313
  payload: {
306
314
  clients: [].concat(_toConsumableArray(params !== null && params !== void 0 && (_params$ = params[0]) !== null && _params$ !== void 0 && _params$.customer ? [_objectSpread(_objectSpread({}, params === null || params === void 0 || (_params$2 = params[0]) === null || _params$2 === void 0 ? void 0 : _params$2.customer), {}, {
307
- id: customer_id
308
- })] : []), _toConsumableArray(((_state$client2 = state.client) === null || _state$client2 === void 0 ? void 0 : _state$client2.clients) || []))
315
+ id: customer_id,
316
+ waiver_form: waiverForm
317
+ })] : []), _toConsumableArray(((_state$client3 = state.client) === null || _state$client3 === void 0 ? void 0 : _state$client3.clients) || []))
309
318
  }
310
319
  });
311
320
  }
@@ -48,6 +48,7 @@ var import_index = require("./index.less");
48
48
  import_dayjs.default.extend(import_isSameOrBefore.default);
49
49
  var Date = (0, import_react.forwardRef)((props, ref) => {
50
50
  var _a, _b, _c;
51
+ const isFetchingDates = (0, import_react.useRef)(false);
51
52
  const [loading, setLoading] = (0, import_react.useState)(false);
52
53
  const [currentDate, setCurrentDate] = (0, import_react.useState)();
53
54
  const [dateMonthList, setDateMonthList] = (0, import_react.useState)([]);
@@ -139,15 +140,22 @@ var Date = (0, import_react.forwardRef)((props, ref) => {
139
140
  endDate
140
141
  };
141
142
  const data = await getDateData(params);
143
+ const firstAvailableDate = (data || []).find(
144
+ (d) => d.status === "available"
145
+ );
146
+ if (!firstAvailableDate && !isFetchingDates.current) {
147
+ isFetchingDates.current = true;
148
+ const nextMonthDate = (0, import_dayjs.default)(date).add(1, "month");
149
+ setCurrentMonth(nextMonthDate);
150
+ setLoading(true);
151
+ return;
152
+ }
142
153
  const selected = await appointmentBooking.getDateRange();
143
154
  console.log(data, selected, customPageId, "getDates");
144
155
  if ((selected == null ? void 0 : selected.length) > 0) {
145
156
  setCurrentDate((_a2 = selected == null ? void 0 : selected[0]) == null ? void 0 : _a2.date);
146
157
  } else if (!isDateSelectedFirst) {
147
- if (date.format("YYYY-MM") === (0, import_dayjs.default)().format("YYYY-MM")) {
148
- const firstAvailableDate = (data || []).find(
149
- (d) => d.status === "available"
150
- );
158
+ if (date.format("YYYY-MM") === (0, import_dayjs.default)().format("YYYY-MM") || isFetchingDates.current) {
151
159
  if (firstAvailableDate) {
152
160
  setCurrentDate(firstAvailableDate == null ? void 0 : firstAvailableDate.date);
153
161
  appointmentBooking.setDateRange([firstAvailableDate]);
@@ -171,7 +179,6 @@ var Date = (0, import_react.forwardRef)((props, ref) => {
171
179
  } catch (error) {
172
180
  setLoading(false);
173
181
  setDateMonthList([]);
174
- console.log(error, "wh978968234234");
175
182
  }
176
183
  };
177
184
  (0, import_react.useEffect)(() => {
@@ -45,6 +45,7 @@ var import_utils2 = require("../../utils");
45
45
  var import_serve = require("./serve");
46
46
  var import_ahooks = require("ahooks");
47
47
  var import_utils3 = require("../clientVariant/utils");
48
+ var import_useGetHolderList = __toESM(require("../hooks/useGetHolderList"));
48
49
  var isLoadClient = false;
49
50
  var Client = () => {
50
51
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
@@ -53,6 +54,7 @@ var Client = () => {
53
54
  const [loading, setLoading] = (0, import_react.useState)(false);
54
55
  const { state, dispatch } = (0, import_react.useContext)(import_model.Context);
55
56
  const [franchiseeLoading, setFranchiseeLoading] = (0, import_react.useState)(0);
57
+ const getHolders = (0, import_useGetHolderList.default)(state, dispatch);
56
58
  const [params, setParams] = (0, import_react.useState)({
57
59
  skip: 1,
58
60
  num: 10,
@@ -202,6 +204,7 @@ var Client = () => {
202
204
  if (data) {
203
205
  handleSelectClient([data]);
204
206
  }
207
+ getHolders();
205
208
  getClients({
206
209
  ...state.client.clientsParams,
207
210
  search: "",
@@ -220,13 +223,17 @@ var Client = () => {
220
223
  showAcceptsMarketing: false
221
224
  },
222
225
  callback: (customer_id, params2) => {
223
- var _a2, _b2, _c2;
226
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2;
227
+ const waiverForm = ((_d2 = (_c2 = (_b2 = (_a2 = state.client) == null ? void 0 : _a2.clients) == null ? void 0 : _b2[0].waiver_form) == null ? void 0 : _c2.map) == null ? void 0 : _d2.call(_c2, (item) => ({
228
+ ...item,
229
+ is_filled: 0
230
+ }))) || [];
224
231
  dispatch({
225
232
  type: "setClient",
226
233
  payload: {
227
234
  clients: [
228
- ...((_a2 = params2 == null ? void 0 : params2[0]) == null ? void 0 : _a2.customer) ? [{ ...(_b2 = params2 == null ? void 0 : params2[0]) == null ? void 0 : _b2.customer, id: customer_id }] : [],
229
- ...((_c2 = state.client) == null ? void 0 : _c2.clients) || []
235
+ ...((_e2 = params2 == null ? void 0 : params2[0]) == null ? void 0 : _e2.customer) ? [{ ...(_f2 = params2 == null ? void 0 : params2[0]) == null ? void 0 : _f2.customer, id: customer_id, waiver_form: waiverForm }] : [],
236
+ ...((_g2 = state.client) == null ? void 0 : _g2.clients) || []
230
237
  ]
231
238
  }
232
239
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/private-materials",
3
- "version": "3.3.72",
3
+ "version": "3.3.73",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -60,7 +60,7 @@
60
60
  "rc-virtual-list": "^3.11.3",
61
61
  "decimal.js": "^10.4.3",
62
62
  "@pisell/utils": "1.0.42",
63
- "@pisell/materials": "3.3.27",
63
+ "@pisell/materials": "3.3.29",
64
64
  "@pisell/icon": "0.0.11",
65
65
  "@pisell/date-picker": "3.0.2"
66
66
  },