@propbinder/mobile-design 0.2.54 → 0.2.56

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.
@@ -16659,6 +16659,8 @@ class DsMobileBookingModalComponent {
16659
16659
  confirmBookingText = 'Bekræft booking';
16660
16660
  availableDates;
16661
16661
  availableTimeSlots;
16662
+ useMockData = false;
16663
+ onSubmit;
16662
16664
  swiperComponent;
16663
16665
  // Signals for reactive state management
16664
16666
  dateOptions = signal([], ...(ngDevMode ? [{ debugName: "dateOptions" }] : []));
@@ -16672,7 +16674,9 @@ class DsMobileBookingModalComponent {
16672
16674
  }, ...(ngDevMode ? [{ debugName: "canConfirm" }] : []));
16673
16675
  constructor(modalController) {
16674
16676
  this.modalController = modalController;
16675
- this.generateMockData();
16677
+ }
16678
+ ngOnInit() {
16679
+ this.initializeData();
16676
16680
  }
16677
16681
  /**
16678
16682
  * After view init - force swiper update to fix initial positioning
@@ -16721,9 +16725,9 @@ class DsMobileBookingModalComponent {
16721
16725
  };
16722
16726
  }, ...(ngDevMode ? [{ debugName: "dateDisabledFn" }] : []));
16723
16727
  /**
16724
- * Generate mock date and time data or use provided available data
16728
+ * Initialize date and time data or optionally use mock data for testing
16725
16729
  */
