Scheduling infrastructure for absolutely everyone.
Made UID unique, implemented cancel API, Prepared mail footer,
nicolasd05ae49e8d8c
diff --git a/lib/emails/confirm-booked.ts b/lib/emails/confirm-booked.tsindex 32c4569515f..c792e4f5e09 100644--- a/lib/emails/confirm-booked.ts+++ b/lib/emails/confirm-booked.ts@@ -46,6 +46,10 @@ const sendEmail = (calEvent: CalendarEvent, {)});+//TODO: Get links+const cancelLink = "TODO";+const rescheduleLink = "TODO";+const html = (calEvent: CalendarEvent) => {const inviteeStart: Dayjs = <Dayjs>dayjs(calEvent.startTime).tz(calEvent.attendees[0].timeZone);return `@@ -58,7 +62,11 @@ const html = (calEvent: CalendarEvent) => {calEvent.location ? `<strong>Location:</strong> ${calEvent.location}<br /><br />` : '') +`Additional notes:<br />- ${calEvent.description}+ ${calEvent.description}<br />+ <br />+ Need to change this event?<br />+ Cancel: {cancelLink}<br />+ Reschedule: {rescheduleLink}</div>`;};diff --git a/pages/api/cancel.ts b/pages/api/cancel.tsnew file mode 100644index 00000000000..c5fb5341052--- /dev/null+++ b/pages/api/cancel.ts@@ -0,0 +1,40 @@+import prisma from '../../lib/prisma';++export default async function handler(req, res) {+ if (req.method == "POST") {+ const uid = req.body.uid;++ const bookingToDelete = await prisma.booking.findFirst({+ where: {+ uid: uid,+ },+ select: {+ id: true,+ attendees: true,+ references: true+ }+ });++ await prisma.attendee.deleteMany({+ where: {+ bookingId: bookingToDelete.id+ }+ });++ await prisma.bookingReference.deleteMany({+ where: {+ bookingId: bookingToDelete.id+ }+ });++ //TODO Delete booking from calendar integrations++ const deleteBooking = await prisma.booking.delete({+ where: {+ id: bookingToDelete.id,+ },+ });++ res.status(200).json({message: 'Booking deleted successfully'});+ }+}\ No newline at end of filediff --git a/prisma/migrations/20210606013704_made_booking_uid_unique/migration.sql b/prisma/migrations/20210606013704_made_booking_uid_unique/migration.sqlnew file mode 100644index 00000000000..e510da7c0e0--- /dev/null+++ b/prisma/migrations/20210606013704_made_booking_uid_unique/migration.sql@@ -0,0 +1,8 @@+/*+ Warnings:++ - A unique constraint covering the columns `[uid]` on the table `Booking` will be added. If there are existing duplicate values, this will fail.++*/+-- CreateIndex+CREATE UNIQUE INDEX "Booking.uid_unique" ON "Booking"("uid");diff --git a/prisma/schema.prisma b/prisma/schema.prismaindex aa58d8a963d..593308e4aae 100644--- a/prisma/schema.prisma+++ b/prisma/schema.prisma@@ -69,7 +69,7 @@ model Attendee {model Booking {id Int @default(autoincrement()) @id- uid String+ uid String @uniqueuser User? @relation(fields: [userId], references: [id])userId Int?references BookingReference[]