@ticketboothapp/booking 1.2.110 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ticketboothapp/booking",
3
- "version": "1.2.110",
3
+ "version": "1.2.112",
4
4
  "private": false,
5
5
  "sideEffects": [
6
6
  "**/*.css",
@@ -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
- if (earliestDate) {
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
- const dateStr = formatInTimeZone(earliestDate, timezone, 'yyyy-MM-dd');
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 when unset (anchor at season open for fast first paint).
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 initialEnd = addWeeks(EARLIEST_AVAILABILITY_DATE, INITIAL_FETCH_WEEKS + VISIBLE_RANGE_BUFFER_WEEKS);
935
- setVisibleRange({ start: EARLIEST_AVAILABILITY_DATE, end: initialEnd });
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(() => {
@@ -1681,16 +1681,15 @@ export function PrivateShuttleBookingFlow({
1681
1681
  },
1682
1682
  ]
1683
1683
  : []),
1684
- ...(taxAmount > 0
1684
+ ...(effectiveTaxAmount > 0
1685
1685
  ? [
1686
1686
  {
1687
1687
  label: t('booking.tax') !== 'booking.tax' ? t('booking.tax') : 'Taxes and fees',
1688
- amount: taxAmount,
1688
+ amount: effectiveTaxAmount,
1689
1689
  type: 'TAX' as const,
1690
1690
  },
1691
1691
  ]
1692
1692
  : []),
1693
- ...(effectiveTaxAmount > 0 ? [{ label: 'GST', amount: effectiveTaxAmount, type: 'TAX' as const }] : []),
1694
1693
  ];
1695
1694
  const receiptTotal = depositInfo ? depositInfo.totalPrice : totalPrice;
1696
1695
  const linesWithPromo = [