feat: Internal Notes for bookings (#18804)

* migration + migrate booking limit page to team settings

* new pages

* use settings toggle for displaying content

* get current team presets

* update mutation

* i18n for settings page

* remove redudant await

* cancelation UI for select

* handle other selection

* extract into a util

* inital cancelation reason flow

* fix i18n to be more readable

* add cancel reason logic

* nits

* improve copy

* ensure is teamMember and not isAdmin for getting internalNotes

* improvie spacing between elements

* fix types

* more type fixes

* correct types

* Update packages/features/bookings/lib/handleNewBooking/getEventTypesFromDB.ts

* use input component and remove mb-2 to allign with icon button

* Update packages/trpc/server/routers/viewer/teams/updateInternalNotesPresets.handler.ts

Co-authored-by: Eunjae Lee <[email protected]>

* nits

* type fixs

* fix type

* fix type

* fix nullable option lost in merge

---------

Co-authored-by: Eunjae Lee <[email protected]>
This commit is contained in:
sean-brydonandEunjae Lee authored and GitHub committed 2025-01-24 09:26:52 +00:00
1 parent 1fd4c3fd4c
commit 656d6dc195
22 files changed
+683 -22

No files matched your search

@@ -0,0 +1,52 @@
-- CreateTable
CREATE TABLE "InternalNotePreset" (
"id" SERIAL NOT NULL,
"name" TEXT NOT NULL,
"cancellationReason" TEXT,
"teamId" INTEGER NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "InternalNotePreset_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "BookingInternalNote" (
"id" SERIAL NOT NULL,
"notePresetId" INTEGER,
"text" TEXT,
"bookingId" INTEGER NOT NULL,
"createdById" INTEGER NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "BookingInternalNote_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "InternalNotePreset_teamId_idx" ON "InternalNotePreset"("teamId");
-- CreateIndex
CREATE UNIQUE INDEX "InternalNotePreset_teamId_name_key" ON "InternalNotePreset"("teamId", "name");
-- CreateIndex
CREATE INDEX "BookingInternalNote_bookingId_idx" ON "BookingInternalNote"("bookingId");
-- CreateIndex
CREATE UNIQUE INDEX "BookingInternalNote_bookingId_notePresetId_key" ON "BookingInternalNote"("bookingId", "notePresetId");
-- CreateIndex
CREATE INDEX "Impersonations_impersonatedUserId_idx" ON "Impersonations"("impersonatedUserId");
-- CreateIndex
CREATE INDEX "Impersonations_impersonatedById_idx" ON "Impersonations"("impersonatedById");
-- AddForeignKey
ALTER TABLE "InternalNotePreset" ADD CONSTRAINT "InternalNotePreset_teamId_fkey" FOREIGN KEY ("teamId") REFERENCES "Team"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "BookingInternalNote" ADD CONSTRAINT "BookingInternalNote_notePresetId_fkey" FOREIGN KEY ("notePresetId") REFERENCES "InternalNotePreset"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "BookingInternalNote" ADD CONSTRAINT "BookingInternalNote_bookingId_fkey" FOREIGN KEY ("bookingId") REFERENCES "Booking"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "BookingInternalNote" ADD CONSTRAINT "BookingInternalNote_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
+40 -1
View File
@@ -366,6 +366,7 @@ model User {
updatedTranslations EventTypeTranslation[] @relation("UpdatedEventTypeTranslations")
createdWatchlists Watchlist[] @relation("CreatedWatchlists")
updatedWatchlists Watchlist[] @relation("UpdatedWatchlists")
BookingInternalNote BookingInternalNote[]
@@unique([email])
@@unique([email, username])
@@ -473,7 +474,8 @@ model Team {
/// @zod.custom(imports.intervalLimitsType)
bookingLimits Json?
includeManagedEventsInLimits Boolean @default(false)
includeManagedEventsInLimits Boolean @default(false)
internalNotePresets InternalNotePreset[]
@@unique([slug, parentId])
@@index([parentId])
@@ -668,6 +670,7 @@ model Booking {
// Ah, made a typo here. Should have been routedFromRoutingFormRe"s"ponse. Live with it :(
routedFromRoutingFormReponse App_RoutingForms_FormResponse?
assignmentReason AssignmentReason[]
internalNote BookingInternalNote[]
@@index([eventTypeId])
@@index([userId])
@@ -870,6 +873,9 @@ model Impersonations {
impersonatedBy User @relation("impersonated_by_user", fields: [impersonatedById], references: [id], onDelete: Cascade)
impersonatedUserId Int
impersonatedById Int
@@index([impersonatedUserId])
@@index([impersonatedById])
}
model ApiKey {
@@ -1824,3 +1830,36 @@ model App_RoutingForms_IncompleteBookingActions {
enabled Boolean @default(true)
credentialId Int?
}
model InternalNotePreset {
id Int @id @default(autoincrement())
name String
cancellationReason String?
team Team @relation(fields: [teamId], references: [id])
teamId Int
createdAt DateTime @default(now())
BookingInternalNote BookingInternalNote[]
@@unique([teamId, name])
@@index([teamId])
}
model BookingInternalNote {
id Int @id @default(autoincrement())
notePreset InternalNotePreset? @relation(fields: [notePresetId], references: [id], onDelete: Cascade)
notePresetId Int?
text String?
booking Booking @relation(fields: [bookingId], references: [id], onDelete: Cascade)
bookingId Int
createdBy User @relation(fields: [createdById], references: [id])
createdById Int
createdAt DateTime @default(now())
@@unique([bookingId, notePresetId])
@@index([bookingId])
}
+8
View File
@@ -370,6 +370,14 @@ export const bookingCancelSchema = z.object({
cancellationReason: z.string().optional(),
seatReferenceUid: z.string().optional(),
cancelledBy: z.string().email({ message: "Invalid email" }).optional(),
internalNote: z
.object({
id: z.number(),
name: z.string(),
cancellationReason: z.string().optional(),
})
.optional()
.nullable(),
});
export const bookingCancelAttendeeSeatSchema = z.object({