@ticketboothapp/booking 1.2.111 → 1.2.112
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/package.json
CHANGED
|
@@ -163,6 +163,13 @@ function parseAvailabilityDateTime(value: string): Date {
|
|
|
163
163
|
return parseISO(hasExplicitOffset ? value : `${value}Z`);
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
+
function getInitialVisibleDateStr(earliestDate: Date | null, timezone: string): string {
|
|
167
|
+
const todayStr = formatInTimeZone(new Date(), timezone, 'yyyy-MM-dd');
|
|
168
|
+
if (!earliestDate) return todayStr;
|
|
169
|
+
const earliestDateStr = formatInTimeZone(earliestDate, timezone, 'yyyy-MM-dd');
|
|
170
|
+
return todayStr > earliestDateStr ? todayStr : earliestDateStr;
|
|
171
|
+
}
|
|
172
|
+
|
|
166
173
|
// ============ Date Cell Component ============
|
|
167
174
|
|
|
168
175
|
interface DateCellProps {
|
|
@@ -476,19 +483,13 @@ export function Calendar({
|
|
|
476
483
|
const hasInitializedRef = useRef(false);
|
|
477
484
|
const [currentStartDateStr, setCurrentStartDateStr] = useState(() => {
|
|
478
485
|
hasInitializedRef.current = true;
|
|
479
|
-
|
|
480
|
-
const dateStr = formatInTimeZone(earliestDate, timezone, 'yyyy-MM-dd');
|
|
481
|
-
return getSundayOfWeek(dateStr, timezone);
|
|
482
|
-
}
|
|
483
|
-
const nowStr = formatInTimeZone(new Date(), timezone, 'yyyy-MM-dd');
|
|
484
|
-
return getSundayOfWeek(nowStr, timezone);
|
|
486
|
+
return getSundayOfWeek(getInitialVisibleDateStr(earliestDate, timezone), timezone);
|
|
485
487
|
});
|
|
486
488
|
|
|
487
489
|
// Only update if earliestDate changes AND we haven't initialized yet
|
|
488
490
|
useEffect(() => {
|
|
489
491
|
if (!hasInitializedRef.current && earliestDate) {
|
|
490
|
-
|
|
491
|
-
setCurrentStartDateStr(getSundayOfWeek(dateStr, timezone));
|
|
492
|
+
setCurrentStartDateStr(getSundayOfWeek(getInitialVisibleDateStr(earliestDate, timezone), timezone));
|
|
492
493
|
hasInitializedRef.current = true;
|
|
493
494
|
}
|
|
494
495
|
}, [earliestDate, timezone]);
|
|
@@ -406,6 +406,20 @@ function parseAvailabilityDateTime(value: string): Date {
|
|
|
406
406
|
return parseISO(hasExplicitOffset ? value : `${value}Z`);
|
|
407
407
|
}
|
|
408
408
|
|
|
409
|
+
function getInitialAvailabilityRangeStart(companyTimezone: string): Date {
|
|
410
|
+
const todayStr = formatInTimeZone(new Date(), companyTimezone, 'yyyy-MM-dd');
|
|
411
|
+
const seasonStartStr = formatInTimeZone(EARLIEST_AVAILABILITY_DATE, companyTimezone, 'yyyy-MM-dd');
|
|
412
|
+
const seasonEndStr = formatInTimeZone(LATEST_AVAILABILITY_DATE, companyTimezone, 'yyyy-MM-dd');
|
|
413
|
+
const initialDateStr =
|
|
414
|
+
todayStr < seasonStartStr
|
|
415
|
+
? seasonStartStr
|
|
416
|
+
: todayStr > seasonEndStr
|
|
417
|
+
? seasonStartStr
|
|
418
|
+
: todayStr;
|
|
419
|
+
|
|
420
|
+
return fromZonedTime(parseISO(`${initialDateStr}T00:00:00.000`), companyTimezone);
|
|
421
|
+
}
|
|
422
|
+
|
|
409
423
|
function deriveDefaultQuantitiesFromAvailabilities(
|
|
410
424
|
availabilities: Availability[]
|
|
411
425
|
): Record<string, number> | null {
|
|
@@ -928,13 +942,14 @@ export function NewBookingFlow({
|
|
|
928
942
|
activeOptionIdsKey,
|
|
929
943
|
]);
|
|
930
944
|
|
|
931
|
-
// Initialize visible range
|
|
945
|
+
// Initialize visible range around today during the season, falling back to season open outside it.
|
|
932
946
|
useEffect(() => {
|
|
933
947
|
if (!visibleRange) {
|
|
934
|
-
const
|
|
935
|
-
|
|
948
|
+
const initialStart = getInitialAvailabilityRangeStart(companyTimezone);
|
|
949
|
+
const initialEnd = addWeeks(initialStart, INITIAL_FETCH_WEEKS + VISIBLE_RANGE_BUFFER_WEEKS);
|
|
950
|
+
setVisibleRange({ start: initialStart, end: initialEnd });
|
|
936
951
|
}
|
|
937
|
-
}, [visibleRange]);
|
|
952
|
+
}, [companyTimezone, visibleRange]);
|
|
938
953
|
|
|
939
954
|
// Fetch availabilities for visible range + buffer
|
|
940
955
|
useEffect(() => {
|