@ticketboothapp/booking 1.2.182 → 1.2.184

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.182",
3
+ "version": "1.2.184",
4
4
  "private": false,
5
5
  "sideEffects": [
6
6
  "**/*.css",
@@ -1,5 +1,6 @@
1
1
  export interface BookingData {
2
2
  bookingReference: string;
3
+ pricingProfileId?: string | null;
3
4
  reservationReference?: string | null;
4
5
  dateTime?: string | null;
5
6
  totalAmount?: number | null;
@@ -428,6 +428,7 @@ export default function ChangeBookingDialog({
428
428
  currency={receiptCurrency}
429
429
  contentRef={contentRef}
430
430
  bookingSourceAttribution={bookingSourceAttribution}
431
+ availabilityPricingProfileId={booking.pricingProfileId ?? null}
431
432
  onSuccess={() => {
432
433
  onChangeCompleted?.(newBookingPreview);
433
434
  onClose();
@@ -183,7 +183,11 @@ export function useStandardBookingAvailability({
183
183
  const fetchedRangesRef = useRef<DateRange[]>([]);
184
184
  const pendingRangeRef = useRef<DateRange | null>(null);
185
185
  const selectedDateHydrationInFlightKeyRef = useRef<string | null>(null);
186
+ const selectedAvailabilityRef = useRef<Availability | null>(null);
187
+ const selectedReturnOptionRef = useRef<ReturnOption | null>(null);
186
188
  const lastVisibleRangeRef = useRef<DateRange | null>(null);
189
+ selectedAvailabilityRef.current = selectedAvailability;
190
+ selectedReturnOptionRef.current = selectedReturnOption;
187
191
  const activeOptionsLength = activeOptions.length;
188
192
  const pricingProfileResolutionDate = selectedDate || (visibleRange
189
193
  ? formatInTimeZone(visibleRange.start, companyTimezone, 'yyyy-MM-dd')
@@ -694,8 +698,6 @@ export function useStandardBookingAvailability({
694
698
  if (!selectedAvailability) return;
695
699
  if (!availabilityMatchesSelectedDate(selectedAvailability, selectedDate, companyTimezone)) return;
696
700
  if (selectedAvailability.isSummary !== true) return;
697
- const selectionToHydrate = selectedAvailability;
698
-
699
701
  const hydrationKey = [
700
702
  product.productId,
701
703
  selectedDate,
@@ -707,7 +709,6 @@ export function useStandardBookingAvailability({
707
709
  if (selectedDateHydrationInFlightKeyRef.current === hydrationKey) return;
708
710
  selectedDateHydrationInFlightKeyRef.current = hydrationKey;
709
711
 
710
- let cancelled = false;
711
712
  async function hydrateSelectedDateDetails() {
712
713
  setIsFetchingMoreAvailabilities(true);
713
714
  try {
@@ -725,6 +726,10 @@ export function useStandardBookingAvailability({
725
726
  ? { cancellationPolicyProfileId: cancellationPolicyProfileIdForAvailabilities }
726
727
  : {}),
727
728
  });
729
+ // Dependency changes (for example, the default return being selected) can rerun this
730
+ // effect while the request is in flight. Keep that same request authoritative instead
731
+ // of discarding its result and leaving the UI stuck on "Confirming availability".
732
+ if (selectedDateHydrationInFlightKeyRef.current !== hydrationKey) return;
728
733
  const results = [{
729
734
  optionId: product.productId,
730
735
  availabilities: result.availabilities.map((availability) => availabilityWithOptionId(availability)),
@@ -732,8 +737,6 @@ export function useStandardBookingAvailability({
732
737
  precomputedPricesByOption: result.precomputedPricesByOption,
733
738
  pricingConfig: result.pricingConfig,
734
739
  }];
735
- if (cancelled) return;
736
-
737
740
  const detailedAvailabilities = results.flatMap((fetchResult) => fetchResult.availabilities);
738
741
  if (detailedAvailabilities.length === 0) return;
739
742
 
@@ -742,12 +745,14 @@ export function useStandardBookingAvailability({
742
745
  mergePrecomputedPrices(results);
743
746
  mergeFetchedAvailabilities(detailedAvailabilities);
744
747
 
748
+ const selectionToHydrate = selectedAvailabilityRef.current;
745
749
  const updatedSelection = findMergedAvailabilityForSelection(detailedAvailabilities, selectionToHydrate);
746
- if (updatedSelection && shouldSyncSelectedAvailability(selectionToHydrate, updatedSelection)) {
750
+ if (selectionToHydrate && updatedSelection && shouldSyncSelectedAvailability(selectionToHydrate, updatedSelection)) {
747
751
  setSelectedAvailability(updatedSelection);
748
- if (selectedReturnOption && updatedSelection.returnOptions) {
752
+ const selectedReturnOptionForHydration = selectedReturnOptionRef.current;
753
+ if (selectedReturnOptionForHydration && updatedSelection.returnOptions) {
749
754
  const updatedReturnOption = updatedSelection.returnOptions.find(
750
- (option) => option.returnAvailabilityId === selectedReturnOption.returnAvailabilityId,
755
+ (option) => option.returnAvailabilityId === selectedReturnOptionForHydration.returnAvailabilityId,
751
756
  );
752
757
  if (updatedReturnOption) setSelectedReturnOption(updatedReturnOption);
753
758
  }
@@ -755,21 +760,18 @@ export function useStandardBookingAvailability({
755
760
 
756
761
  updateCache(detailedAvailabilities, results, undefined, firstPricingConfig);
757
762
  } catch (err) {
758
- if (!cancelled) {
763
+ if (selectedDateHydrationInFlightKeyRef.current === hydrationKey) {
759
764
  console.error('Error hydrating availability details:', err);
760
765
  }
761
766
  } finally {
762
767
  if (selectedDateHydrationInFlightKeyRef.current === hydrationKey) {
763
768
  selectedDateHydrationInFlightKeyRef.current = null;
769
+ setIsFetchingMoreAvailabilities(false);
764
770
  }
765
- if (!cancelled) setIsFetchingMoreAvailabilities(false);
766
771
  }
767
772
  }
768
773
 
769
774
  hydrateSelectedDateDetails();
770
- return () => {
771
- cancelled = true;
772
- };
773
775
  }, [
774
776
  activeOptionIdsKey,
775
777
  activeOptionsLength,
@@ -784,7 +786,6 @@ export function useStandardBookingAvailability({
784
786
  product.productId,
785
787
  selectedAvailability,
786
788
  selectedDate,
787
- selectedReturnOption,
788
789
  updateCache,
789
790
  ]);
790
791