@dialiq/calendar-component 1.0.0 → 1.0.1

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/dist/index.js CHANGED
@@ -527,6 +527,31 @@ function startOfISOWeekYear(date) {
527
527
  return startOfISOWeek(fourthOfJanuary);
528
528
  }
529
529
 
530
+ /**
531
+ * @name addWeeks
532
+ * @category Week Helpers
533
+ * @summary Add the specified number of weeks to the given date.
534
+ *
535
+ * @description
536
+ * Add the specified number of week to the given date.
537
+ *
538
+ * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
539
+ *
540
+ * @param date - The date to be changed
541
+ * @param amount - The amount of weeks to be added.
542
+ *
543
+ * @returns The new date with the weeks added
544
+ *
545
+ * @example
546
+ * // Add 4 weeks to 1 September 2014:
547
+ * const result = addWeeks(new Date(2014, 8, 1), 4)
548
+ * //=> Mon Sep 29 2014 00:00:00
549
+ */
550
+ function addWeeks(date, amount) {
551
+ const days = amount * 7;
552
+ return addDays(date, days);
553
+ }
554
+
530
555
  /**
531
556
  * @name isSameDay
532
557
  * @category Day Helpers
@@ -645,6 +670,32 @@ function isValid(date) {
645
670
  return !isNaN(Number(_date));
646
671
  }
647
672
 
673
+ /**
674
+ * @name endOfDay
675
+ * @category Day Helpers
676
+ * @summary Return the end of a day for the given date.
677
+ *
678
+ * @description
679
+ * Return the end of a day for the given date.
680
+ * The result will be in the local timezone.
681
+ *
682
+ * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
683
+ *
684
+ * @param date - The original date
685
+ *
686
+ * @returns The end of a day
687
+ *
688
+ * @example
689
+ * // The end of a day for 2 September 2014 11:55:00:
690
+ * const result = endOfDay(new Date(2014, 8, 2, 11, 55, 0))
691
+ * //=> Tue Sep 02 2014 23:59:59.999
692
+ */
693
+ function endOfDay(date) {
694
+ const _date = toDate(date);
695
+ _date.setHours(23, 59, 59, 999);
696
+ return _date;
697
+ }
698
+
648
699
  /**
649
700
  * @name endOfMonth
650
701
  * @category Month Helpers
@@ -3376,6 +3427,30 @@ function subMonths(date, amount) {
3376
3427
  return addMonths(date, -amount);
3377
3428
  }
3378
3429
 
3430
+ /**
3431
+ * @name subWeeks
3432
+ * @category Week Helpers
3433
+ * @summary Subtract the specified number of weeks from the given date.
3434
+ *
3435
+ * @description
3436
+ * Subtract the specified number of weeks from the given date.
3437
+ *
3438
+ * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
3439
+ *
3440
+ * @param date - The date to be changed
3441
+ * @param amount - The amount of weeks to be subtracted.
3442
+ *
3443
+ * @returns The new date with the weeks subtracted
3444
+ *
3445
+ * @example
3446
+ * // Subtract 4 weeks from 1 September 2014:
3447
+ * const result = subWeeks(new Date(2014, 8, 1), 4)
3448
+ * //=> Mon Aug 04 2014 00:00:00
3449
+ */
3450
+ function subWeeks(date, amount) {
3451
+ return addWeeks(date, -amount);
3452
+ }
3453
+
3379
3454
  const getBaseUrl = () => {
3380
3455
  if (typeof process !== 'undefined' && process.env && process.env.REACT_APP_CALENDAR_API_URL) {
3381
3456
  return process.env.REACT_APP_CALENDAR_API_URL;
@@ -3542,11 +3617,12 @@ const CreateBookingModal = ({ businessId, apiBaseUrl, initialDate, participants:
3542
3617
  React.createElement("button", { type: "submit", className: "modal-btn modal-btn-primary", disabled: loading }, loading ? 'Creating...' : 'Create Booking'))))));
3543
3618
  };
3544
3619
 
