@pisell/pisellos 2.0.23 → 2.0.25
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/dist/modules/Date/index.d.ts +2 -0
- package/dist/modules/Date/index.js +70 -34
- package/dist/modules/Rules/index.js +1 -1
- package/dist/modules/Schedule/types.d.ts +1 -0
- package/dist/solution/BookingByStep/index.d.ts +25 -4
- package/dist/solution/BookingByStep/index.js +343 -25
- package/dist/solution/BookingByStep/utils/resources.d.ts +40 -3
- package/dist/solution/BookingByStep/utils/resources.js +100 -1
- package/lib/modules/Date/index.d.ts +2 -0
- package/lib/modules/Date/index.js +23 -10
- package/lib/modules/Rules/index.js +2 -2
- package/lib/modules/Schedule/types.d.ts +1 -0
- package/lib/solution/BookingByStep/index.d.ts +25 -4
- package/lib/solution/BookingByStep/index.js +265 -32
- package/lib/solution/BookingByStep/utils/resources.d.ts +40 -3
- package/lib/solution/BookingByStep/utils/resources.js +73 -2
- package/package.json +1 -1
|
@@ -29,7 +29,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
// src/solution/BookingByStep/utils/resources.ts
|
|
30
30
|
var resources_exports = {};
|
|
31
31
|
__export(resources_exports, {
|
|
32
|
+
checkSessionProductLeadTime: () => checkSessionProductLeadTime,
|
|
32
33
|
checkSubResourcesCapacity: () => checkSubResourcesCapacity,
|
|
34
|
+
filterScheduleByDateRange: () => filterScheduleByDateRange,
|
|
33
35
|
formatDefaultCapacitys: () => formatDefaultCapacitys,
|
|
34
36
|
formatResources: () => formatResources,
|
|
35
37
|
getIsUsableByTimeItem: () => getIsUsableByTimeItem,
|
|
@@ -37,11 +39,13 @@ __export(resources_exports, {
|
|
|
37
39
|
getOthersSelectedResources: () => getOthersSelectedResources,
|
|
38
40
|
getResourcesByIds: () => getResourcesByIds,
|
|
39
41
|
getResourcesByProduct: () => getResourcesByProduct,
|
|
42
|
+
getResourcesIdsByProduct: () => getResourcesIdsByProduct,
|
|
40
43
|
getSumCapacity: () => getSumCapacity,
|
|
41
44
|
getTimeSlicesByResource: () => getTimeSlicesByResource,
|
|
42
45
|
getTimeSlicesByResources: () => getTimeSlicesByResources,
|
|
43
46
|
getTimesIntersection: () => getTimesIntersection,
|
|
44
|
-
mergeSubResourcesTimeSlices: () => mergeSubResourcesTimeSlices
|
|
47
|
+
mergeSubResourcesTimeSlices: () => mergeSubResourcesTimeSlices,
|
|
48
|
+
sortCombinedResources: () => sortCombinedResources
|
|
45
49
|
});
|
|
46
50
|
module.exports = __toCommonJS(resources_exports);
|
|
47
51
|
var import_dayjs = __toESM(require("dayjs"));
|
|
@@ -561,9 +565,74 @@ var checkSubResourcesCapacity = (resource) => {
|
|
|
561
565
|
});
|
|
562
566
|
}
|
|
563
567
|
};
|
|
568
|
+
function filterScheduleByDateRange(schedule, startDate, endDate) {
|
|
569
|
+
if (!(schedule == null ? void 0 : schedule.length))
|
|
570
|
+
return [];
|
|
571
|
+
const start = new Date(startDate);
|
|
572
|
+
const end = new Date(endDate);
|
|
573
|
+
return schedule.filter((item) => {
|
|
574
|
+
const itemDate = new Date(item.date);
|
|
575
|
+
return itemDate >= start && itemDate <= end;
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
function checkSessionProductLeadTime(product) {
|
|
579
|
+
let latestStartDate = "";
|
|
580
|
+
let earliestEndDate = "";
|
|
581
|
+
const { future_day, unit, unit_type } = product.cut_off_time;
|
|
582
|
+
if (future_day) {
|
|
583
|
+
const endDate = (0, import_dayjs.default)().add(future_day, "day");
|
|
584
|
+
if (!earliestEndDate || endDate.isBefore((0, import_dayjs.default)(earliestEndDate), "day")) {
|
|
585
|
+
earliestEndDate = endDate.format("YYYY-MM-DD");
|
|
586
|
+
}
|
|
587
|
+
} else if (future_day === 0) {
|
|
588
|
+
const endDate = (0, import_dayjs.default)();
|
|
589
|
+
if (!earliestEndDate || endDate.isBefore((0, import_dayjs.default)(earliestEndDate), "day")) {
|
|
590
|
+
earliestEndDate = endDate.format("YYYY-MM-DD");
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
if (unit && unit_type) {
|
|
594
|
+
const startDate = (0, import_dayjs.default)(
|
|
595
|
+
(0, import_dayjs.default)().add(unit, unit_type).format("YYYY-MM-DD")
|
|
596
|
+
);
|
|
597
|
+
if (!latestStartDate || startDate.isAfter((0, import_dayjs.default)(latestStartDate), "day")) {
|
|
598
|
+
latestStartDate = startDate.format("YYYY-MM-DD");
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
return {
|
|
602
|
+
latestStartDate,
|
|
603
|
+
earliestEndDate
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
function getResourcesIdsByProduct(product) {
|
|
607
|
+
var _a, _b, _c;
|
|
608
|
+
const tempResourceIds = [];
|
|
609
|
+
(_c = (_b = (_a = product == null ? void 0 : product.product_resource) == null ? void 0 : _a.resources) == null ? void 0 : _b.forEach) == null ? void 0 : _c.call(_b, (resource) => {
|
|
610
|
+
var _a2, _b2;
|
|
611
|
+
if ((resource == null ? void 0 : resource.status) == 1) {
|
|
612
|
+
if ((_a2 = resource == null ? void 0 : resource.default_resource) == null ? void 0 : _a2.length) {
|
|
613
|
+
tempResourceIds.push(...resource == null ? void 0 : resource.default_resource);
|
|
614
|
+
} else if ((_b2 = resource == null ? void 0 : resource.optional_resource) == null ? void 0 : _b2.length) {
|
|
615
|
+
tempResourceIds.push(...resource == null ? void 0 : resource.optional_resource);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
});
|
|
619
|
+
return tempResourceIds;
|
|
620
|
+
}
|
|
621
|
+
function sortCombinedResources(resourcesList) {
|
|
622
|
+
const newResourcesList = [...resourcesList];
|
|
623
|
+
newResourcesList.sort((a, b) => {
|
|
624
|
+
var _a, _b, _c, _d;
|
|
625
|
+
const aIsCombined = ((_b = (_a = a.metadata) == null ? void 0 : _a.combined_resource) == null ? void 0 : _b.status) === 1;
|
|
626
|
+
const bIsCombined = ((_d = (_c = b.metadata) == null ? void 0 : _c.combined_resource) == null ? void 0 : _d.status) === 1;
|
|
627
|
+
return aIsCombined === bIsCombined ? 0 : aIsCombined ? 1 : -1;
|
|
628
|
+
});
|
|
629
|
+
return newResourcesList;
|
|
630
|
+
}
|
|
564
631
|
// Annotate the CommonJS export names for ESM import in node:
|
|
565
632
|
0 && (module.exports = {
|
|
633
|
+
checkSessionProductLeadTime,
|
|
566
634
|
checkSubResourcesCapacity,
|
|
635
|
+
filterScheduleByDateRange,
|
|
567
636
|
formatDefaultCapacitys,
|
|
568
637
|
formatResources,
|
|
569
638
|
getIsUsableByTimeItem,
|
|
@@ -571,9 +640,11 @@ var checkSubResourcesCapacity = (resource) => {
|
|
|
571
640
|
getOthersSelectedResources,
|
|
572
641
|
getResourcesByIds,
|
|
573
642
|
getResourcesByProduct,
|
|
643
|
+
getResourcesIdsByProduct,
|
|
574
644
|
getSumCapacity,
|
|
575
645
|
getTimeSlicesByResource,
|
|
576
646
|
getTimeSlicesByResources,
|
|
577
647
|
getTimesIntersection,
|
|
578
|
-
mergeSubResourcesTimeSlices
|
|
648
|
+
mergeSubResourcesTimeSlices,
|
|
649
|
+
sortCombinedResources
|
|
579
650
|
});
|