@dialiq/calendar-component 1.0.0 → 1.0.2
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/Calendar.d.ts.map +1 -1
- package/dist/index.esm.js +189 -16
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +189 -16
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/Calendar.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calendar.d.ts","sourceRoot":"","sources":["../src/Calendar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2C,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Calendar.d.ts","sourceRoot":"","sources":["../src/Calendar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAmBhE,OAAO,EAAE,aAAa,EAAW,MAAM,SAAS,CAAC;AAGjD,OAAO,gBAAgB,CAAC;AAIxB,QAAA,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAoYrC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -525,6 +525,31 @@ function startOfISOWeekYear(date) {
|
|
|
525
525
|
return startOfISOWeek(fourthOfJanuary);
|
|
526
526
|
}
|
|
527
527
|
|
|
528
|
+
/**
|
|
529
|
+
* @name addWeeks
|
|
530
|
+
* @category Week Helpers
|
|
531
|
+
* @summary Add the specified number of weeks to the given date.
|
|
532
|
+
*
|
|
533
|
+
* @description
|
|
534
|
+
* Add the specified number of week to the given date.
|
|
535
|
+
*
|
|
536
|
+
* @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).
|
|
537
|
+
*
|
|
538
|
+
* @param date - The date to be changed
|
|
539
|
+
* @param amount - The amount of weeks to be added.
|
|
540
|
+
*
|
|
541
|
+
* @returns The new date with the weeks added
|
|
542
|
+
*
|
|
543
|
+
* @example
|
|
544
|
+
* // Add 4 weeks to 1 September 2014:
|
|
545
|
+
* const result = addWeeks(new Date(2014, 8, 1), 4)
|
|
546
|
+
* //=> Mon Sep 29 2014 00:00:00
|
|
547
|
+
*/
|
|
548
|
+
function addWeeks(date, amount) {
|
|
549
|
+
const days = amount * 7;
|
|
550
|
+
return addDays(date, days);
|
|
551
|
+
}
|
|
552
|
+
|
|
528
553
|
/**
|
|
529
554
|
* @name isSameDay
|
|
530
555
|
* @category Day Helpers
|
|
@@ -643,6 +668,32 @@ function isValid(date) {
|
|
|
643
668
|
return !isNaN(Number(_date));
|
|
644
669
|
}
|
|
645
670
|
|
|
671
|
+
/**
|
|
672
|
+
* @name endOfDay
|
|
673
|
+
* @category Day Helpers
|
|
674
|
+
* @summary Return the end of a day for the given date.
|
|
675
|
+
*
|
|
676
|
+
* @description
|
|
677
|
+
* Return the end of a day for the given date.
|
|
678
|
+
* The result will be in the local timezone.
|
|
679
|
+
*
|
|
680
|
+
* @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).
|
|
681
|
+
*
|
|
682
|
+
* @param date - The original date
|
|
683
|
+
*
|
|
684
|
+
* @returns The end of a day
|
|
685
|
+
*
|
|
686
|
+
* @example
|
|
687
|
+
* // The end of a day for 2 September 2014 11:55:00:
|
|
688
|
+
* const result = endOfDay(new Date(2014, 8, 2, 11, 55, 0))
|
|
689
|
+
* //=> Tue Sep 02 2014 23:59:59.999
|
|
690
|
+
*/
|
|
691
|
+
function endOfDay(date) {
|
|
692
|
+
const _date = toDate(date);
|
|
693
|
+
_date.setHours(23, 59, 59, 999);
|
|
694
|
+
return _date;
|
|
695
|
+
}
|
|
696
|
+
|
|
646
697
|
/**
|
|
647
698
|
* @name endOfMonth
|
|
648
699
|
* @category Month Helpers
|
|
@@ -3374,6 +3425,30 @@ function subMonths(date, amount) {
|
|
|
3374
3425
|
return addMonths(date, -amount);
|
|
3375
3426
|
}
|
|
3376
3427
|
|
|
3428
|
+
/**
|
|
3429
|
+
* @name subWeeks
|
|
3430
|
+
* @category Week Helpers
|
|
3431
|
+
* @summary Subtract the specified number of weeks from the given date.
|
|
3432
|
+
*
|
|
3433
|
+
* @description
|
|
3434
|
+
* Subtract the specified number of weeks from the given date.
|
|
3435
|
+
*
|
|
3436
|
+
* @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).
|
|
3437
|
+
*
|
|
3438
|
+
* @param date - The date to be changed
|
|
3439
|
+
* @param amount - The amount of weeks to be subtracted.
|
|
3440
|
+
*
|
|
3441
|
+
* @returns The new date with the weeks subtracted
|
|
3442
|
+
*
|
|
3443
|
+
* @example
|
|
3444
|
+
* // Subtract 4 weeks from 1 September 2014:
|
|
3445
|
+
* const result = subWeeks(new Date(2014, 8, 1), 4)
|
|
3446
|
+
* //=> Mon Aug 04 2014 00:00:00
|
|
3447
|
+
*/
|
|
3448
|
+
function subWeeks(date, amount) {
|
|
3449
|
+
return addWeeks(date, -amount);
|
|
3450
|
+
}
|
|
3451
|
+
|
|
3377
3452
|
const getBaseUrl = () => {
|
|
3378
3453
|
if (typeof process !== 'undefined' && process.env && process.env.REACT_APP_CALENDAR_API_URL) {
|
|
3379
3454
|
return process.env.REACT_APP_CALENDAR_API_URL;
|
|
@@ -3540,11 +3615,12 @@ const CreateBookingModal = ({ businessId, apiBaseUrl, initialDate, participants:
|
|
|
3540
3615
|
React.createElement("button", { type: "submit", className: "modal-btn modal-btn-primary", disabled: loading }, loading ? 'Creating...' : 'Create Booking'))))));
|
|
3541
3616
|
};
|
|
3542
3617
|
|
|
3543
|
-
var css_248z = ".calendar-container {\
|
|
3618
|
+
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";
|
|
3544
3619
|
styleInject(css_248z);
|
|
3545
3620
|
|
|
3546
3621
|
const Calendar = ({ businessId, resourceId, title = 'Calendar', apiBaseUrl, defaultView = 'month', onBookingCreate, onBookingClick, participants = [], }) => {
|
|
3547
3622
|
const [currentDate, setCurrentDate] = useState(new Date());
|
|
3623
|
+
const [currentView, setCurrentView] = useState(defaultView);
|
|
3548
3624
|
const [bookings, setBookings] = useState([]);
|
|
3549
3625
|
const [loading, setLoading] = useState(false);
|
|
3550
3626
|
const [error, setError] = useState(null);
|
|
@@ -3554,10 +3630,22 @@ const Calendar = ({ businessId, resourceId, title = 'Calendar', apiBaseUrl, defa
|
|
|
3554
3630
|
setLoading(true);
|
|
3555
3631
|
setError(null);
|
|
3556
3632
|
try {
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3633
|
+
let startDate;
|
|
3634
|
+
let endDate;
|
|
3635
|
+
if (currentView === 'month') {
|
|
3636
|
+
const monthStart = startOfMonth(currentDate);
|
|
3637
|
+
const monthEnd = endOfMonth(currentDate);
|
|
3638
|
+
startDate = startOfWeek(monthStart);
|
|
3639
|
+
endDate = endOfWeek(monthEnd);
|
|
3640
|
+
}
|
|
3641
|
+
else if (currentView === 'week') {
|
|
3642
|
+
startDate = startOfWeek(currentDate);
|
|
3643
|
+
endDate = endOfWeek(currentDate);
|
|
3644
|
+
}
|
|
3645
|
+
else {
|
|
3646
|
+
startDate = startOfDay(currentDate);
|
|
3647
|
+
endDate = endOfDay(currentDate);
|
|
3648
|
+
}
|
|
3561
3649
|
let fetchedBookings;
|
|
3562
3650
|
if (resourceId) {
|
|
3563
3651
|
fetchedBookings = yield getResourceSchedule(businessId, resourceId, startDate.toISOString(), endDate.toISOString(), apiBaseUrl);
|
|
@@ -3573,15 +3661,31 @@ const Calendar = ({ businessId, resourceId, title = 'Calendar', apiBaseUrl, defa
|
|
|
3573
3661
|
finally {
|
|
3574
3662
|
setLoading(false);
|
|
3575
3663
|
}
|
|
3576
|
-
}), [businessId, resourceId, currentDate, apiBaseUrl]);
|
|
3664
|
+
}), [businessId, resourceId, currentDate, currentView, apiBaseUrl]);
|
|
3577
3665
|
useEffect(() => {
|
|
3578
3666
|
fetchBookings();
|
|
3579
3667
|
}, [fetchBookings]);
|
|
3580
|
-
const
|
|
3581
|
-
|
|
3668
|
+
const handlePrevious = () => {
|
|
3669
|
+
if (currentView === 'month') {
|
|
3670
|
+
setCurrentDate(subMonths(currentDate, 1));
|
|
3671
|
+
}
|
|
3672
|
+
else if (currentView === 'week') {
|
|
3673
|
+
setCurrentDate(subWeeks(currentDate, 1));
|
|
3674
|
+
}
|
|
3675
|
+
else {
|
|
3676
|
+
setCurrentDate(addDays(currentDate, -1));
|
|
3677
|
+
}
|
|
3582
3678
|
};
|
|
3583
|
-
const
|
|
3584
|
-
|
|
3679
|
+
const handleNext = () => {
|
|
3680
|
+
if (currentView === 'month') {
|
|
3681
|
+
setCurrentDate(addMonths(currentDate, 1));
|
|
3682
|
+
}
|
|
3683
|
+
else if (currentView === 'week') {
|
|
3684
|
+
setCurrentDate(addWeeks(currentDate, 1));
|
|
3685
|
+
}
|
|
3686
|
+
else {
|
|
3687
|
+
setCurrentDate(addDays(currentDate, 1));
|
|
3688
|
+
}
|
|
3585
3689
|
};
|
|
3586
3690
|
const handleToday = () => {
|
|
3587
3691
|
setCurrentDate(new Date());
|
|
@@ -3604,22 +3708,39 @@ const Calendar = ({ businessId, resourceId, title = 'Calendar', apiBaseUrl, defa
|
|
|
3604
3708
|
return isSameDay(bookingStart, day);
|
|
3605
3709
|
});
|
|
3606
3710
|
};
|
|
3711
|
+
const getHeaderDateFormat = () => {
|
|
3712
|
+
if (currentView === 'month') {
|
|
3713
|
+
return format(currentDate, 'MMMM yyyy');
|
|
3714
|
+
}
|
|
3715
|
+
else if (currentView === 'week') {
|
|
3716
|
+
const weekStart = startOfWeek(currentDate);
|
|
3717
|
+
const weekEnd = endOfWeek(currentDate);
|
|
3718
|
+
return `${format(weekStart, 'MMM d')} - ${format(weekEnd, 'MMM d, yyyy')}`;
|
|
3719
|
+
}
|
|
3720
|
+
else {
|
|
3721
|
+
return format(currentDate, 'MMMM d, yyyy');
|
|
3722
|
+
}
|
|
3723
|
+
};
|
|
3607
3724
|
const renderHeader = () => {
|
|
3608
3725
|
return (React.createElement("div", { className: "calendar-header" },
|
|
3609
3726
|
React.createElement("div", { className: "calendar-title-section" },
|
|
3610
3727
|
React.createElement("h2", { className: "calendar-title" }, title),
|
|
3728
|
+
React.createElement("div", { className: "calendar-view-toggle" },
|
|
3729
|
+
React.createElement("button", { className: `calendar-btn calendar-btn-view ${currentView === 'month' ? 'active' : ''}`, onClick: () => setCurrentView('month') }, "Month"),
|
|
3730
|
+
React.createElement("button", { className: `calendar-btn calendar-btn-view ${currentView === 'week' ? 'active' : ''}`, onClick: () => setCurrentView('week') }, "Week"),
|
|
3731
|
+
React.createElement("button", { className: `calendar-btn calendar-btn-view ${currentView === 'day' ? 'active' : ''}`, onClick: () => setCurrentView('day') }, "Day")),
|
|
3611
3732
|
React.createElement("button", { className: "calendar-btn calendar-btn-create", onClick: () => setShowCreateModal(true) }, "+ Create Booking")),
|
|
3612
3733
|
React.createElement("div", { className: "calendar-navigation" },
|
|
3613
|
-
React.createElement("button", { className: "calendar-btn", onClick:
|
|
3734
|
+
React.createElement("button", { className: "calendar-btn", onClick: handlePrevious }, "\u2039"),
|
|
3614
3735
|
React.createElement("button", { className: "calendar-btn", onClick: handleToday }, "Today"),
|
|
3615
|
-
React.createElement("button", { className: "calendar-btn", onClick:
|
|
3616
|
-
React.createElement("span", { className: "calendar-current-month" },
|
|
3736
|
+
React.createElement("button", { className: "calendar-btn", onClick: handleNext }, "\u203A"),
|
|
3737
|
+
React.createElement("span", { className: "calendar-current-month" }, getHeaderDateFormat()))));
|
|
3617
3738
|
};
|
|
3618
3739
|
const renderDaysOfWeek = () => {
|
|
3619
3740
|
const days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
3620
3741
|
return (React.createElement("div", { className: "calendar-days-row" }, days.map((day) => (React.createElement("div", { key: day, className: "calendar-day-header" }, day)))));
|
|
3621
3742
|
};
|
|
3622
|
-
const
|
|
3743
|
+
const renderMonthView = () => {
|
|
3623
3744
|
const monthStart = startOfMonth(currentDate);
|
|
3624
3745
|
const monthEnd = endOfMonth(currentDate);
|
|
3625
3746
|
const startDate = startOfWeek(monthStart);
|
|
@@ -3658,12 +3779,64 @@ const Calendar = ({ businessId, resourceId, title = 'Calendar', apiBaseUrl, defa
|
|
|
3658
3779
|
}
|
|
3659
3780
|
return React.createElement("div", { className: "calendar-body" }, rows);
|
|
3660
3781
|
};
|
|
3782
|
+
const renderWeekView = () => {
|
|
3783
|
+
const weekStart = startOfWeek(currentDate);
|
|
3784
|
+
const days = [];
|
|
3785
|
+
for (let i = 0; i < 7; i++) {
|
|
3786
|
+
const day = addDays(weekStart, i);
|
|
3787
|
+
const dayBookings = getBookingsForDay(day);
|
|
3788
|
+
const isToday = isSameDay(day, new Date());
|
|
3789
|
+
days.push(React.createElement("div", { key: day.toString(), className: `calendar-week-day ${isToday ? 'calendar-cell-today' : ''}`, onClick: () => handleDateClick(day) },
|
|
3790
|
+
React.createElement("div", { className: "calendar-week-day-header" },
|
|
3791
|
+
React.createElement("div", { className: "calendar-week-day-name" }, format(day, 'EEE')),
|
|
3792
|
+
React.createElement("div", { className: "calendar-week-day-number" }, format(day, 'd'))),
|
|
3793
|
+
React.createElement("div", { className: "calendar-week-day-bookings" }, dayBookings.map((booking) => {
|
|
3794
|
+
var _a, _b;
|
|
3795
|
+
return (React.createElement("div", { key: booking.meeting_id, className: "calendar-booking calendar-week-booking", onClick: (e) => {
|
|
3796
|
+
e.stopPropagation();
|
|
3797
|
+
if (onBookingClick) {
|
|
3798
|
+
onBookingClick(booking);
|
|
3799
|
+
}
|
|
3800
|
+
}, title: ((_a = booking.metadata) === null || _a === void 0 ? void 0 : _a.title) || 'Untitled' },
|
|
3801
|
+
React.createElement("span", { className: "calendar-booking-time" }, format(parseISO(booking.start), 'HH:mm')),
|
|
3802
|
+
React.createElement("span", { className: "calendar-booking-title" }, ((_b = booking.metadata) === null || _b === void 0 ? void 0 : _b.title) || 'Untitled')));
|
|
3803
|
+
}))));
|
|
3804
|
+
}
|
|
3805
|
+
return React.createElement("div", { className: "calendar-week-view" }, days);
|
|
3806
|
+
};
|
|
3807
|
+
const renderDayView = () => {
|
|
3808
|
+
const dayBookings = getBookingsForDay(currentDate);
|
|
3809
|
+
const isToday = isSameDay(currentDate, new Date());
|
|
3810
|
+
return (React.createElement("div", { className: "calendar-day-view" },
|
|
3811
|
+
React.createElement("div", { className: `calendar-day-container ${isToday ? 'calendar-cell-today' : ''}` },
|
|
3812
|
+
React.createElement("div", { className: "calendar-day-header" },
|
|
3813
|
+
React.createElement("div", { className: "calendar-day-name" }, format(currentDate, 'EEEE')),
|
|
3814
|
+
React.createElement("div", { className: "calendar-day-date" }, format(currentDate, 'MMMM d, yyyy'))),
|
|
3815
|
+
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) => {
|
|
3816
|
+
var _a, _b, _c;
|
|
3817
|
+
return (React.createElement("div", { key: booking.meeting_id, className: "calendar-booking calendar-day-booking", onClick: () => {
|
|
3818
|
+
if (onBookingClick) {
|
|
3819
|
+
onBookingClick(booking);
|
|
3820
|
+
}
|
|
3821
|
+
}, title: ((_a = booking.metadata) === null || _a === void 0 ? void 0 : _a.title) || 'Untitled' },
|
|
3822
|
+
React.createElement("span", { className: "calendar-booking-time" },
|
|
3823
|
+
format(parseISO(booking.start), 'HH:mm'),
|
|
3824
|
+
" - ",
|
|
3825
|
+
format(parseISO(booking.end), 'HH:mm')),
|
|
3826
|
+
React.createElement("span", { className: "calendar-booking-title" }, ((_b = booking.metadata) === null || _b === void 0 ? void 0 : _b.title) || 'Untitled'),
|
|
3827
|
+
((_c = booking.metadata) === null || _c === void 0 ? void 0 : _c.description) && (React.createElement("span", { className: "calendar-booking-description" }, booking.metadata.description))));
|
|
3828
|
+
}))),
|
|
3829
|
+
React.createElement("button", { className: "calendar-btn calendar-day-add-btn", onClick: () => handleDateClick(currentDate) }, "+ Add Booking"))));
|
|
3830
|
+
};
|
|
3661
3831
|
return (React.createElement("div", { className: "calendar-container" },
|
|
3662
3832
|
renderHeader(),
|
|
3663
3833
|
error && React.createElement("div", { className: "calendar-error" }, error),
|
|
3664
3834
|
loading && React.createElement("div", { className: "calendar-loading" }, "Loading..."),
|
|
3665
|
-
|
|
3666
|
-
|
|
3835
|
+
currentView === 'month' && (React.createElement(React.Fragment, null,
|
|
3836
|
+
renderDaysOfWeek(),
|
|
3837
|
+
renderMonthView())),
|
|
3838
|
+
currentView === 'week' && renderWeekView(),
|
|
3839
|
+
currentView === 'day' && renderDayView(),
|
|
3667
3840
|
showCreateModal && (React.createElement(CreateBookingModal, { businessId: businessId, apiBaseUrl: apiBaseUrl, initialDate: selectedDate || new Date(), participants: participants, onClose: () => {
|
|
3668
3841
|
setShowCreateModal(false);
|
|
3669
3842
|
setSelectedDate(null);
|