3545
- var css_248z = ".calendar-container {\r\n width: 100%;\r\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;\r\n background: #ffffff;\r\n border-radius: 8px;\r\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\r\n overflow: hidden;\r\n}\r\n\r\n.calendar-header {\r\n background: #f8f9fa;\r\n padding: 20px;\r\n border-bottom: 1px solid #e9ecef;\r\n}\r\n\r\n.calendar-title-section {\r\n display: flex;\r\n justify-content: space-between;\r\n align-items: center;\r\n margin-bottom: 16px;\r\n}\r\n\r\n.calendar-title {\r\n margin: 0;\r\n font-size: 24px;\r\n font-weight: 600;\r\n color: #212529;\r\n}\r\n\r\n.calendar-navigation {\r\n display: flex;\r\n align-items: center;\r\n gap: 12px;\r\n}\r\n\r\n.calendar-current-month {\r\n font-size: 18px;\r\n font-weight: 500;\r\n color: #495057;\r\n margin-left: 12px;\r\n}\r\n\r\n.calendar-btn {\r\n padding: 8px 16px;\r\n border: 1px solid #dee2e6;\r\n background: #ffffff;\r\n border-radius: 4px;\r\n cursor: pointer;\r\n font-size: 14px;\r\n font-weight: 500;\r\n color: #495057;\r\n transition: all 0.2s;\r\n}\r\n\r\n.calendar-btn:hover {\r\n background: #e9ecef;\r\n border-color: #adb5bd;\r\n}\r\n\r\n.calendar-btn-create {\r\n background: #0d6efd;\r\n color: #ffffff;\r\n border-color: #0d6efd;\r\n}\r\n\r\n.calendar-btn-create:hover {\r\n background: #0b5ed7;\r\n border-color: #0a58ca;\r\n}\r\n\r\n.calendar-days-row {\r\n display: grid;\r\n grid-template-columns: repeat(7, 1fr);\r\n background: #f8f9fa;\r\n border-bottom: 2px solid #dee2e6;\r\n}\r\n\r\n.calendar-day-header {\r\n padding: 12px;\r\n text-align: center;\r\n font-weight: 600;\r\n font-size: 14px;\r\n color: #6c757d;\r\n text-transform: uppercase;\r\n}\r\n\r\n.calendar-body {\r\n background: #ffffff;\r\n}\r\n\r\n.calendar-row {\r\n display: grid;\r\n grid-template-columns: repeat(7, 1fr);\r\n border-bottom: 1px solid #e9ecef;\r\n}\r\n\r\n.calendar-row:last-child {\r\n border-bottom: none;\r\n}\r\n\r\n.calendar-cell {\r\n min-height: 120px;\r\n padding: 8px;\r\n border-right: 1px solid #e9ecef;\r\n cursor: pointer;\r\n transition: background-color 0.2s;\r\n position: relative;\r\n}\r\n\r\n.calendar-cell:last-child {\r\n border-right: none;\r\n}\r\n\r\n.calendar-cell:hover {\r\n background: #f8f9fa;\r\n}\r\n\r\n.calendar-cell-disabled {\r\n background: #f8f9fa;\r\n opacity: 0.5;\r\n cursor: not-allowed;\r\n}\r\n\r\n.calendar-cell-disabled:hover {\r\n background: #f8f9fa;\r\n}\r\n\r\n.calendar-cell-today {\r\n background: #e7f5ff;\r\n}\r\n\r\n.calendar-cell-today .calendar-cell-number {\r\n background: #0d6efd;\r\n color: #ffffff;\r\n}\r\n\r\n.calendar-cell-number {\r\n display: inline-flex;\r\n align-items: center;\r\n justify-content: center;\r\n width: 28px;\r\n height: 28px;\r\n border-radius: 50%;\r\n font-weight: 600;\r\n font-size: 14px;\r\n color: #212529;\r\n margin-bottom: 4px;\r\n}\r\n\r\n.calendar-cell-bookings {\r\n margin-top: 4px;\r\n}\r\n\r\n.calendar-booking {\r\n background: #0d6efd;\r\n color: #ffffff;\r\n padding: 4px 8px;\r\n margin-bottom: 4px;\r\n border-radius: 4px;\r\n font-size: 12px;\r\n cursor: pointer;\r\n transition: background-color 0.2s;\r\n display: flex;\r\n gap: 4px;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n white-space: nowrap;\r\n}\r\n\r\n.calendar-booking:hover {\r\n background: #0b5ed7;\r\n}\r\n\r\n.calendar-booking-time {\r\n font-weight: 600;\r\n}\r\n\r\n.calendar-booking-title {\r\n flex: 1;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n}\r\n\r\n.calendar-booking-more {\r\n color: #6c757d;\r\n font-size: 11px;\r\n padding: 2px 4px;\r\n font-weight: 500;\r\n}\r\n\r\n.calendar-error {\r\n background: #f8d7da;\r\n color: #842029;\r\n padding: 12px 20px;\r\n border-bottom: 1px solid #f5c2c7;\r\n}\r\n\r\n.calendar-loading {\r\n background: #cff4fc;\r\n color: #055160;\r\n padding: 12px 20px;\r\n border-bottom: 1px solid #b6effb;\r\n text-align: center;\r\n}\r\n\r\n@media (max-width: 768px) {\r\n .calendar-title-section {\r\n flex-direction: column;\r\n align-items: flex-start;\r\n gap: 12px;\r\n }\r\n\r\n .calendar-cell {\r\n min-height: 80px;\r\n padding: 4px;\r\n }\r\n\r\n .calendar-cell-number {\r\n width: 24px;\r\n height: 24px;\r\n font-size: 12px;\r\n }\r\n\r\n .calendar-booking {\r\n font-size: 10px;\r\n padding: 2px 4px;\r\n }\r\n}\r\n";
3620
+ var css_248z = ".calendar-container {\n width: 100%;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;\n background: #ffffff;\n border-radius: 8px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n overflow: hidden;\n}\n\n.calendar-header {\n background: #f8f9fa;\n padding: 20px;\n border-bottom: 1px solid #e9ecef;\n}\n\n.calendar-title-section {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-bottom: 16px;\n gap: 16px;\n flex-wrap: wrap;\n}\n\n.calendar-title {\n margin: 0;\n font-size: 24px;\n font-weight: 600;\n color: #212529;\n}\n\n.calendar-view-toggle {\n display: flex;\n gap: 4px;\n background: #e9ecef;\n padding: 4px;\n border-radius: 6px;\n}\n\n.calendar-btn-view {\n padding: 6px 14px;\n border: none;\n background: transparent;\n font-size: 13px;\n}\n\n.calendar-btn-view.active {\n background: #ffffff;\n color: #0d6efd;\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);\n}\n\n.calendar-btn-view:hover {\n background: #ffffff;\n border-color: transparent;\n}\n\n.calendar-navigation {\n display: flex;\n align-items: center;\n gap: 12px;\n}\n\n.calendar-current-month {\n font-size: 18px;\n font-weight: 500;\n color: #495057;\n margin-left: 12px;\n}\n\n.calendar-btn {\n padding: 8px 16px;\n border: 1px solid #dee2e6;\n background: #ffffff;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n font-weight: 500;\n color: #495057;\n transition: all 0.2s;\n}\n\n.calendar-btn:hover {\n background: #e9ecef;\n border-color: #adb5bd;\n}\n\n.calendar-btn-create {\n background: #0d6efd;\n color: #ffffff;\n border-color: #0d6efd;\n}\n\n.calendar-btn-create:hover {\n background: #0b5ed7;\n border-color: #0a58ca;\n}\n\n.calendar-days-row {\n display: grid;\n grid-template-columns: repeat(7, 1fr);\n background: #f8f9fa;\n border-bottom: 2px solid #dee2e6;\n}\n\n.calendar-day-header {\n padding: 12px;\n text-align: center;\n font-weight: 600;\n font-size: 14px;\n color: #6c757d;\n text-transform: uppercase;\n}\n\n.calendar-body {\n background: #ffffff;\n}\n\n.calendar-row {\n display: grid;\n grid-template-columns: repeat(7, 1fr);\n border-bottom: 1px solid #e9ecef;\n}\n\n.calendar-row:last-child {\n border-bottom: none;\n}\n\n.calendar-cell {\n min-height: 120px;\n padding: 8px;\n border-right: 1px solid #e9ecef;\n cursor: pointer;\n transition: background-color 0.2s;\n position: relative;\n}\n\n.calendar-cell:last-child {\n border-right: none;\n}\n\n.calendar-cell:hover {\n background: #f8f9fa;\n}\n\n.calendar-cell-disabled {\n background: #f8f9fa;\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n.calendar-cell-disabled:hover {\n background: #f8f9fa;\n}\n\n.calendar-cell-today {\n background: #e7f5ff;\n}\n\n.calendar-cell-today .calendar-cell-number {\n background: #0d6efd;\n color: #ffffff;\n}\n\n.calendar-cell-number {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 28px;\n height: 28px;\n border-radius: 50%;\n font-weight: 600;\n font-size: 14px;\n color: #212529;\n margin-bottom: 4px;\n}\n\n.calendar-cell-bookings {\n margin-top: 4px;\n}\n\n.calendar-booking {\n background: #0d6efd;\n color: #ffffff;\n padding: 4px 8px;\n margin-bottom: 4px;\n border-radius: 4px;\n font-size: 12px;\n cursor: pointer;\n transition: background-color 0.2s;\n display: flex;\n gap: 4px;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.calendar-booking:hover {\n background: #0b5ed7;\n}\n\n.calendar-booking-time {\n font-weight: 600;\n}\n\n.calendar-booking-title {\n flex: 1;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.calendar-booking-more {\n color: #6c757d;\n font-size: 11px;\n padding: 2px 4px;\n font-weight: 500;\n}\n\n.calendar-error {\n background: #f8d7da;\n color: #842029;\n padding: 12px 20px;\n border-bottom: 1px solid #f5c2c7;\n}\n\n.calendar-loading {\n background: #cff4fc;\n color: #055160;\n padding: 12px 20px;\n border-bottom: 1px solid #b6effb;\n text-align: center;\n}\n\n.calendar-week-view {\n display: grid;\n grid-template-columns: repeat(7, 1fr);\n gap: 1px;\n background: #e9ecef;\n padding: 1px;\n}\n\n.calendar-week-day {\n background: #ffffff;\n min-height: 400px;\n cursor: pointer;\n transition: background-color 0.2s;\n display: flex;\n flex-direction: column;\n}\n\n.calendar-week-day:hover {\n background: #f8f9fa;\n}\n\n.calendar-week-day-header {\n padding: 12px;\n border-bottom: 2px solid #e9ecef;\n text-align: center;\n background: #f8f9fa;\n}\n\n.calendar-week-day-name {\n font-size: 12px;\n font-weight: 600;\n color: #6c757d;\n text-transform: uppercase;\n margin-bottom: 4px;\n}\n\n.calendar-week-day-number {\n font-size: 20px;\n font-weight: 600;\n color: #212529;\n}\n\n.calendar-week-day.calendar-cell-today .calendar-week-day-header {\n background: #e7f5ff;\n}\n\n.calendar-week-day.calendar-cell-today .calendar-week-day-number {\n color: #0d6efd;\n}\n\n.calendar-week-day-bookings {\n padding: 8px;\n flex: 1;\n overflow-y: auto;\n}\n\n.calendar-week-booking {\n margin-bottom: 6px;\n display: block;\n}\n\n.calendar-day-view {\n padding: 20px;\n background: #ffffff;\n}\n\n.calendar-day-container {\n max-width: 800px;\n margin: 0 auto;\n background: #ffffff;\n border: 1px solid #e9ecef;\n border-radius: 8px;\n overflow: hidden;\n}\n\n.calendar-day-container.calendar-cell-today {\n border-color: #0d6efd;\n box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.1);\n}\n\n.calendar-day-header {\n background: #f8f9fa;\n padding: 20px;\n border-bottom: 2px solid #e9ecef;\n text-align: center;\n}\n\n.calendar-day-name {\n font-size: 16px;\n font-weight: 600;\n color: #6c757d;\n text-transform: uppercase;\n margin-bottom: 8px;\n}\n\n.calendar-day-date {\n font-size: 24px;\n font-weight: 700;\n color: #212529;\n}\n\n.calendar-day-bookings {\n padding: 20px;\n min-height: 300px;\n}\n\n.calendar-no-bookings {\n text-align: center;\n color: #6c757d;\n padding: 60px 20px;\n font-size: 16px;\n}\n\n.calendar-day-booking {\n display: flex;\n flex-direction: column;\n gap: 8px;\n padding: 16px;\n margin-bottom: 12px;\n border-left: 4px solid #0d6efd;\n}\n\n.calendar-day-booking .calendar-booking-time {\n font-size: 14px;\n}\n\n.calendar-day-booking .calendar-booking-title {\n font-size: 16px;\n font-weight: 600;\n color: #212529;\n}\n\n.calendar-booking-description {\n font-size: 14px;\n color: #6c757d;\n line-height: 1.5;\n}\n\n.calendar-day-add-btn {\n margin: 20px;\n width: calc(100% - 40px);\n background: #0d6efd;\n color: #ffffff;\n border-color: #0d6efd;\n padding: 12px;\n font-size: 15px;\n}\n\n.calendar-day-add-btn:hover {\n background: #0b5ed7;\n border-color: #0a58ca;\n}\n\n@media (max-width: 768px) {\n .calendar-title-section {\n flex-direction: column;\n align-items: flex-start;\n gap: 12px;\n }\n\n .calendar-cell {\n min-height: 80px;\n padding: 4px;\n }\n\n .calendar-cell-number {\n width: 24px;\n height: 24px;\n font-size: 12px;\n }\n\n .calendar-booking {\n font-size: 10px;\n padding: 2px 4px;\n }\n\n .calendar-week-view {\n grid-template-columns: 1fr;\n }\n\n .calendar-week-day {\n min-height: 200px;\n }\n\n .calendar-day-view {\n padding: 12px;\n }\n\n .calendar-day-container {\n border-radius: 4px;\n }\n\n .calendar-day-header {\n padding: 16px;\n }\n\n .calendar-day-date {\n font-size: 20px;\n }\n\n .calendar-day-bookings {\n padding: 12px;\n }\n}\n";
3546
3621
  styleInject(css_248z);
