Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

πŸ”₯ Drop the sign-up sheets feature (#2443)

Luke Vella19d886b3ea8d
diff --git a/apps/web/public/locales/en/app.json b/apps/web/public/locales/en/app.json
index 6fdb1f4ba..683829198 100644
--- a/apps/web/public/locales/en/app.json
+++ b/apps/web/public/locales/en/app.json
@@ -402,7 +402,6 @@
"newParticipantFormDescription": "Fill in the form below to submit your votes.",
"newPassword": "New Password",
"newPoll": "New Poll",
- "newSignupSheet": "New Sign-up Sheet",
"nextMonth": "Next month",
"no": "No",
"noApiKeys": "No API keys found",
@@ -591,15 +590,11 @@
"setupPasswordButton": "Set up password",
"setupPasswordDescription": "Your account doesn't have a password yet. Click the button below to send a secure link to your email to set a password.",
"share": "Share",
- "sheetUpdatedRelative": "Updated {relativeTime}",
"showBrandingDescription": "Show your brand identity on your public pages and emails",
"shrink": "Shrink",
"signIn": "Sign in",
"signOut": "Sign Out",
"signUp": "Sign Up",
- "signupSheets": "Sign-up Sheets",
- "signupSheetsEmptyDescription": "Create a sign-up sheet so people can book the time slots you offer.",
- "signupSheetsEmptyTitle": "No sign-up sheets yet",
"space": "Space",
"spaceInviteMember": "Invite Member",
"spaceName": "Space Name",
diff --git a/apps/web/src/app/[locale]/(space)/(dashboard)/sheets/page.tsx b/apps/web/src/app/[locale]/(space)/(dashboard)/sheets/page.tsx
deleted file mode 100644
index f960ec4ac..000000000
--- a/apps/web/src/app/[locale]/(space)/(dashboard)/sheets/page.tsx
+++ /dev/null
@@ -1,31 +0,0 @@
-import { dehydrate, HydrationBoundary } from "@tanstack/react-query";
-import type { Metadata } from "next";
-import { notFound } from "next/navigation";
-import { getTranslation } from "@/i18n/server";
-import { isFeatureEnabled } from "@/lib/feature-flags/server";
-import { createPrivateSSRHelper } from "@/trpc/server/create-ssr-helper";
-import { SheetsPage } from "./sheets-page";
-
-export default async function Page() {
- if (!isFeatureEnabled("signupSheets")) {
- notFound();
- }
-
- const helpers = await createPrivateSSRHelper();
- await helpers.sheets.list.prefetch();
-
- return (
- <HydrationBoundary state={dehydrate(helpers.queryClient)}>
- <SheetsPage />
- </HydrationBoundary>
- );
-}
-
-export async function generateMetadata(): Promise<Metadata> {
- const { t } = await getTranslation();
- return {
- title: t("signupSheets", {
- defaultValue: "Sign-up Sheets",
- }),
- };
-}
diff --git a/apps/web/src/app/[locale]/(space)/(dashboard)/sheets/sheets-page.tsx b/apps/web/src/app/[locale]/(space)/(dashboard)/sheets/sheets-page.tsx
deleted file mode 100644
index 18551bea4..000000000
--- a/apps/web/src/app/[locale]/(space)/(dashboard)/sheets/sheets-page.tsx
+++ /dev/null
@@ -1,136 +0,0 @@
-"use client";
-
-import { buttonVariants } from "@rallly/ui";
-import { shortUrl } from "@rallly/utils/absolute-url";
-import { ClipboardListIcon, PlusIcon } from "lucide-react";
-import Link from "next/link";
-import {
- PageContainer,
- PageContent,
- PageHeader,
- PageHeaderActions,
- PageHeaderContent,
- PageTitle,
-} from "@/app/components/page-layout";
-import { CopyLinkButton } from "@/components/copy-link-button";
-import {
- EmptyState,
- EmptyStateDescription,
- EmptyStateFooter,
- EmptyStateIcon,
- EmptyStateTitle,
-} from "@/components/empty-state";
-import { HoverPrefetchLink } from "@/components/hover-prefetch-link";
-import { StackedList, StackedListItem } from "@/components/stacked-list";
-import { Trans } from "@/i18n/client";
-import { dayjs } from "@/lib/dayjs";
-import { trpc } from "@/trpc/client";
-
-function SheetsEmptyState() {
- return (
- <EmptyState className="h-96">
- <EmptyStateIcon>
- <ClipboardListIcon />
- </EmptyStateIcon>
- <EmptyStateTitle>
- <Trans
- i18nKey="signupSheetsEmptyTitle"
- defaults="No sign-up sheets yet"
- />
- </EmptyStateTitle>
- <EmptyStateDescription>
- <Trans
- i18nKey="signupSheetsEmptyDescription"
- defaults="Create a sign-up sheet so people can book the time slots you offer."
- />
- </EmptyStateDescription>
- <EmptyStateFooter>
- <Link
- href="/sheets/new"
- className={buttonVariants({ variant: "primary" })}
- >
- <PlusIcon data-icon="inline-start" />
- <Trans i18nKey="newSignupSheet" defaults="New Sign-up Sheet" />
- </Link>
- </EmptyStateFooter>
- </EmptyState>
- );
-}
-
-function SheetListItem({
- id,
- title,
- urlId,
- updatedAt,
-}: {
- id: string;
- title: string;
- urlId: string;
- updatedAt: Date;
-}) {
- return (
- <StackedListItem>
- <div className="relative -m-4 flex min-w-0 flex-1 items-center gap-2 p-4">
- <HoverPrefetchLink
- className="min-w-0 text-sm hover:underline focus:ring-ring focus-visible:ring-2"
- href={`/sheets/${id}`}
- >
- <span className="absolute inset-0" />
- <span className="block truncate font-medium">{title}</span>
- </HoverPrefetchLink>
- </div>
- <div className="flex items-center gap-4">
- <span className="hidden text-muted-foreground text-sm sm:inline">
- <Trans
- i18nKey="sheetUpdatedRelative"
- defaults="Updated {relativeTime}"
- values={{ relativeTime: dayjs(updatedAt).fromNow() }}
- />
- </span>
- <CopyLinkButton href={shortUrl(`/sheet/${urlId}`)} />
- </div>
- </StackedListItem>
- );
-}
-
-export function SheetsPage() {
- const [{ sheets }] = trpc.sheets.list.useSuspenseQuery();
-
- return (
- <PageContainer>
- <PageHeader>
- <PageHeaderContent>
- <PageTitle>
- <Trans i18nKey="signupSheets" defaults="Sign-up Sheets" />
- </PageTitle>
- </PageHeaderContent>
- <PageHeaderActions>
- <Link
- href="/sheets/new"
- className={buttonVariants({ variant: "primary" })}
- >
- <PlusIcon data-icon="inline-start" />
- <Trans i18nKey="newSignupSheet" defaults="New Sign-up Sheet" />
- </Link>
- </PageHeaderActions>
- </PageHeader>
- <PageContent>
- {sheets.length === 0 ? (
- <SheetsEmptyState />
- ) : (
- <StackedList>
- {sheets.map((sheet) => (
- <SheetListItem
- key={sheet.id}
- id={sheet.id}
- title={sheet.title}
- urlId={sheet.urlId}
- updatedAt={sheet.updatedAt}
- />
- ))}
- </StackedList>
- )}
- </PageContent>
- </PageContainer>
- );
-}
diff --git a/apps/web/src/features/navigation/config.tsx b/apps/web/src/features/navigation/config.tsx
index 965bec274..57b12c55e 100644
--- a/apps/web/src/features/navigation/config.tsx
+++ b/apps/web/src/features/navigation/config.tsx
@@ -5,7 +5,6 @@ import {
BarChart2Icon,
CalendarDaysIcon,
CalendarIcon,
- ClipboardListIcon,
HomeIcon,
} from "lucide-react";
import { usePathname } from "next/navigation";
@@ -38,7 +37,6 @@ export const useSpaceMenu = () => {
const { t } = useTranslation();
const pathname = usePathname();
const isCalendarsEnabled = useFeatureFlag("calendars");
- const isSignupSheetsEnabled = useFeatureFlag("signupSheets");
const config = React.useMemo<NavigationConfig>(
() => ({
sections: [
@@ -83,25 +81,11 @@ export const useSpaceMenu = () => {
},
]
: []),
- ...(isSignupSheetsEnabled
- ? [
- {
- id: "sheets",
- label: t("signupSheets", {
- defaultValue: "Sign-up Sheets",
- }),
- href: "/sheets",
- icon: ClipboardListIcon,
- isActive:
- pathname === "/sheets" || pathname.startsWith("/sheets/"),
- },
- ]
- : []),
],
},
],
}),
- [pathname, t, isCalendarsEnabled, isSignupSheetsEnabled],
+ [pathname, t, isCalendarsEnabled],
);
return React.useMemo(
diff --git a/apps/web/src/features/sheets/constants.ts b/apps/web/src/features/sheets/constants.ts
deleted file mode 100644
index 7705197df..000000000
--- a/apps/web/src/features/sheets/constants.ts
+++ /dev/null
@@ -1 +0,0 @@
-export const isSignupSheetsEnabled = process.env.NODE_ENV === "development";
diff --git a/apps/web/src/features/sheets/data.ts b/apps/web/src/features/sheets/data.ts
deleted file mode 100644
index c80d9248c..000000000
--- a/apps/web/src/features/sheets/data.ts
+++ /dev/null
@@ -1,139 +0,0 @@
-import type { EventType, Sheet, SheetSlot } from "@rallly/database";
-import { prisma } from "@rallly/database";
-import { createLogger } from "@rallly/logger";
-import type {
- SheetDetailDTO,
- SheetDTO,
- SheetSlotDTO,
-} from "@/features/sheets/types";
-import { locationSchema } from "@/lib/location";
-
-const logger = createLogger("sheets/data");
-
-type EventTypeForSlot = Pick<
- EventType,
- "id" | "name" | "duration" | "description" | "location" | "capacity"
->;
-
-type SlotWithRelations = SheetSlot & {
- eventType: EventTypeForSlot;
- scheduledEvent: {
- capacity: number | null;
- _count: { invites: number };
- } | null;
-};
-
-function parseLocation(
- raw: EventTypeForSlot["location"],
- context: { eventTypeId: string },
-) {
- if (raw === null) {
- return null;
- }
- const parsed = locationSchema.safeParse(raw);
- if (!parsed.success) {
- logger.warn(
- { eventTypeId: context.eventTypeId, value: raw },
- "Failed to parse event type location",
- );
- return null;
- }
- return parsed.data;
-}
-
-export function createSheetSlotDTO(slot: SlotWithRelations): SheetSlotDTO {
- return {
- id: slot.id,
- startTime: slot.startTime,
- eventType: {
- id: slot.eventType.id,
- name: slot.eventType.name,
- duration: slot.eventType.duration,
- description: slot.eventType.description,
- location: parseLocation(slot.eventType.location, {
- eventTypeId: slot.eventType.id,
- }),
- capacity: slot.eventType.capacity,
- },
- bookingCount: slot.scheduledEvent?._count.invites ?? 0,
- capacity: slot.scheduledEvent?.capacity ?? slot.eventType.capacity,
- };
-}
-
-export function createSheetDTO(sheet: Sheet): SheetDTO {
- return {
- id: sheet.id,
- title: sheet.title,
- description: sheet.description,
- urlId: sheet.urlId,
- createdAt: sheet.createdAt,
- updatedAt: sheet.updatedAt,
- };
-}
-
-export function createSheetDetailDTO(
- sheet: Sheet & { slots: SlotWithRelations[] },
-): SheetDetailDTO {
- return {
- ...createSheetDTO(sheet),
- slots: sheet.slots.map(createSheetSlotDTO),
- };
-}
-
-const slotInclude = {
- eventType: {
- select: {
- id: true,
- name: true,
- duration: true,
- description: true,
- location: true,
- capacity: true,
- },
- },
- scheduledEvent: {
- select: {
- capacity: true,
- _count: { select: { invites: true } },
- },
- },
-} as const;
-
-export async function getSheets(spaceId: string): Promise<SheetDTO[]> {
- const rows = await prisma.sheet.findMany({
- where: { spaceId, deleted: false },
- orderBy: { updatedAt: "desc" },
- });
- return rows.map(createSheetDTO);
-}
-
-export async function getSheetById(
- id: string,
- spaceId: string,
-): Promise<SheetDetailDTO | null> {
- const sheet = await prisma.sheet.findFirst({
- where: { id, spaceId, deleted: false },
- include: {
- slots: {
- orderBy: { startTime: "asc" },
- include: slotInclude,
- },
- },
- });
- return sheet ? createSheetDetailDTO(sheet) : null;
-}
-
-export async function getSheetByUrlId(
- urlId: string,
-): Promise<SheetDetailDTO | null> {
- const sheet = await prisma.sheet.findFirst({
- where: { urlId, deleted: false },
- include: {
- slots: {
- orderBy: { startTime: "asc" },
- include: slotInclude,
- },
- },
- });
- return sheet ? createSheetDetailDTO(sheet) : null;
-}
diff --git a/apps/web/src/features/sheets/schema.ts b/apps/web/src/features/sheets/schema.ts
deleted file mode 100644
index ab56eecd5..000000000
--- a/apps/web/src/features/sheets/schema.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-import * as z from "zod";
-
-export const createSheetInputSchema = z.object({
- title: z.string().min(1).max(255),
-});
-
-export type CreateSheetInput = z.infer<typeof createSheetInputSchema>;
-
-export const updateSheetInputSchema = z.object({
- id: z.string(),
- title: z.string().min(1).max(255),
-});
-
-export type UpdateSheetInput = z.infer<typeof updateSheetInputSchema>;
-
-export const createSlotInputSchema = z.object({
- sheetId: z.string(),
- eventTypeId: z.string(),
- startTime: z.date(),
-});
-
-export type CreateSlotInput = z.infer<typeof createSlotInputSchema>;
-
-export const createBookingInputSchema = z.object({
- slotId: z.string(),
- name: z.string().min(1).max(100),
- email: z.email(),
- timeZone: z.string().min(1).max(64),
-});
-
-export type CreateBookingInput = z.infer<typeof createBookingInputSchema>;
diff --git a/apps/web/src/features/sheets/types.ts b/apps/web/src/features/sheets/types.ts
deleted file mode 100644
index e0679b63a..000000000
--- a/apps/web/src/features/sheets/types.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import type { Location } from "@/lib/location";
-
-export interface SheetDTO {
- id: string;
- title: string;
- description: string | null;
- urlId: string;
- createdAt: Date;
- updatedAt: Date;
-}
-
-export interface SheetSlotDTO {
- id: string;
- startTime: Date;
- eventType: {
- id: string;
- name: string;
- duration: number;
- description: string | null;
- location: Location | null;
- capacity: number | null;
- };
- bookingCount: number;
- capacity: number | null;
-}
-
-export interface SheetDetailDTO extends SheetDTO {
- slots: SheetSlotDTO[];
-}
diff --git a/apps/web/src/lib/feature-flags/config.ts b/apps/web/src/lib/feature-flags/config.ts
index da6bb1348..a4f9fd3fb 100644
--- a/apps/web/src/lib/feature-flags/config.ts
+++ b/apps/web/src/lib/feature-flags/config.ts
@@ -4,7 +4,6 @@ import { isBillingEnabled } from "@/features/billing/constants";
import { isCalendarsEnabled } from "@/features/calendars/constants";
import { isEventTypesEnabled } from "@/features/event-types/constants";
import { isFeedbackEnabled } from "@/features/feedback/constants";
-import { isSignupSheetsEnabled } from "@/features/sheets/constants";
import type { FeatureFlagConfig } from "@/lib/feature-flags/types";
import { isStorageEnabled } from "@/lib/storage";
@@ -19,5 +18,4 @@ export const featureFlagConfig: FeatureFlagConfig = {
registration: isEmailLoginEnabled && isRegistrationEnabled,
calendars: isCalendarsEnabled,
eventTypes: isEventTypesEnabled,
- signupSheets: isSignupSheetsEnabled,
};
diff --git a/apps/web/src/lib/feature-flags/types.ts b/apps/web/src/lib/feature-flags/types.ts
index 7ba5bf201..d939c7a19 100644
--- a/apps/web/src/lib/feature-flags/types.ts
+++ b/apps/web/src/lib/feature-flags/types.ts
@@ -6,7 +6,6 @@ export interface FeatureFlagConfig {
registration: boolean;
calendars: boolean;
eventTypes: boolean;
- signupSheets: boolean;
}
export type Feature = keyof FeatureFlagConfig;
diff --git a/apps/web/src/trpc/routers/index.ts b/apps/web/src/trpc/routers/index.ts
index f254d4900..cffc0f31a 100644
--- a/apps/web/src/trpc/routers/index.ts
+++ b/apps/web/src/trpc/routers/index.ts
@@ -9,7 +9,6 @@ import { dashboard } from "./dashboard";
import { eventTypes } from "./event-types";
import { events } from "./events";
import { polls } from "./polls";
-import { sheets } from "./sheets";
import { spaces } from "./spaces";
import { system } from "./system";
import { user } from "./user";
@@ -23,7 +22,6 @@ export const appRouter = mergeRouters(
eventTypes,
events,
polls,
- sheets,
spaces,
system,
user,
diff --git a/apps/web/src/trpc/routers/sheets.ts b/apps/web/src/trpc/routers/sheets.ts
deleted file mode 100644
index d1840deeb..000000000
--- a/apps/web/src/trpc/routers/sheets.ts
+++ /dev/null
@@ -1,381 +0,0 @@
-import { prisma } from "@rallly/database";
-import { nanoid } from "@rallly/utils/nanoid";
-import { TRPCError } from "@trpc/server";
-import * as z from "zod";
-import type { Conferencing } from "@/features/conferencing/schema";
-import type { Location as ScheduledEventLocation } from "@/features/location/schema";
-import { isSignupSheetsEnabled } from "@/features/sheets/constants";
-import {
- createSheetDTO,
- getSheetById,
- getSheetByUrlId,
- getSheets,
-} from "@/features/sheets/data";
-import {
- createBookingInputSchema,
- createSheetInputSchema,
- createSlotInputSchema,
- updateSheetInputSchema,
-} from "@/features/sheets/schema";
-import type { Location } from "@/lib/location";
-import { locationSchema } from "@/lib/location";
-import {
- mergeRouters,
- middleware,
- publicProcedure,
- router,
- spaceProcedure,
-} from "../trpc";
-
-const requireSignupSheetsEnabled = middleware(async ({ next }) => {
- if (!isSignupSheetsEnabled) {
- throw new TRPCError({
- code: "NOT_FOUND",
- message: "Sign-up sheets are not enabled",
- });
- }
- return next();
-});
-
-const sheetSpaceProcedure = spaceProcedure.use(requireSignupSheetsEnabled);
-const sheetPublicProcedure = publicProcedure.use(requireSignupSheetsEnabled);
-
-// Convert an EventType.location (in_person or custom_link) into the new
-// scheduled-event structured `location` / `conferencing` columns. An
-// in-person source becomes a custom location; a custom link becomes
-// conferencing metadata.
-function locationSnapshot(value: unknown): {
- location: ScheduledEventLocation | null;
- conferencing: Conferencing | null;
-} {
- if (value === null || value === undefined) {
- return { location: null, conferencing: null };
- }
- const parsed = locationSchema.safeParse(value);
- if (!parsed.success) {
- return { location: null, conferencing: null };
- }
- const source: Location = parsed.data;
- if (source.type === "in_person") {
- return {
- location: {
- provider: "custom",
- address: source.address,
- },
- conferencing: null,
- };
- }
- return {
- location: null,
- conferencing: {
- provider: "custom",
- uri: source.url,
- label: source.text ?? source.url,
- },
- };
-}
-
-const sheetsRoot = router({
- list: sheetSpaceProcedure.query(async ({ ctx }) => {
- const sheets = await getSheets(ctx.space.id);
- return { sheets };
- }),
-
- get: sheetSpaceProcedure
- .input(z.object({ id: z.string() }))
- .query(async ({ ctx, input }) => {
- const sheet = await getSheetById(input.id, ctx.space.id);
- if (!sheet) {
- throw new TRPCError({ code: "NOT_FOUND", message: "Sheet not found" });
- }
- return { sheet };
- }),
-
- getByUrlId: sheetPublicProcedure
- .input(z.object({ urlId: z.string() }))
- .query(async ({ input }) => {
- const sheet = await getSheetByUrlId(input.urlId);
- if (!sheet) {
- throw new TRPCError({ code: "NOT_FOUND", message: "Sheet not found" });
- }
- return { sheet };
- }),
-
- create: sheetSpaceProcedure
- .input(createSheetInputSchema)
- .mutation(async ({ ctx, input }) => {
- const created = await prisma.sheet.create({
- data: {
- spaceId: ctx.space.id,
- hostId: ctx.user.id,
- title: input.title,
- urlId: nanoid(),
- },
- });
- return { sheet: createSheetDTO(created) };
- }),
-
- update: sheetSpaceProcedure
- .input(updateSheetInputSchema)
- .mutation(async ({ ctx, input }) => {
- const updated = await prisma.sheet.updateMany({
- where: {
- id: input.id,
- spaceId: ctx.space.id,
- deleted: false,
- },
- data: {
- title: input.title,
- },
- });
- if (updated.count === 0) {
- throw new TRPCError({ code: "NOT_FOUND", message: "Sheet not found" });
- }
- return { success: true };
- }),
-
- softDelete: sheetSpaceProcedure
- .input(z.object({ id: z.string() }))
- .mutation(async ({ ctx, input }) => {
- const deleted = await prisma.sheet.updateMany({
- where: {
- id: input.id,
- spaceId: ctx.space.id,
- deleted: false,
- },
- data: {
- deleted: true,
- deletedAt: new Date(),
- },
- });
- if (deleted.count === 0) {
- throw new TRPCError({ code: "NOT_FOUND", message: "Sheet not found" });
- }
- return { success: true };
- }),
-});
-
-const slots = router({
- create: sheetSpaceProcedure
- .input(createSlotInputSchema)
- .mutation(async ({ ctx, input }) => {
- const sheet = await prisma.sheet.findFirst({
- where: {
- id: input.sheetId,
- spaceId: ctx.space.id,
- deleted: false,
- },
- select: { id: true },
- });
- if (!sheet) {
- throw new TRPCError({ code: "NOT_FOUND", message: "Sheet not found" });
- }
-
- const eventType = await prisma.eventType.findFirst({
- where: {
- id: input.eventTypeId,
- spaceId: ctx.space.id,
- deleted: false,
- },
- select: { id: true },
- });
- if (!eventType) {
- throw new TRPCError({
- code: "NOT_FOUND",
- message: "Event type not found in this space",
- });
- }
-
- const slot = await prisma.sheetSlot.create({
- data: {
- sheetId: input.sheetId,
- eventTypeId: input.eventTypeId,
- startTime: input.startTime,
- },
- });
-
- return {
- slot: {
- id: slot.id,
- sheetId: slot.sheetId,
- eventTypeId: slot.eventTypeId,
- startTime: slot.startTime,
- createdAt: slot.createdAt,
- updatedAt: slot.updatedAt,
- },
- };
- }),
-
- delete: sheetSpaceProcedure
- .input(z.object({ id: z.string() }))
- .mutation(async ({ ctx, input }) => {
- const slot = await prisma.sheetSlot.findFirst({
- where: {
- id: input.id,
- sheet: { spaceId: ctx.space.id, deleted: false },
- },
- select: {
- id: true,
- scheduledEvent: { select: { id: true } },
- },
- });
- if (!slot) {
- throw new TRPCError({ code: "NOT_FOUND", message: "Slot not found" });
- }
- if (slot.scheduledEvent) {
- throw new TRPCError({
- code: "CONFLICT",
- message:
- "Cannot delete a slot with bookings. Cancel the booking first.",
- });
- }
- await prisma.sheetSlot.delete({ where: { id: input.id } });
- return { success: true };
- }),
-});
-
-const bookings = router({
- create: sheetPublicProcedure
- .input(createBookingInputSchema)
- .mutation(async ({ input }) => {
- return await prisma.$transaction(async (tx) => {
- // Lock the slot row to serialize concurrent bookings on the same slot
- await tx.$queryRaw`SELECT id FROM "sheet_slots" WHERE id = ${input.slotId} FOR UPDATE`;
-
- const slot = await tx.sheetSlot.findFirst({
- where: {
- id: input.slotId,
- sheet: { deleted: false },
- },
- include: {
- sheet: { select: { spaceId: true } },
- eventType: {
- select: {
- id: true,
- name: true,
- description: true,
- location: true,
- duration: true,
- capacity: true,
- hostId: true,
- },
- },
- scheduledEvent: {
- select: {
- id: true,
- capacity: true,
- _count: { select: { invites: true } },
- },
- },
- },
- });
-
- if (!slot) {
- throw new TRPCError({
- code: "NOT_FOUND",
- message: "Slot not found",
- });
- }
-
- const capacity =
- slot.scheduledEvent?.capacity ?? slot.eventType.capacity;
- const currentCount = slot.scheduledEvent?._count.invites ?? 0;
-
- if (capacity !== null && currentCount >= capacity) {
- throw new TRPCError({
- code: "CONFLICT",
- message: "This slot is full",
- });
- }
-
- if (slot.scheduledEvent) {
- const existing = await tx.scheduledEventInvite.findFirst({
- where: {
- scheduledEventId: slot.scheduledEvent.id,
- inviteeEmail: input.email,
- },
- select: { id: true },
- });
- if (existing) {
- throw new TRPCError({
- code: "CONFLICT",
- message: "You've already booked this slot",
- });
- }
- }
-
- const inviteUid = nanoid();
- const endTime = new Date(
- slot.startTime.getTime() + slot.eventType.duration * 60_000,
- );
-
- if (slot.scheduledEvent) {
- await tx.scheduledEventInvite.create({
- data: {
- uid: inviteUid,
- scheduledEventId: slot.scheduledEvent.id,
- inviteeName: input.name,
- inviteeEmail: input.email,
- inviteeTimeZone: input.timeZone,
- status: "accepted",
- },
- });
- return {
- scheduledEventId: slot.scheduledEvent.id,
- attendeeUid: inviteUid,
- };
- }
-
- const host = await tx.user.findUnique({
- where: { id: slot.eventType.hostId },
- select: { timeZone: true },
- });
-
- const eventId = nanoid();
- const { location, conferencing } = locationSnapshot(
- slot.eventType.location,
- );
- const created = await tx.scheduledEvent.create({
- data: {
- id: eventId,
- uid: `${eventId}@rallly.co`,
- sheetSlotId: slot.id,
- eventTypeId: slot.eventType.id,
- userId: slot.eventType.hostId,
- spaceId: slot.sheet.spaceId,
- title: slot.eventType.name,
- description: slot.eventType.description,
- location: location ?? undefined,
- conferencing: conferencing ?? undefined,
- capacity: slot.eventType.capacity,
- start: slot.startTime,
- end: endTime,
- timeZone: host?.timeZone ?? null,
- status: "confirmed",
- invites: {
- create: {
- uid: inviteUid,
- inviteeName: input.name,
- inviteeEmail: input.email,
- inviteeTimeZone: input.timeZone,
- status: "accepted",
- },
- },
- },
- });
-
- return {
- scheduledEventId: created.id,
- attendeeUid: inviteUid,
- };
- });
- }),
-});
-
-export const sheets = mergeRouters(
- sheetsRoot,
- router({
- slots,
- bookings,
- }),
-);
diff --git a/packages/database/prisma/seed.ts b/packages/database/prisma/seed.ts
index 857aede60..64f4523c9 100644
--- a/packages/database/prisma/seed.ts
+++ b/packages/database/prisma/seed.ts
@@ -4,7 +4,6 @@ import {
eventTypes,
polls,
scheduledEvents,
- sheets,
spaceMembers,
spaces,
users,
@@ -191,20 +190,6 @@ async function main() {
})),
});
console.info(`βœ“ ${eventTypes.length} event types`);
-
- // 7. Sheets
- await prisma.sheet.createMany({
- data: sheets.map((sheet, i) => ({
- id: sheet.id,
- spaceId: sheet.spaceId,
- hostId: sheet.hostId,
- title: sheet.title,
- description: sheet.description,
- urlId: sheet.urlId,
- updatedAt: new Date(now - i * 60_000),
- })),
- });
- console.info(`βœ“ ${sheets.length} sheets`);
}
main()
diff --git a/packages/database/prisma/seed/data.ts b/packages/database/prisma/seed/data.ts
index 41b11159c..65c11e9c9 100644
--- a/packages/database/prisma/seed/data.ts
+++ b/packages/database/prisma/seed/data.ts
@@ -1020,61 +1020,6 @@ export type EventTypeDef = {
location: EventTypeLocation | null;
};
-export type SheetDef = {
- id: string;
- spaceId: string;
- hostId: string;
- title: string;
- description: string | null;
- urlId: string;
-};
-
-export const sheets: SheetDef[] = [
- // ── Personal space (space-1) ─────────────────────────────────────────────
- {
- id: "sheet-1",
- spaceId: "space-1",
- hostId: "user-1",
- title: "Coffee chat sign-ups",
- description: "Pick a slot for a 30 minute coffee chat next week.",
- urlId: "personal-coffee-chats",
- },
- {
- id: "sheet-2",
- spaceId: "space-1",
- hostId: "user-1",
- title: "Mentorship office hours",
- description: null,
- urlId: "personal-mentorship",
- },
-
- // ── Acme Inc (space-2) ───────────────────────────────────────────────────
- {
- id: "sheet-3",
- spaceId: "space-2",
- hostId: "user-3",
- title: "Engineering office hours",
- description: "Drop in for help with code reviews or architecture.",
- urlId: "acme-eng-office-hours",
- },
- {
- id: "sheet-4",
- spaceId: "space-2",
- hostId: "user-2",
- title: "Design critique slots",
- description: "30 minute critiques of in-progress designs.",
- urlId: "acme-design-critiques",
- },
- {
- id: "sheet-5",
- spaceId: "space-2",
- hostId: "user-1",
- title: "New hire intro chats",
- description: "Welcome chat with our newest team members.",
- urlId: "acme-new-hire-intros",
- },
-];
-
export const eventTypes: EventTypeDef[] = [
// ── Personal space (space-1) ─────────────────────────────────────────────
{