@joewinke/jatui 0.2.18 → 0.2.19
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.
|
@@ -141,8 +141,12 @@
|
|
|
141
141
|
const endDate = days[days.length - 1];
|
|
142
142
|
|
|
143
143
|
const counts = await getAvailability(startDate, endDate);
|
|
144
|
+
// AvailabilityCounts is a Map, but tolerate plain-object returns too —
|
|
145
|
+
// Object.entries(aMap) is [] and silently kills the dots.
|
|
146
|
+
const entries =
|
|
147
|
+
counts instanceof Map ? counts.entries() : Object.entries(counts ?? {});
|
|
144
148
|
const map = new Map<string, { available: number; total: number }>();
|
|
145
|
-
for (const [key, value] of
|
|
149
|
+
for (const [key, value] of entries) {
|
|
146
150
|
map.set(key, value);
|
|
147
151
|
}
|
|
148
152
|
availabilityCounts = map;
|
|
@@ -159,7 +163,9 @@
|
|
|
159
163
|
});
|
|
160
164
|
|
|
161
165
|
function getAvailabilityLevel(date: Date): 'none' | 'low' | 'medium' | 'high' | 'full' {
|
|
162
|
-
|
|
166
|
+
// Key by LOCAL calendar date — toISOString() shifts to UTC and is off by
|
|
167
|
+
// one day for positive-offset timezones (calendar days are local midnights).
|
|
168
|
+
const dateStr = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
|
|
163
169
|
const counts = availabilityCounts.get(dateStr);
|
|
164
170
|
|
|
165
171
|
if (!counts || counts.total === 0) return 'none';
|