@pisell/pisellos 2.2.267 → 2.2.268
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/Order/index.d.ts +6 -6
- package/dist/modules/Order/index.js +120 -76
- package/dist/modules/Order/types.d.ts +21 -3
- package/dist/modules/Order/types.js +11 -0
- package/dist/solution/BaseSales/index.d.ts +4 -4
- package/dist/solution/BaseSales/index.js +14 -14
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/types.d.ts +3 -0
- package/dist/solution/BookingTicket/utils/cartView.js +44 -32
- package/lib/modules/Order/index.d.ts +6 -6
- package/lib/modules/Order/index.js +70 -8
- package/lib/modules/Order/types.d.ts +21 -3
- package/lib/solution/BaseSales/index.d.ts +4 -4
- package/lib/solution/BaseSales/index.js +6 -6
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/types.d.ts +3 -0
- package/lib/solution/BookingTicket/utils/cartView.js +43 -30
- package/package.json +1 -1
|
@@ -86,29 +86,27 @@ function isGiftProductLine(line) {
|
|
|
86
86
|
function buildCartView(lines, bookings, options = {}) {
|
|
87
87
|
const productLines = Array.isArray(lines) ? lines : [];
|
|
88
88
|
const bookingList = Array.isArray(bookings) ? bookings : [];
|
|
89
|
+
const childBookings = bookingList.filter((booking) => booking.parent_id !== 0);
|
|
90
|
+
const bookingsByProductUid = indexBookingsByProductUid(childBookings);
|
|
89
91
|
const linesByUid = indexProductsByUid(productLines);
|
|
90
92
|
const addTimeLinesByBookingUid = indexAddTimeProductsByBookingUid(productLines);
|
|
91
|
-
const claimedUids = /* @__PURE__ */ new Set();
|
|
92
93
|
const claimedAddTimeLines = /* @__PURE__ */ new Set();
|
|
93
|
-
|
|
94
|
-
const
|
|
94
|
+
childBookings.forEach((booking) => {
|
|
95
|
+
const bookingUid = getBookingUid(booking);
|
|
96
|
+
if (!bookingUid)
|
|
97
|
+
return;
|
|
98
|
+
(addTimeLinesByBookingUid[bookingUid] || []).forEach((line) => {
|
|
99
|
+
claimedAddTimeLines.add(line);
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
const claimedBookings = /* @__PURE__ */ new Set();
|
|
103
|
+
const cartBookings = [];
|
|
104
|
+
const items = [];
|
|
105
|
+
const orderedLines = [];
|
|
106
|
+
const buildBookingView = (booking, product) => {
|
|
95
107
|
const bookingUid = getBookingUid(booking);
|
|
96
|
-
let product = null;
|
|
97
|
-
if (uid !== void 0 && uid !== null && uid !== "") {
|
|
98
|
-
const key = String(uid);
|
|
99
|
-
if (!claimedUids.has(key)) {
|
|
100
|
-
const line = linesByUid[key];
|
|
101
|
-
if (isGiftProductLine(line))
|
|
102
|
-
return acc;
|
|
103
|
-
if (line) {
|
|
104
|
-
claimedUids.add(key);
|
|
105
|
-
product = line;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
108
|
const addTimeProduct = bookingUid ? addTimeLinesByBookingUid[bookingUid] || [] : [];
|
|
110
|
-
|
|
111
|
-
acc.push({
|
|
109
|
+
return {
|
|
112
110
|
...booking,
|
|
113
111
|
_extend: {
|
|
114
112
|
product,
|
|
@@ -122,21 +120,36 @@ function buildCartView(lines, bookings, options = {}) {
|
|
|
122
120
|
shopOpeningHours: options.shopOpeningHours
|
|
123
121
|
})
|
|
124
122
|
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const items = productLines.filter((line) => {
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
productLines.forEach((line) => {
|
|
129
126
|
var _a;
|
|
130
|
-
if (isGiftProductLine(line))
|
|
131
|
-
return
|
|
132
|
-
if (claimedAddTimeLines.has(line))
|
|
133
|
-
return false;
|
|
127
|
+
if (isGiftProductLine(line) || claimedAddTimeLines.has(line))
|
|
128
|
+
return;
|
|
134
129
|
const uid = (_a = line.metadata) == null ? void 0 : _a.unique_identification_number;
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
130
|
+
const matchedBooking = uid === void 0 || uid === null || uid === "" ? void 0 : (bookingsByProductUid[String(uid)] || []).find(
|
|
131
|
+
(booking) => !claimedBookings.has(booking)
|
|
132
|
+
);
|
|
133
|
+
if (matchedBooking) {
|
|
134
|
+
claimedBookings.add(matchedBooking);
|
|
135
|
+
const bookingView = buildBookingView(matchedBooking, line);
|
|
136
|
+
cartBookings.push(bookingView);
|
|
137
|
+
orderedLines.push(bookingView);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
items.push(line);
|
|
141
|
+
orderedLines.push(line);
|
|
142
|
+
});
|
|
143
|
+
childBookings.forEach((booking) => {
|
|
144
|
+
if (claimedBookings.has(booking))
|
|
145
|
+
return;
|
|
146
|
+
const uid = booking == null ? void 0 : booking.product_uid;
|
|
147
|
+
const linkedProduct = uid === void 0 || uid === null || uid === "" ? null : linesByUid[String(uid)] || null;
|
|
148
|
+
if (isGiftProductLine(linkedProduct))
|
|
149
|
+
return;
|
|
150
|
+
cartBookings.push(buildBookingView(booking, null));
|
|
138
151
|
});
|
|
139
|
-
return { bookings: cartBookings, items };
|
|
152
|
+
return { bookings: cartBookings, items, lines: orderedLines };
|
|
140
153
|
}
|
|
141
154
|
function isWalkInCustomer(customer) {
|
|
142
155
|
if (!customer)
|