Revalidate calendar cache when user change de selected calendars-

This commit is contained in:
Efrain Rochin Aramburo 2023-02-08 12:27:49 -07:00
parent a0c81eba88
commit fb2412b5ce

View File

@ -1,4 +1,5 @@
import type { NextApiRequest, NextApiResponse } from "next";
import { revalidateCalendarCache } from "pages/api/revalidate-calendar-cache/[username]";
import { getCalendarCredentials, getConnectedCalendars } from "@calcom/core/CalendarManager";
import notEmpty from "@calcom/lib/notEmpty";
@ -65,6 +66,10 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
res.status(200).json({ message: "Calendar Selection Saved" });
}
if (["DELETE", "POST"].includes(req.method)) {
await revalidateCalendarCache(res.revalidate, `${session?.user?.username}`);
}
if (req.method === "GET") {
const selectedCalendarIds = await prisma.selectedCalendar.findMany({
where: {