3547
3622
 
3548
3623
  const Calendar = ({ businessId, resourceId, title = 'Calendar', apiBaseUrl, defaultView = 'month', onBookingCreate, onBookingClick, participants = [], }) => {
3549
3624
  const [currentDate, setCurrentDate] = React.useState(new Date());
3625
+ const [currentView, setCurrentView] = React.useState(defaultView);
3550
3626
  const [bookings, setBookings] = React.useState([]);
3551
3627
  const [loading, setLoading] = React.useState(false);
3552
3628
  const [error, setError] = React.useState(null);
@@ -3556,10 +3632,22 @@ const Calendar = ({ businessId, resourceId, title = 'Calendar', apiBaseUrl, defa
3556
3632
  setLoading(true);
3557
3633
  setError(null);
3558
3634
  try {
3559
- const monthStart = startOfMonth(currentDate);
3560
- const monthEnd = endOfMonth(currentDate);
3561
- const startDate = startOfWeek(monthStart);
3562
- const endDate = endOfWeek(monthEnd);
3635
+ let startDate;
3636
+ let endDate;
3637
+ if (currentView === 'month') {
3638
+ const monthStart = startOfMonth(currentDate);
3639
+ const monthEnd = endOfMonth(currentDate);
3640
+ startDate = startOfWeek(monthStart);
3641
+ endDate = endOfWeek(monthEnd);
3642
+ }
3643
+ else if (currentView === 'week') {
3644
+ startDate = startOfWeek(currentDate);
3645
+ endDate = endOfWeek(currentDate);
3646
+ }
3647
+ else {
3648
+ startDate = startOfDay(currentDate);
3649
+ endDate = endOfDay(currentDate);
3650
+ }
3563
3651
  let fetchedBookings;
3564
3652
  if (resourceId) {
3565
3653
  fetchedBookings = yield getResourceSchedule(businessId, resourceId, startDate.toISOString(), endDate.toISOString(), apiBaseUrl);
@@ -3575,15 +3663,31 @@ const Calendar = ({ businessId, resourceId, title = 'Calendar', apiBaseUrl, defa
3575
3663
  finally {
3576
3664
  setLoading(false);
3577
3665
  }
3578
- }), [businessId, resourceId, currentDate, apiBaseUrl]);
3666
+ }), [businessId, resourceId, currentDate, currentView, apiBaseUrl]);
3579
3667
  React.useEffect(() => {
3580
3668
  fetchBookings();
3581
3669
  }, [fetchBookings]);
3582
- const handlePreviousMonth = () => {
3583
- setCurrentDate(subMonths(currentDate, 1));
3670
+ const handlePrevious = () => {
3671
+ if (currentView === 'month') {
3672
+ setCurrentDate(subMonths(currentDate, 1));
3673
+ }
3674
+ else if (currentView === 'week') {
3675
+ setCurrentDate(subWeeks(currentDate, 1));
3676
+ }
3677
+ else {
3678
+ setCurrentDate(addDays(currentDate, -1));
3679
+ }
3584
3680
  };
3585
- const handleNextMonth = () => {
3586
- setCurrentDate(addMonths(currentDate, 1));
3681
+ const handleNext = () => {
3682
+ if (currentView === 'month') {
3683
+ setCurrentDate(addMonths(currentDate, 1));
3684
+ }
3685
+ else if (currentView === 'week') {
3686
+ setCurrentDate(addWeeks(currentDate, 1));
3687
+ }
3688
+ else {
3689
+ setCurrentDate(addDays(currentDate, 1));
3690
+ }
3587
3691
  };
3588
3692
  const handleToday = () => {
3589
3693
  setCurrentDate(new Date());
@@ -3606,22 +3710,39 @@ const Calendar = ({ businessId, resourceId, title = 'Calendar', apiBaseUrl, defa
3606
3710
  return isSameDay(bookingStart, day);
3607
3711
  });
3608
3712
  };
3713
+ const getHeaderDateFormat = () => {
3714
+ if (currentView === 'month') {
3715
+ return format(currentDate, 'MMMM yyyy');
3716
+ }
3717
+ else if (currentView === 'week') {
3718
+ const weekStart = startOfWeek(currentDate);
3719
+ const weekEnd = endOfWeek(currentDate);
3720
+ return `${format(weekStart, 'MMM d')} - ${format(weekEnd, 'MMM d, yyyy')}`;
3721
+ }
3722
+ else {
3723
+ return format(currentDate, 'MMMM d, yyyy');
3724
+ }
3725
+ };
3609
3726
  const renderHeader = () => {
3610
3727
  return (React.createElement("div", { className: "calendar-header" },
3611
3728
  React.createElement("div", { className: "calendar-title-section" },
3612
3729
  React.createElement("h2", { className: "calendar-title" }, title),
3730
+ React.createElement("div", { className: "calendar-view-toggle" },
3731
+ React.createElement("button", { className: `calendar-btn calendar-btn-view ${currentView === 'month' ? 'active' : ''}`, onClick: () => setCurrentView('month') }, "Month"),
3732
+ React.createElement("button", { className: `calendar-btn calendar-btn-view ${currentView === 'week' ? 'active' : ''}`, onClick: () => setCurrentView('week') }, "Week"),
3733
+ React.createElement("button", { className: `calendar-btn calendar-btn-view ${currentView === 'day' ? 'active' : ''}`, onClick: () => setCurrentView('day') }, "Day")),
3613
3734
  React.createElement("button", { className: "calendar-btn calendar-btn-create", onClick: () => setShowCreateModal(true) }, "+ Create Booking")),
3614
3735
  React.createElement("div", { className: "calendar-navigation" },
3615
- React.createElement("button", { className: "calendar-btn", onClick: handlePreviousMonth }, "\u2039"),
3736
+ React.createElement("button", { className: "calendar-btn", onClick: handlePrevious }, "\u2039"),
3616
3737
  React.createElement("button", { className: "calendar-btn", onClick: handleToday }, "Today"),
3617
- React.createElement("button", { className: "calendar-btn", onClick: handleNextMonth }, "\u203A"),
3618
- React.createElement("span", { className: "calendar-current-month" }, format(currentDate, 'MMMM yyyy')))));
3738
+ React.createElement("button", { className: "calendar-btn", onClick: handleNext }, "\u203A"),
3739
+ React.createElement("span", { className: "calendar-current-month" }, getHeaderDateFormat()))));
3619
3740
  };
