fix: Provide event rescheduling option before the event end time (#15150)
* feat: Provide event rescheduling option * update * update * add checker function * refactor and update * update * fix type error * Update bookings-single-view.tsx --------- Co-authored-by: Somay Chauhan <[email protected]>
This commit is contained in:
1 parent
ececef96e5
commit
3807e339ce
3 files changed
+43
-14
No files matched your search
@@ -129,6 +129,16 @@ const NoAvailabilityOverlay = ({
|
||||
);
|
||||
};
|
||||
|
||||
const ReschedulingNotPossibleOverlay = () => {
|
||||
const { t } = useLocale();
|
||||
|
||||
return (
|
||||
<div className="bg-muted border-subtle absolute left-1/2 top-40 -mt-10 w-2/3 -translate-x-1/2 -translate-y-1/2 transform break-all rounded-md border p-8 shadow-sm">
|
||||
<h4 className="text-emphasis font-medium">{t("rescheduling_not_possible")}</h4>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const Days = ({
|
||||
minDate,
|
||||
excludedDates = [],
|
||||
@@ -141,6 +151,7 @@ const Days = ({
|
||||
eventSlug,
|
||||
slots,
|
||||
customClassName,
|
||||
isBookingInPast,
|
||||
...props
|
||||
}: Omit<DatePickerProps, "locale" | "className" | "weekStart"> & {
|
||||
DayComponent?: React.FC<React.ComponentProps<typeof Day>>;
|
||||
@@ -153,6 +164,7 @@ const Days = ({
|
||||
datePickerDateActive?: string;
|
||||
};
|
||||
scrollToTimeSlots?: () => void;
|
||||
isBookingInPast: boolean;
|
||||
}) => {
|
||||
// Create placeholder elements for empty days in first week
|
||||
const weekdayOfFirst = browsingDate.date(1).day();
|
||||
@@ -279,7 +291,9 @@ const Days = ({
|
||||
</div>
|
||||
))}
|
||||
|
||||
{!props.isPending && includedDates && includedDates?.length === 0 && (
|
||||
{isBookingInPast && <ReschedulingNotPossibleOverlay />}
|
||||
|
||||
{!props.isPending && !isBookingInPast && includedDates && includedDates?.length === 0 && (
|
||||
<NoAvailabilityOverlay month={month} nextMonthButton={nextMonthButton} />
|
||||
)}
|
||||
</>
|
||||
@@ -294,6 +308,7 @@ const DatePicker = ({
|
||||
onMonthChange,
|
||||
slots,
|
||||
customClassNames,
|
||||
includedDates,
|
||||
...passThroughProps
|
||||
}: DatePickerProps &
|
||||
Partial<React.ComponentProps<typeof Days>> & {
|
||||
@@ -308,6 +323,8 @@ const DatePicker = ({
|
||||
}) => {
|
||||
const browsingDate = passThroughProps.browsingDate || dayjs().startOf("month");
|
||||
const { i18n } = useLocale();
|
||||
const bookingData = useBookerStore((state) => state.bookingData);
|
||||
const isBookingInPast = bookingData ? new Date(bookingData.endTime) < new Date() : false;
|
||||
|
||||
const changeMonth = (newMonth: number) => {
|
||||
if (onMonthChange) {
|
||||
@@ -357,11 +374,13 @@ const DatePicker = ({
|
||||
<Button
|
||||
className={classNames(
|
||||
`group p-1 opacity-70 transition hover:opacity-100 rtl:rotate-180`,
|
||||
isBookingInPast && `disabled:text-bookinglighter hover:bg-background hover:opacity-70`,
|
||||
`${customClassNames?.datePickerToggle}`
|
||||
)}
|
||||
onClick={() => changeMonth(+1)}
|
||||
data-testid="incrementMonth"
|
||||
color="minimal"
|
||||
disabled={isBookingInPast}
|
||||
variant="icon"
|
||||
StartIcon="chevron-right"
|
||||
/>
|
||||
@@ -387,12 +406,14 @@ const DatePicker = ({
|
||||
datePickerDateActive: customClassNames?.datePickerDatesActive,
|
||||
}}
|
||||
weekStart={weekStart}
|
||||
selected={selected}
|
||||
selected={!isBookingInPast ? selected : null}
|
||||
{...passThroughProps}
|
||||
browsingDate={browsingDate}
|
||||
month={month}
|
||||
nextMonthButton={() => changeMonth(+1)}
|
||||
slots={slots}
|
||||
slots={!isBookingInPast ? slots : {}}
|
||||
includedDates={!isBookingInPast ? includedDates : []}
|
||||
isBookingInPast={isBookingInPast}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user