perf: caching + modularize data fetching for team booking pages (#22172)

* wip

* wip

* wip

* refactor

* refactor

* refactor

* refactor

* refactor

* fix

* better

* fix

* fix

* use notFound

* refactor

* wip

* refactor

* wip

* refactor

* wip

* wip

* finalize

* wip

* fix

* lots of refactors

* better code

* clean up

* fix

* fix type checks

* finalize

* select more fields

* select more fields

* fix

* fix

* fix

* fix

* better

* better

* fix

* fix

* fix

* fix

* add back comment

* fix

* better

* fix

* refactor

* fix

* fix type check

* add comment

* fix

* wip

* wip

* add more comment

* refactor

* rename

* refactors

* fix reschedule logic

* remove hard-coded true from isCachedEnabled

* better

* use revalidateTeamDataCache in team profile update

* fix invalidation

* better comment

* refactors

* add better comments

* add revalidations

* add comments

* fix

* remove hard code

* fix

* update tags

* use features package

* fix type check
This commit is contained in:
Benny Joo authored and GitHub committed 2025-07-15 21:42:55 -03:00
1 parent e6da5c85e0
commit c4eda5f21d
19 files changed
+932 -5

No files matched your search

@@ -26,7 +26,7 @@ import { DEFAULT_LIGHT_BRAND_COLOR, DEFAULT_DARK_BRAND_COLOR, WEBAPP_URL } from
import { useRouterQuery } from "@calcom/lib/hooks/useRouterQuery";
import { BookerLayouts } from "@calcom/prisma/zod-utils";
type BookerWebWrapperAtomProps = BookerProps & {
export type BookerWebWrapperAtomProps = BookerProps & {
eventData?: NonNullable<Awaited<ReturnType<typeof getPublicEvent>>>;
};
+1
View File
@@ -1 +1,2 @@
export { BookerWebWrapper } from "./BookerWebWrapper";
export type { BookerWebWrapperAtomProps } from "./BookerWebWrapper";
@@ -20,6 +20,7 @@ import { trpc } from "@calcom/trpc/react";
import type { RouterOutputs } from "@calcom/trpc/react";
import useMeQuery from "@calcom/trpc/react/hooks/useMeQuery";
import { showToast } from "@calcom/ui/components/toast";
import { revalidateTeamEventTypeCache } from "@calcom/web/app/(booking-page-wrapper)/team/[slug]/[type]/actions";
import { revalidateEventTypeEditPage } from "@calcom/web/app/(use-page-wrapper)/event-types/[type]/actions";
import { TRPCClientError } from "@trpc/react-query";
@@ -138,6 +139,15 @@ const EventTypeWeb = ({ id, ...rest }: EventTypeSetupProps & { id: number }) =>
// Reset the form with these values as new default values to ensure the correct comparison for dirtyFields eval
form.reset(currentValues);
revalidateEventTypeEditPage(eventType.id);
if (eventType.team?.slug) {
// When an event-type is updated,
// guests could still hit a stale cache and see the old page.
revalidateTeamEventTypeCache({
teamSlug: eventType.team.slug,
meetingSlug: eventType.slug,
orgSlug: eventType.team.parent?.slug ?? null,
});
}
showToast(t("event_type_updated_successfully", { eventTypeTitle: eventType.title }), "success");
},
async onSettled() {
@@ -311,6 +321,15 @@ const EventTypeWeb = ({ id, ...rest }: EventTypeSetupProps & { id: number }) =>
const deleteMutation = trpc.viewer.eventTypes.delete.useMutation({
onSuccess: async () => {
await utils.viewer.eventTypes.invalidate();
if (team?.slug) {
// When a team event-type is deleted,
// guests could still hit a stale cache and see the old page.
revalidateTeamEventTypeCache({
teamSlug: team.slug,
meetingSlug: eventType.slug,
orgSlug: team.parent?.slug ?? null,
});
}
showToast(t("event_type_deleted_successfully"), "success");
isTeamEventTypeDeleted.current = true;
appRouter.push("/event-types");