Skip to content

Scheduling infrastructure for absolutely everyone.

feat(bookings): implement Booking UID filter for bookings data table. (#21380)

Akarsh Jainf84c8239e718
diff --git a/apps/web/modules/bookings/views/bookings-listing-view.tsx b/apps/web/modules/bookings/views/bookings-listing-view.tsx
index f13d2351276..c74bf84af7f 100644
--- a/apps/web/modules/bookings/views/bookings-listing-view.tsx
+++ b/apps/web/modules/bookings/views/bookings-listing-view.tsx
@@ -115,6 +115,7 @@ function BookingsContent({ status }: BookingsProps) {
const dateRange = useFilterValue("dateRange", ZDateRangeFilterValue)?.data;
const attendeeName = useFilterValue("attendeeName", ZTextFilterValue);
const attendeeEmail = useFilterValue("attendeeEmail", ZTextFilterValue);
+ const bookingUid = useFilterValue("bookingUid", ZTextFilterValue)?.data?.operand as string | undefined;
const { limit, offset } = useDataTable();
@@ -128,6 +129,7 @@ function BookingsContent({ status }: BookingsProps) {
userIds,
attendeeName,
attendeeEmail,
+ bookingUid,
afterStartDate: dateRange?.startDate
? dayjs(dateRange?.startDate).startOf("day").toISOString()
: undefined,
@@ -214,6 +216,21 @@ function BookingsContent({ status }: BookingsProps) {
},
},
}),
+ columnHelper.accessor((row) => row.type === "data" && row.booking.uid, {
+ id: "bookingUid",
+ header: t("booking_uid"),
+ enableColumnFilter: true,
+ enableSorting: false,
+ cell: () => null,
+ meta: {
+ filter: {
+ type: ColumnFilterType.TEXT,
+ textOptions: {
+ allowedOperators: ["equals"],
+ },
+ },
+ },
+ }),
columnHelper.display({
id: "customView",
cell: (props) => {
@@ -336,6 +353,7 @@ function BookingsContent({ status }: BookingsProps) {
attendeeName: false,
attendeeEmail: false,
dateRange: false,
+ bookingUid: false,
},
},
getCoreRowModel: getCoreRowModel(),
diff --git a/apps/web/public/static/locales/en/common.json b/apps/web/public/static/locales/en/common.json
index 8cafd6a522d..28b2a3ab9de 100644
--- a/apps/web/public/static/locales/en/common.json
+++ b/apps/web/public/static/locales/en/common.json
@@ -1779,6 +1779,7 @@
"number_sms_notifications": "Phone number (SMS notifications)",
"attendee_email_variable": "Attendee email",
"attendee_email_info": "The person booking's email",
+ "booking_uid": "Booking UID",
"kbar_search_placeholder": "Type a command or search...",
"invalid_credential": "It looks like permissions expired or were revoked for {{appName}}.",
"invalid_credential_action": "Reinstall app",
diff --git a/packages/lib/bookings/getAllUserBookings.ts b/packages/lib/bookings/getAllUserBookings.ts
index 7d870d30ebb..39934544da4 100644
--- a/packages/lib/bookings/getAllUserBookings.ts
+++ b/packages/lib/bookings/getAllUserBookings.ts
@@ -28,6 +28,7 @@ type GetOptions = {
eventTypeIds?: number[] | undefined;
attendeeEmail?: string | TextFilterValue;
attendeeName?: string | TextFilterValue;
+ bookingUid?: string | undefined;
};
sort?: SortOptions;
};
diff --git a/packages/platform/types/bookings/2024-08-13/inputs/get-bookings.input.ts b/packages/platform/types/bookings/2024-08-13/inputs/get-bookings.input.ts
index e302378c78c..2abcfa1b91b 100644
--- a/packages/platform/types/bookings/2024-08-13/inputs/get-bookings.input.ts
+++ b/packages/platform/types/bookings/2024-08-13/inputs/get-bookings.input.ts
@@ -81,6 +81,16 @@ export class GetBookingsInput_2024_08_13 {
})
attendeeName?: string;
+ @IsString()
+ @IsOptional()
+ @ApiProperty({
+ type: String,
+ required: false,
+ description: "Filter bookings by the booking Uid.",
+ example: "2NtaeaVcKfpmSZ4CthFdfk",
+ })
+ bookingUid?: string;
+
@IsOptional()
@Transform(({ value }) => {
if (typeof value === "string") {
diff --git a/packages/trpc/server/routers/viewer/bookings/get.handler.ts b/packages/trpc/server/routers/viewer/bookings/get.handler.ts
index 8b286dc0635..c2d79dcd72c 100644
--- a/packages/trpc/server/routers/viewer/bookings/get.handler.ts
+++ b/packages/trpc/server/routers/viewer/bookings/get.handler.ts
@@ -355,7 +355,12 @@ export async function getBookings({
}
}
- // 6. Booking Start/End Time Range Filters
+ // 6. Filter by Booking Uid (if provided)
+ if (filters?.bookingUid) {
+ fullQuery = fullQuery.where("Booking.uid", "=", filters.bookingUid.trim());
+ }
+
+ // 7. Booking Start/End Time Range Filters
if (filters?.afterStartDate) {
fullQuery = fullQuery.where("Booking.startTime", ">=", dayjs.utc(filters.afterStartDate).toDate());
}
diff --git a/packages/trpc/server/routers/viewer/bookings/get.schema.ts b/packages/trpc/server/routers/viewer/bookings/get.schema.ts
index 5a438068eee..97cc5683984 100644
--- a/packages/trpc/server/routers/viewer/bookings/get.schema.ts
+++ b/packages/trpc/server/routers/viewer/bookings/get.schema.ts
@@ -10,6 +10,7 @@ export const ZGetInputSchema = z.object({
eventTypeIds: z.number().array().optional(),
attendeeEmail: z.union([z.string(), ZTextFilterValue]).optional(),
attendeeName: z.union([z.string(), ZTextFilterValue]).optional(),
+ bookingUid: z.string().optional(),
afterStartDate: z.string().optional(),
beforeEndDate: z.string().optional(),
afterUpdatedDate: z.string().optional(),