feat: Setting for rescheduling past bookings (#18358)
* feat: Setting for rescheduling past bookings * fix stuff * rename column * add e2e test * fix column name * fix typo --------- Co-authored-by: Anik Dhabal Babu <[email protected]> Co-authored-by: Peer Richelsen <[email protected]> Co-authored-by: CarinaWolli <[email protected]>
This commit is contained in:
17 files changed
+97
-17
No files matched your search
@@ -216,7 +216,7 @@ function BookingListItem(booking: BookingItemProps) {
|
||||
];
|
||||
|
||||
const editBookingActions: ActionType[] = [
|
||||
...(isBookingInPast
|
||||
...(isBookingInPast && !booking.eventType.allowReschedulingPastBookings
|
||||
? []
|
||||
: [
|
||||
{
|
||||
|
||||
@@ -37,6 +37,7 @@ export const getEventTypesFromDB = async (id: number) => {
|
||||
price: true,
|
||||
currency: true,
|
||||
bookingFields: true,
|
||||
allowReschedulingPastBookings: true,
|
||||
disableGuests: true,
|
||||
timeZone: true,
|
||||
profile: {
|
||||
|
||||
@@ -57,6 +57,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
},
|
||||
},
|
||||
slug: true,
|
||||
allowReschedulingPastBookings: true,
|
||||
team: {
|
||||
select: {
|
||||
parentId: true,
|
||||
@@ -131,7 +132,7 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
});
|
||||
|
||||
const isBookingInPast = booking.endTime && new Date(booking.endTime) < new Date();
|
||||
if (isBookingInPast) {
|
||||
if (isBookingInPast && !eventType.allowReschedulingPastBookings) {
|
||||
const destinationUrlSearchParams = new URLSearchParams();
|
||||
const responses = bookingSeat ? getSafe<string>(bookingSeat.data, ["responses"]) : booking.responses;
|
||||
const name = getSafe<string>(responses, ["name"]);
|
||||
|
||||
@@ -730,22 +730,23 @@ export default function Success(props: PageProps) {
|
||||
</span>
|
||||
|
||||
<>
|
||||
{!props.recurringBookings && !isBookingInPast && (
|
||||
<span className="text-default inline">
|
||||
<span className="underline" data-testid="reschedule-link">
|
||||
<Link
|
||||
href={`/reschedule/${seatReferenceUid || bookingInfo?.uid}${
|
||||
currentUserEmail
|
||||
? `?rescheduledBy=${encodeURIComponent(currentUserEmail)}`
|
||||
: ""
|
||||
}`}
|
||||
legacyBehavior>
|
||||
{t("reschedule")}
|
||||
</Link>
|
||||
{!props.recurringBookings &&
|
||||
(!isBookingInPast || eventType.allowReschedulingPastBookings) && (
|
||||
<span className="text-default inline">
|
||||
<span className="underline" data-testid="reschedule-link">
|
||||
<Link
|
||||
href={`/reschedule/${seatReferenceUid || bookingInfo?.uid}${
|
||||
currentUserEmail
|
||||
? `?rescheduledBy=${encodeURIComponent(currentUserEmail)}`
|
||||
: ""
|
||||
}`}
|
||||
legacyBehavior>
|
||||
{t("reschedule")}
|
||||
</Link>
|
||||
</span>
|
||||
<span className="mx-2">{t("or_lowercase")}</span>
|
||||
</span>
|
||||
<span className="mx-2">{t("or_lowercase")}</span>
|
||||
</span>
|
||||
)}
|
||||
)}
|
||||
|
||||
<button
|
||||
data-testid="cancel"
|
||||
|
||||
@@ -50,6 +50,53 @@ test.describe("Reschedule Tests", async () => {
|
||||
await booking.delete();
|
||||
});
|
||||
|
||||
test("Should not show reschedule and request reschedule option if booking in past and disallowed", async ({
|
||||
page,
|
||||
users,
|
||||
bookings,
|
||||
}) => {
|
||||
const user = await users.create();
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const booking = await bookings.create(user.id, user.username, user.eventTypes[0].id!, {
|
||||
status: BookingStatus.ACCEPTED,
|
||||
startTime: dayjs().subtract(2, "day").toDate(),
|
||||
endTime: dayjs().subtract(2, "day").add(30, "minutes").toDate(),
|
||||
});
|
||||
|
||||
await prisma.eventType.update({
|
||||
where: {
|
||||
id: user.eventTypes[0].id,
|
||||
},
|
||||
data: {
|
||||
allowReschedulingPastBookings: true,
|
||||
},
|
||||
});
|
||||
|
||||
await user.apiLogin();
|
||||
await page.goto("/bookings/past");
|
||||
|
||||
await page.locator('[data-testid="edit_booking"]').nth(0).click();
|
||||
|
||||
await expect(page.locator('[data-testid="reschedule"]')).toBeVisible();
|
||||
await expect(page.locator('[data-testid="reschedule_request"]')).toBeVisible();
|
||||
|
||||
await prisma.eventType.update({
|
||||
where: {
|
||||
id: user.eventTypes[0].id,
|
||||
},
|
||||
data: {
|
||||
allowReschedulingPastBookings: false,
|
||||
},
|
||||
});
|
||||
|
||||
await page.reload();
|
||||
|
||||
await page.locator('[data-testid="edit_booking"]').nth(0).click();
|
||||
|
||||
await expect(page.locator('[data-testid="reschedule"]')).toBeHidden();
|
||||
await expect(page.locator('[data-testid="reschedule_request"]')).toBeHidden();
|
||||
});
|
||||
|
||||
test("Should display former time when rescheduling availability", async ({ page, users, bookings }) => {
|
||||
const user = await users.create();
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
|
||||
@@ -2907,6 +2907,8 @@
|
||||
"attribute_weight_enabled_description": "By enabling weights, it would be possible to assign higher priority to certain attributes per user. The higher the weight, the higher the priority.",
|
||||
"routed": "Routed",
|
||||
"reassigned": "Reassigned",
|
||||
"allow_rescheduling_past_events": "Allow rescheduling past events",
|
||||
"allow_rescheduling_past_events_description": "Enabling this option allows for past events to be rescheduled",
|
||||
"rerouted": "Rerouted",
|
||||
"salesforce_assigned": "Salesforce assignment",
|
||||
"router_position": "Router Position",
|
||||
|
||||
Reference in new issue
Block a user