Booking confirm endpoint refactoring (#2949)

* Adds new default handler and responder

* Moved confirm endpoint

* Fixes availability for unconfirmed bookings

* Cleanup

* Update _patch.ts

* Prevent too much diffs

* Adds missing BookingStatus

* Migrates confirmed & rejected to status

* Adds requiresConfirmation icon to listing

* Adds booking status migration

* Adds migrations to remove confirmed/rejected

* Undo refactor

* Sets the organizer as "accepted" in gCal

* Update getBusyTimes.ts

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Omar Lópezandkodiakhq[bot] authored and GitHub committed 2022-06-06 10:54:47 -06:00
1 parent 3b321e5d3c
commit 12d66cb9df
27 files changed
+393 -336

No files matched your search

@@ -14,7 +14,6 @@ import type {
IntegrationCalendar,
NewCalendarEventType,
} from "@calcom/types/Calendar";
import type { PartialReference } from "@calcom/types/EventManager";
import getAppKeysFromSlug from "../../_utils/getAppKeysFromSlug";
@@ -103,11 +102,8 @@ export default class GoogleCalendarService implements Calendar {
timeZone: calEventRaw.organizer.timeZone,
},
attendees: [
{ ...calEventRaw.organizer, organizer: true },
...calEventRaw.attendees.map((attendee) => ({
...attendee,
responseStatus: "accepted",
})),
{ ...calEventRaw.organizer, organizer: true, responseStatus: "accepted" },
...calEventRaw.attendees.map((attendee) => ({ ...attendee, responseStatus: "accepted" })),
],
reminders: {
useDefault: true,
@@ -185,7 +181,7 @@ export default class GoogleCalendarService implements Calendar {
dateTime: event.endTime,
timeZone: event.organizer.timeZone,
},
attendees: event.attendees,
attendees: [{ ...event.organizer, organizer: true, responseStatus: "accepted" }, ...event.attendees],
reminders: {
useDefault: true,
},
@@ -0,0 +1,11 @@
-- Set BookingStatus.PENDING
UPDATE "Booking" SET "status" = 'pending' WHERE "confirmed" = false AND "rejected" = false AND "rescheduled" IS NOT true;
-- Set BookingStatus.REJECTED
UPDATE "Booking" SET "status" = 'rejected' WHERE "confirmed" = false AND "rejected" = true AND "rescheduled" IS NOT true;
-- Set BookingStatus.CANCELLED
UPDATE "Booking" SET "status" = 'cancelled' WHERE "confirmed" = false AND "rejected" = false AND "rescheduled" IS true;
-- Set BookingStatus.ACCEPTED
UPDATE "Booking" SET "status" = 'accepted' WHERE "confirmed" = true AND "rejected" = false AND "rescheduled" IS NOT true;
@@ -0,0 +1,10 @@
/*
Warnings:
- You are about to drop the column `confirmed` on the `Booking` table. All the data in the column will be lost.
- You are about to drop the column `rejected` on the `Booking` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "Booking" DROP COLUMN "confirmed",
DROP COLUMN "rejected";
-2
View File
@@ -273,8 +273,6 @@ model Booking {
dailyRef DailyEventReference?
createdAt DateTime @default(now())
updatedAt DateTime?
confirmed Boolean @default(true)
rejected Boolean @default(false)
status BookingStatus @default(ACCEPTED)
paid Boolean @default(false)
payment Payment[]
+14 -14
View File
@@ -1,4 +1,4 @@
import { MembershipRole, Prisma, UserPlan } from "@prisma/client";
import { BookingStatus, MembershipRole, Prisma, UserPlan } from "@prisma/client";
import dayjs from "dayjs";
import { uuid } from "short-uuid";
@@ -110,7 +110,7 @@ async function createUserAndEventType(opts: {
id,
},
},
confirmed: bookingInput.confirmed,
status: bookingInput.status,
},
});
console.log(
@@ -238,7 +238,7 @@ async function main() {
title: "30min",
startTime: dayjs().add(2, "day").toDate(),
endTime: dayjs().add(2, "day").add(30, "minutes").toDate(),
confirmed: false,
status: BookingStatus.PENDING,
},
],
},
@@ -289,7 +289,7 @@ async function main() {
recurringEventId: Buffer.from("yoga-class").toString("base64"),
startTime: dayjs().add(1, "day").toDate(),
endTime: dayjs().add(1, "day").add(30, "minutes").toDate(),
confirmed: false,
status: BookingStatus.PENDING,
},
{
uid: uuid(),
@@ -297,7 +297,7 @@ async function main() {
recurringEventId: Buffer.from("yoga-class").toString("base64"),
startTime: dayjs().add(1, "day").add(1, "week").toDate(),
endTime: dayjs().add(1, "day").add(1, "week").add(30, "minutes").toDate(),
confirmed: false,
status: BookingStatus.PENDING,
},
{
uid: uuid(),
@@ -305,7 +305,7 @@ async function main() {
recurringEventId: Buffer.from("yoga-class").toString("base64"),
startTime: dayjs().add(1, "day").add(2, "week").toDate(),
endTime: dayjs().add(1, "day").add(2, "week").add(30, "minutes").toDate(),
confirmed: false,
status: BookingStatus.PENDING,
},
{
uid: uuid(),
@@ -313,7 +313,7 @@ async function main() {
recurringEventId: Buffer.from("yoga-class").toString("base64"),
startTime: dayjs().add(1, "day").add(3, "week").toDate(),
endTime: dayjs().add(1, "day").add(3, "week").add(30, "minutes").toDate(),
confirmed: false,
status: BookingStatus.PENDING,
},
{
uid: uuid(),
@@ -321,7 +321,7 @@ async function main() {
recurringEventId: Buffer.from("yoga-class").toString("base64"),
startTime: dayjs().add(1, "day").add(4, "week").toDate(),
endTime: dayjs().add(1, "day").add(4, "week").add(30, "minutes").toDate(),
confirmed: false,
status: BookingStatus.PENDING,
},
{
uid: uuid(),
@@ -329,7 +329,7 @@ async function main() {
recurringEventId: Buffer.from("yoga-class").toString("base64"),
startTime: dayjs().add(1, "day").add(5, "week").toDate(),
endTime: dayjs().add(1, "day").add(5, "week").add(30, "minutes").toDate(),
confirmed: false,
status: BookingStatus.PENDING,
},
],
},
@@ -346,7 +346,7 @@ async function main() {
recurringEventId: Buffer.from("tennis-class").toString("base64"),
startTime: dayjs().add(2, "day").toDate(),
endTime: dayjs().add(2, "day").add(60, "minutes").toDate(),
confirmed: false,
status: BookingStatus.PENDING,
},
{
uid: uuid(),
@@ -354,7 +354,7 @@ async function main() {
recurringEventId: Buffer.from("tennis-class").toString("base64"),
startTime: dayjs().add(2, "day").add(2, "week").toDate(),
endTime: dayjs().add(2, "day").add(2, "week").add(60, "minutes").toDate(),
confirmed: false,
status: BookingStatus.PENDING,
},
{
uid: uuid(),
@@ -362,7 +362,7 @@ async function main() {
recurringEventId: Buffer.from("tennis-class").toString("base64"),
startTime: dayjs().add(2, "day").add(4, "week").toDate(),
endTime: dayjs().add(2, "day").add(4, "week").add(60, "minutes").toDate(),
confirmed: false,
status: BookingStatus.PENDING,
},
{
uid: uuid(),
@@ -370,7 +370,7 @@ async function main() {
recurringEventId: Buffer.from("tennis-class").toString("base64"),
startTime: dayjs().add(2, "day").add(8, "week").toDate(),
endTime: dayjs().add(2, "day").add(8, "week").add(60, "minutes").toDate(),
confirmed: false,
status: BookingStatus.PENDING,
},
{
uid: uuid(),
@@ -378,7 +378,7 @@ async function main() {
recurringEventId: Buffer.from("tennis-class").toString("base64"),
startTime: dayjs().add(2, "day").add(10, "week").toDate(),
endTime: dayjs().add(2, "day").add(10, "week").add(60, "minutes").toDate(),
confirmed: false,
status: BookingStatus.PENDING,
},
],
},
+15
View File
@@ -0,0 +1,15 @@
import { Prisma } from "@prisma/client";
export const baseEventTypeSelect = Prisma.validator<Prisma.EventTypeSelect>()({
id: true,
title: true,
description: true,
length: true,
schedulingType: true,
recurringEvent: true,
slug: true,
hidden: true,
price: true,
currency: true,
requiresConfirmation: true,
});
+1
View File
@@ -1 +1,2 @@
export * from "./booking";
export * from "./event-types";