3620
3741
  const renderDaysOfWeek = () => {
3621
3742
  const days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
3622
3743
  return (React.createElement("div", { className: "calendar-days-row" }, days.map((day) => (React.createElement("div", { key: day, className: "calendar-day-header" }, day)))));
3623
3744
  };
3624
- const renderCells = () => {
3745
+ const renderMonthView = () => {
3625
3746
  const monthStart = startOfMonth(currentDate);
3626
3747
  const monthEnd = endOfMonth(currentDate);
3627
3748
  const startDate = startOfWeek(monthStart);
@@ -3660,12 +3781,64 @@ const Calendar = ({ businessId, resourceId, title = 'Calendar', apiBaseUrl, defa
3660
3781
  }
3661
3782
  return React.createElement("div", { className: "calendar-body" }, rows);
3662
3783
  };
3784
+ const renderWeekView = () => {
3785
+ const weekStart = startOfWeek(currentDate);
3786
+ const days = [];
3787
+ for (let i = 0; i < 7; i++) {
3788
+ const day = addDays(weekStart, i);
3789
+ const dayBookings = getBookingsForDay(day);
3790
+ const isToday = isSameDay(day, new Date());
3791
+ days.push(React.createElement("div", { key: day.toString(), className: `calendar-week-day ${isToday ? 'calendar-cell-today' : ''}`, onClick: () => handleDateClick(day) },
3792
+ React.createElement("div", { className: "calendar-week-day-header" },
3793
+ React.createElement("div", { className: "calendar-week-day-name" }, format(day, 'EEE')),
3794
+ React.createElement("div", { className: "calendar-week-day-number" }, format(day, 'd'))),
3795
+ React.createElement("div", { className: "calendar-week-day-bookings" }, dayBookings.map((booking) => {
3796
+ var _a, _b;
3797
+ return (React.createElement("div", { key: booking.meeting_id, className: "calendar-booking calendar-week-booking", onClick: (e) => {
3798
+ e.stopPropagation();
3799
+ if (onBookingClick) {
3800
+ onBookingClick(booking);
3801
+ }
3802
+ }, title: ((_a = booking.metadata) === null || _a === void 0 ? void 0 : _a.title) || 'Untitled' },
3803
+ React.createElement("span", { className: "calendar-booking-time" }, format(parseISO(booking.start), 'HH:mm')),
3804
+ React.createElement("span", { className: "calendar-booking-title" }, ((_b = booking.metadata) === null || _b === void 0 ? void 0 : _b.title) || 'Untitled')));
3805
+ }))));
3806
+ }
3807
+ return React.createElement("div", { className: "calendar-week-view" }, days);
3808
+ };
3809
+ const renderDayView = () => {
3810
+ const dayBookings = getBookingsForDay(currentDate);
3811
+ const isToday = isSameDay(currentDate, new Date());
3812
+ return (React.createElement("div", { className: "calendar-day-view" },
3813
+ React.createElement("div", { className: `calendar-day-container ${isToday ? 'calendar-cell-today' : ''}` },
3814
+ React.createElement("div", { className: "calendar-day-header" },
3815
+ React.createElement("div", { className: "calendar-day-name" }, format(currentDate, 'EEEE')),
3816
+ React.createElement("div", { className: "calendar-day-date" }, format(currentDate, 'MMMM d, yyyy'))),
3817
+ React.createElement("div", { className: "calendar-day-bookings" }, dayBookings.length === 0 ? (React.createElement("div", { className: "calendar-no-bookings" }, "No bookings for this day")) : (dayBookings.map((booking) => {
3818
+ var _a, _b, _c;
3819
+ return (React.createElement("div", { key: booking.meeting_id, className: "calendar-booking calendar-day-booking", onClick: () => {
3820
+ if (onBookingClick) {
3821
+ onBookingClick(booking);
3822
+ }
3823
+ }, title: ((_a = booking.metadata) === null || _a === void 0 ? void 0 : _a.title) || 'Untitled' },
3824
+ React.createElement("span", { className: "calendar-booking-time" },
3825
+ format(parseISO(booking.start), 'HH:mm'),
3826
+ " - ",
3827
+ format(parseISO(booking.end), 'HH:mm')),
3828
+ React.createElement("span", { className: "calendar-booking-title" }, ((_b = booking.metadata) === null || _b === void 0 ? void 0 : _b.title) || 'Untitled'),
3829
+ ((_c = booking.metadata) === null || _c === void 0 ? void 0 : _c.description) && (React.createElement("span", { className: "calendar-booking-description" }, booking.metadata.description))));
3830
+ }))),
3831
+ React.createElement("button", { className: "calendar-btn calendar-day-add-btn", onClick: () => handleDateClick(currentDate) }, "+ Add Booking"))));
3832
+ };
3663
3833
  return (React.createElement("div", { className: "calendar-container" },
3664
3834
  renderHeader(),
3665
3835
  error && React.createElement("div", { className: "calendar-error" }, error),
3666
3836
  loading && React.createElement("div", { className: "calendar-loading" }, "Loading..."),
3667
- renderDaysOfWeek(),
3668
- renderCells(),
3837
+ currentView === 'month' && (React.createElement(React.Fragment, null,
3838
+ renderDaysOfWeek(),
3839
+ renderMonthView())),
3840
+ currentView === 'week' && renderWeekView(),
3841
+ currentView === 'day' && renderDayView(),
3669
3842
  showCreateModal && (React.createElement(CreateBookingModal, { businessId: businessId, apiBaseUrl: apiBaseUrl, initialDate: selectedDate || new Date(), participants: participants, onClose: () => {
3670
3843
  setShowCreateModal(false);
3671
3844
  setSelectedDate(null);