@idkwebsites/components 0.1.15 → 0.1.16
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/index.cjs +14 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1503,7 +1503,19 @@ function BookingWidget({
|
|
|
1503
1503
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "idk-availability__slots", children: (() => {
|
|
1504
1504
|
const activeEntry = selectedDate ? availability.data.dates.find((entry) => entry.date === selectedDate) : availability.data.dates[0];
|
|
1505
1505
|
if (!activeEntry) return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "idk-state", children: "Select a date to see times." });
|
|
1506
|
-
const
|
|
1506
|
+
const availableSlots = (activeEntry.slots || []).filter((slot) => slot.available).sort((a, b) => {
|
|
1507
|
+
const aTime = parseDateTime(a.time, activeEntry.date)?.getTime() ?? Number.POSITIVE_INFINITY;
|
|
1508
|
+
const bTime = parseDateTime(b.time, activeEntry.date)?.getTime() ?? Number.POSITIVE_INFINITY;
|
|
1509
|
+
if (aTime === bTime) {
|
|
1510
|
+
const aEnd = parseDateTime(a.endTime, activeEntry.date)?.getTime() ?? Number.POSITIVE_INFINITY;
|
|
1511
|
+
const bEnd = parseDateTime(b.endTime, activeEntry.date)?.getTime() ?? Number.POSITIVE_INFINITY;
|
|
1512
|
+
return aEnd - bEnd;
|
|
1513
|
+
}
|
|
1514
|
+
return aTime - bTime;
|
|
1515
|
+
});
|
|
1516
|
+
const slots = availableSlots.filter(
|
|
1517
|
+
(slot, index) => index === 0 || slot.time !== availableSlots[index - 1].time || slot.endTime !== availableSlots[index - 1].endTime
|
|
1518
|
+
);
|
|
1507
1519
|
if (slots.length === 0) {
|
|
1508
1520
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "idk-state", children: "No available times for this date." });
|
|
1509
1521
|
}
|
|
@@ -1511,7 +1523,7 @@ function BookingWidget({
|
|
|
1511
1523
|
"button",
|
|
1512
1524
|
{
|
|
1513
1525
|
type: "button",
|
|
1514
|
-
className: slot.time === selectedTime ? "is-active" : void 0,
|
|
1526
|
+
className: slot.time === selectedTime && slot.endTime === selectedEndTime ? "is-active" : void 0,
|
|
1515
1527
|
onClick: () => {
|
|
1516
1528
|
const date = selectedDate || activeEntry.date;
|
|
1517
1529
|
setSelectedDate(date || null);
|