Skip to content

Commit

Permalink
Revalidate booking pages on updateProfile (#7941)
Browse files Browse the repository at this point in the history
  • Loading branch information
roae authored Mar 25, 2023
1 parent a571d40 commit 0365157
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/trpc/server/routers/viewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { DestinationCalendar, Prisma } from "@prisma/client";
import { AppCategories, BookingStatus, IdentityProvider } from "@prisma/client";
import { cityMapping } from "city-timezones";
import { reverse } from "lodash";
import type { NextApiResponse } from "next";
import { authenticator } from "otplib";
import z from "zod";

Expand Down Expand Up @@ -709,6 +710,25 @@ const loggedInViewerRouter = router({
},
});
}
// Revalidate booking pages
const res = ctx.res as NextApiResponse;
if (typeof res?.revalidate !== "undefined") {
const eventTypes = await prisma.eventType.findMany({
where: {
userId: user.id,
team: null,
hidden: false,
},
select: {
id: true,
slug: true,
},
});
// waiting for this isn't needed
Promise.all(eventTypes.map((eventType) => res?.revalidate(`/${ctx.user.username}/${eventType.slug}`)))
.then(() => console.info("Booking pages revalidated"))
.catch((e) => console.error(e));
}
}),
eventTypeOrder: authedProcedure
.input(
Expand Down

1 comment on commit 0365157

@vercel
Copy link

@vercel vercel bot commented on 0365157 Mar 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ui – ./apps/storybook

ui-cal.vercel.app
cal-com-storybook.vercel.app
ui-git-main-cal.vercel.app
ui.cal.com
www.timelessui.com
timelessui.com

Please sign in to comment.