Feature/multiple schedules post turbo (#2150)
* Concluded merge * Applied stash to newly merged * Always disconnect + remove redundant success message * Added named dialog to replace new=1 * Merged with main p2 * Set eventTypeId to @unique * WIP * Undo vscode changes * Availability dropdown works * Remove console.log + set schedule to null as it is unneeded * Added schedule to availability endpoint * Reduce one refresh; hotfix state inconsistency with forced refresh for now * Add missing translations * Fixed some type errors I missed * Ditch outdated remnant from before packages/prisma * Remove Availability section for teams * Bringing back the Availability section temporarily to teams to allow configuration * Migrated getting-started to new availability system + updated translations + updated seed * Fixed type error coming from main * Titlecase 'default' by providing translation * Fixed broken 'radio' buttons. * schedule deleted translation added * Added empty state for when no schedules are configured * Added correct created message + hotfix reload hard on delete to refresh state * Removed index renames * Type fixes * Update NewScheduleButton.tsx Co-authored-by: zomars <[email protected]> Co-authored-by: Bailey Pumfleet <[email protected]> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
28 files changed
+1073
-1207
No files matched your search
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `label` on the `Availability` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `freeBusyTimes` on the `Schedule` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `title` on the `Schedule` table. All the data in the column will be lost.
|
||||
- A unique constraint covering the columns `[eventTypeId]` on the table `Schedule` will be added. If there are existing duplicate values, this will fail.
|
||||
- Added the required column `name` to the `Schedule` table without a default value. This is not possible if the table is not empty.
|
||||
- Made the column `userId` on table `Schedule` required. This step will fail if there are existing NULL values in that column.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "Availability" DROP COLUMN "label",
|
||||
ADD COLUMN "scheduleId" INTEGER;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Schedule" DROP COLUMN "freeBusyTimes",
|
||||
DROP COLUMN "title",
|
||||
ADD COLUMN "name" TEXT NOT NULL,
|
||||
ADD COLUMN "timeZone" TEXT,
|
||||
ALTER COLUMN "userId" SET NOT NULL;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "users" ADD COLUMN "defaultScheduleId" INTEGER;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Schedule_eventTypeId_key" ON "Schedule"("eventTypeId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Availability" ADD CONSTRAINT "Availability_scheduleId_fkey" FOREIGN KEY ("scheduleId") REFERENCES "Schedule"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -62,7 +62,7 @@ model EventType {
|
||||
beforeEventBuffer Int @default(0)
|
||||
afterEventBuffer Int @default(0)
|
||||
schedulingType SchedulingType?
|
||||
Schedule Schedule[]
|
||||
schedule Schedule?
|
||||
price Int @default(0)
|
||||
currency String @default("usd")
|
||||
slotInterval Int?
|
||||
@@ -128,7 +128,8 @@ model User {
|
||||
credentials Credential[]
|
||||
teams Membership[]
|
||||
bookings Booking[]
|
||||
availability Availability[]
|
||||
schedules Schedule[]
|
||||
defaultScheduleId Int?
|
||||
selectedCalendars SelectedCalendar[]
|
||||
completedOnboarding Boolean @default(false)
|
||||
locale String?
|
||||
@@ -137,9 +138,9 @@ model User {
|
||||
twoFactorEnabled Boolean @default(false)
|
||||
identityProvider IdentityProvider @default(CAL)
|
||||
identityProviderId String?
|
||||
availability Availability[]
|
||||
invitedTo Int?
|
||||
plan UserPlan @default(TRIAL)
|
||||
Schedule Schedule[]
|
||||
webhooks Webhook[]
|
||||
brandColor String @default("#292929")
|
||||
darkBrandColor String @default("#fafafa")
|
||||
@@ -255,18 +256,18 @@ model Booking {
|
||||
}
|
||||
|
||||
model Schedule {
|
||||
id Int @id @default(autoincrement())
|
||||
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
userId Int?
|
||||
eventType EventType? @relation(fields: [eventTypeId], references: [id])
|
||||
eventTypeId Int?
|
||||
title String?
|
||||
freeBusyTimes Json?
|
||||
id Int @id @default(autoincrement())
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
userId Int
|
||||
eventType EventType? @relation(fields: [eventTypeId], references: [id])
|
||||
eventTypeId Int? @unique
|
||||
name String
|
||||
timeZone String?
|
||||
availability Availability[]
|
||||
}
|
||||
|
||||
model Availability {
|
||||
id Int @id @default(autoincrement())
|
||||
label String?
|
||||
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
userId Int?
|
||||
eventType EventType? @relation(fields: [eventTypeId], references: [id])
|
||||
@@ -275,6 +276,8 @@ model Availability {
|
||||
startTime DateTime @db.Time
|
||||
endTime DateTime @db.Time
|
||||
date DateTime? @db.Date
|
||||
Schedule Schedule? @relation(fields: [scheduleId], references: [id])
|
||||
scheduleId Int?
|
||||
}
|
||||
|
||||
model SelectedCalendar {
|
||||
|
||||
+12
-5
@@ -29,11 +29,18 @@ async function createUserAndEventType(opts: {
|
||||
emailVerified: new Date(),
|
||||
completedOnboarding: opts.user.completedOnboarding ?? true,
|
||||
locale: "en",
|
||||
availability: {
|
||||
createMany: {
|
||||
data: getAvailabilityFromSchedule(DEFAULT_SCHEDULE),
|
||||
},
|
||||
},
|
||||
schedules: opts.user.completedOnboarding
|
||||
? {
|
||||
create: {
|
||||
name: "Working Hours",
|
||||
availability: {
|
||||
createMany: {
|
||||
data: getAvailabilityFromSchedule(DEFAULT_SCHEDULE),
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
: undefined,
|
||||
};
|
||||
const user = await prisma.user.upsert({
|
||||
where: { email: opts.user.email },
|
||||
|
||||
Reference in new issue
Block a user