16726
- generateMockData() {
16730
+ initializeData() {
16727
16731
  if (this.availableDates && this.availableDates.length > 0) {
16728
16732
  this.dateOptions.set(this.availableDates);
16729
16733
  const firstAvailableDate = this.availableDates.find(d => d.state !== 'disabled') || this.availableDates[0];
@@ -16738,11 +16742,16 @@ class DsMobileBookingModalComponent {
16738
16742
  const selectedRef = updatedDates.find(d => d.id === firstAvailableDate.id);
16739
16743
  if (selectedRef) {
16740
16744
  this.selectedDate.set(selectedRef);
16741
- this.generateTimeSlots(selectedRef.fullDate, selectedRef.date);
16745
+ this.initializeTimeSlots(selectedRef.fullDate, selectedRef.id);
16742
16746
  }
16743
16747
  }
16744
16748
  return;
16745
16749
  }
16750
+ if (!this.useMockData) {
16751
+ this.dateOptions.set([]);
16752
+ this.timeSlots.set([]);
16753
+ return;
16754
+ }
16746
16755
  const dates = [];
16747
16756
  const today = new Date();
16748
16757
  const dayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
@@ -16771,21 +16780,25 @@ class DsMobileBookingModalComponent {
16771
16780
  // Set the first available date as selected and generate time slots for it
16772
16781
  if (firstAvailableDate) {
16773
16782
  this.selectedDate.set(firstAvailableDate);
16774
- this.generateTimeSlots(firstAvailableDate.fullDate, firstAvailableDate.date);
16783
+ this.initializeTimeSlots(firstAvailableDate.fullDate, firstAvailableDate.id);
16775
16784
  }
16776
16785
  else {
16777
16786
  // Fallback to today if no available dates
16778
- this.generateTimeSlots(today);
16787
+ this.initializeTimeSlots(today);
16779
16788
  }
16780
16789
  }
16781
16790
  /**
16782
16791
  * Generate time slots based on selected date and dynamic available timeslots
16783
16792
  */
16784
- generateTimeSlots(date, dateStringKey) {
16793
+ initializeTimeSlots(date, dateStringKey) {
16785
16794
  if (this.availableTimeSlots && dateStringKey && this.availableTimeSlots[dateStringKey]) {
16786
16795
  this.timeSlots.set(this.availableTimeSlots[dateStringKey]);
16787
16796
  return;
16788
16797
  }
16798
+ if (!this.useMockData) {
16799
+ this.timeSlots.set([]);
16800
+ return;
16801
+ }
16789
16802
  const slots = [];
16790
16803
  const currentHour = new Date().getHours();
16791
16804
  const isToday = date.toDateString() === new Date().toDateString();
@@ -16824,7 +16837,7 @@ class DsMobileBookingModalComponent {
16824
16837
  this.dateOptions.set(updatedDates);
16825
16838
  this.selectedDate.set(selectedDate);
16826
16839
  // Regenerate time slots for the selected date
16827
- this.generateTimeSlots(selectedDate.fullDate, selectedDate.date);
16840
+ this.initializeTimeSlots(selectedDate.fullDate, selectedDate.id);
16828
16841
  // Reset time selection
16829
16842
  this.selectedTimeSlot.set(null);
16830
16843
  }
@@ -16868,8 +16881,6 @@ class DsMobileBookingModalComponent {
16868
16881
  return;
16869
16882
  // Set loading state
16870
16883
  this.isConfirming.set(true);
16871
- // Simulate booking API call with 2 second delay
16872
- await new Promise(resolve => setTimeout(resolve, 2000));
16873
16884
  const result = {
16874
16885
  facilityId: this.facilityId,
16875
16886
  facilityTitle: this.facilityTitle,
@@ -16877,7 +16888,20 @@ class DsMobileBookingModalComponent {
16877
16888
  selectedTimeSlot: this.selectedTimeSlot(),
16878
16889
  timestamp: new Date()
16879
16890
  };
16880
- await this.modalController.dismiss(result, 'confirm');
16891
+ try {
16892
+ if (this.onSubmit) {
16893
+ await this.onSubmit(result);
16894
+ }
16895
+ else {
16896
+ // Simulate booking API call with 2 second delay
16897
+ await new Promise(resolve => setTimeout(resolve, 2000));
16898
+ }
16899
+ await this.modalController.dismiss(result, 'confirm');
16900
+ }
16901
+ catch (e) {
16902
+ console.error('Booking confirmation failed in onSubmit hook', e);
16903
+ this.isConfirming.set(false);
16904
+ }
16881
16905
  }
16882
16906
  /**
16883
16907
  * Handle close button click
@@ -16886,7 +16910,7 @@ class DsMobileBookingModalComponent {
16886
16910
  await this.modalController.dismiss(null, 'cancel');
16887
16911
  }
16888
16912
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: DsMobileBookingModalComponent, deps: [{ token: i1.ModalController }], target: i0.ɵɵFactoryTarget.Component });
16889
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.16", type: DsMobileBookingModalComponent, isStandalone: true, selector: "ds-mobile-booking-modal", inputs: { facilityId: "facilityId", facilityTitle: "facilityTitle", daysAhead: "daysAhead", selectFromCalendarText: "selectFromCalendarText", confirmBookingText: "confirmBookingText", availableDates: "availableDates", availableTimeSlots: "availableTimeSlots" }, viewQueries: [{ propertyName: "swiperComponent", first: true, predicate: DsMobileSwiperComponent, descendants: true }], ngImport: i0, template: `
16913
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.16", type: DsMobileBookingModalComponent, isStandalone: true, selector: "ds-mobile-booking-modal", inputs: { facilityId: "facilityId", facilityTitle: "facilityTitle", daysAhead: "daysAhead", selectFromCalendarText: "selectFromCalendarText", confirmBookingText: "confirmBookingText", availableDates: "availableDates", availableTimeSlots: "availableTimeSlots", useMockData: "useMockData", onSubmit: "onSubmit" }, viewQueries: [{ propertyName: "swiperComponent", first: true, predicate: DsMobileSwiperComponent, descendants: true }], ngImport: i0, template: `
16890
16914
  <ds-mobile-modal-base
16891
16915
  headerTitle="Hvornår skal det være?"
16892
16916
  [showCloseButton]="true"
@@ -17057,6 +17081,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
17057
17081
  type: Input
17058
17082
  }], availableTimeSlots: [{
17059
17083
  type: Input
17084
+ }], useMockData: [{
17085
+ type: Input
17086
+ }], onSubmit: [{
17087
+ type: Input
17060
17088
  }], swiperComponent: [{
17061
17089
  type: ViewChild,
17062
17090
  args: [DsMobileSwiperComponent]
@@ -17301,6 +17329,10 @@ class DsMobileBookingModalService extends BaseModalService {
17301
17329
  componentProps.availableDates = options.availableDates;
17302
17330
  if (options.availableTimeSlots !== undefined)
17303
17331
  componentProps.availableTimeSlots = options.availableTimeSlots;
17332
+ if (options.useMockData !== undefined)
17333
+ componentProps.useMockData = options.useMockData;
17334
+ if (options.onSubmit !== undefined)
17335
+ componentProps.onSubmit = options.onSubmit;
17304
17336
  if (options.labels?.selectFromCalendar)
17305
17337
  componentProps.selectFromCalendarText = options.labels.selectFromCalendar;
17306
17338
  if (options.labels?.confirmBooking)
@@ -19167,7 +19199,8 @@ class DsMobileFacilityDetailModalComponent {
19167
19199
  facilityTitle: this.facilityData.facilityTitle,
19168
19200
  facilityThumbnail: this.facilityData.heroImage,
19169
19201
  availableDates: this.facilityData.availableDates,
19170
- availableTimeSlots: this.facilityData.availableTimeSlots
19202
+ availableTimeSlots: this.facilityData.availableTimeSlots,
19203
+ useMockData: this.facilityData.useMockData
19171
19204
  });
19172
19205
  }
19173
19206
  /**
@@ -25059,7 +25092,8 @@ class MobileBookingPageComponent {
25059
25092
  availabilityStatus: facility.availabilityStatus,
25060
25093
  statusLabel: facility.statusLabel,
25061
25094
  bookingDate: facility.bookingDate,
25062
- bookingTime: facility.bookingTime
25095
+ bookingTime: facility.bookingTime,
25096
+ useMockData: true // Aktivér mock data til lokal test
25063
25097
  });
25064
25098
  }
25065
25099
  }