@bailierich/booking-components 2.1.2 → 2.1.4

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.
@@ -469,6 +469,7 @@ export function BookingFlow({
469
469
  onDateSelect(date);
470
470
  }
471
471
  }}
472
+ isPreview={isPreview}
472
473
  cyclePhases={cyclePhases} // NEW: Pass cycle phases for cycle-aware booking
473
474
  selectedService={selectedServiceData} // NEW: Pass selected service for summary card
474
475
  addons={addons} // NEW: Pass addons for selection
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import { useState, useMemo } from 'react';
3
+ import { useState, useMemo, useEffect } from 'react';
4
4
  import { motion } from 'framer-motion';
5
5
  import { ChevronLeft, ChevronRight } from 'lucide-react';
6
6
  import type { DateSelectionSettings } from '../../../types';
@@ -16,6 +16,7 @@ interface DateSelectionProps {
16
16
  secondary: string;
17
17
  };
18
18
  cyclePhases?: Record<string, string>; // Map of date -> phase ('avoid', 'caution', 'optimal', 'neutral')
19
+ isPreview?: boolean; // true = admin preview with mock dates, false/undefined = live mode
19
20
  selectedService?: any; // Selected service object with name, price, description, duration
20
21
  addons?: any[]; // Available addons
21
22
  selectedAddons?: string[]; // Selected addon IDs
@@ -68,6 +69,7 @@ export function DateSelection({
68
69
  settings,
69
70
  colors,
70
71
  cyclePhases,
72
+ isPreview,
71
73
  selectedService,
72
74
  addons = [],
73
75
  selectedAddons = [],
@@ -87,12 +89,14 @@ export function DateSelection({
87
89
  const calendarView = settings.calendarView || 'month';
88
90
  const headerText = settings.headerContent?.value || 'Select a Date';
89
91
 
90
- // Detect preview mode vs live mode
91
- const isPreviewMode = !availableDates || availableDates.length === 0;
92
+ // Preview mode: admin studio shows mock dates. Live mode: show real dates or loading.
93
+ const isPreviewMode = isPreview === true;
94
+ const isLoadingDates = !isPreview && (!availableDates || availableDates.length === 0);
92
95
 
93
- // Use mock dates in preview mode, real dates in live mode
96
+ // Use mock dates only in preview mode, otherwise use real dates
94
97
  const effectiveDates = useMemo(() => {
95
- return isPreviewMode ? generateMockDates() : availableDates;
98
+ if (isPreviewMode) return generateMockDates();
99
+ return availableDates || [];
96
100
  }, [isPreviewMode, availableDates]);
97
101
 
98
102
  // Determine initial month from first available date (today or later)
@@ -119,6 +123,11 @@ export function DateSelection({
119
123
 
120
124
  const [currentMonth, setCurrentMonth] = useState(initialMonth);
121
125
 
126
+ // Reset calendar month when dates transition from mock to real (or vice versa)
127
+ useEffect(() => {
128
+ setCurrentMonth(initialMonth);
129
+ }, [initialMonth]);
130
+
122
131
  // Create a Set for O(1) lookup of available dates
123
132
  const availableDatesSet = useMemo(() => new Set(effectiveDates), [effectiveDates]);
124
133
 
@@ -370,7 +379,27 @@ export function DateSelection({
370
379
  </motion.div>
371
380
  )}
372
381
 
373
- {calendarView === 'month' ? (
382
+ {isLoadingDates ? (
383
+ <div className="space-y-4 animate-pulse">
384
+ <div className="border border-gray-200 rounded-lg p-4">
385
+ <div className="flex items-center justify-between mb-4">
386
+ <div className="h-4 w-4 rounded" style={{ backgroundColor: '#e5e7eb' }} />
387
+ <div className="h-5 rounded w-32" style={{ backgroundColor: '#e5e7eb' }} />
388
+ <div className="h-4 w-4 rounded" style={{ backgroundColor: '#e5e7eb' }} />
389
+ </div>
390
+ <div className="grid grid-cols-7 gap-2">
391
+ {['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'].map(day => (
392
+ <div key={day} className="text-center text-xs font-medium py-2 opacity-60">
393
+ {day}
394
+ </div>
395
+ ))}
396
+ {Array.from({ length: 35 }).map((_, i) => (
397
+ <div key={i} className="aspect-square rounded-lg" style={{ backgroundColor: '#e5e7eb', opacity: 0.3 + (i % 3) * 0.2 }} />
398
+ ))}
399
+ </div>
400
+ </div>
401
+ </div>
402
+ ) : calendarView === 'month' ? (
374
403
  <div className="border border-gray-200 rounded-lg p-4">
375
404
  <div className="flex items-center justify-between mb-4">
376
405
  <button