perf: server-fetch data for all pages in /settings/my-account (#20712)

* wip

* fix type check

* refactor "/settings/my-account/profile"

* refactor "settings/my-account/general"

* refactor "/settings/my-accouunt/calendars"

* refactor "/settings/my-account/appearance"

* fix: type-check

---------

Co-authored-by: Amit Sharma <[email protected]>
Co-authored-by: Amit Sharma <[email protected]>
This commit is contained in:
authored and GitHub committed 2025-07-24 22:36:40 +01:00
1 parent 6259b0b3cb
commit 6b9115dfde
32 files changed
+721 -524

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
"use server";
import { revalidateTag, unstable_cache } from "next/cache";
import { NEXTJS_CACHE_TTL } from "@calcom/lib/constants";
import { MembershipRepository } from "@calcom/lib/server/repository/membership";
const CACHE_TAGS = {
HAS_TEAM_PLAN: "MembershipRepository.findFirstAcceptedMembershipByUserId",
} as const;
export const getCachedHasTeamPlan = unstable_cache(
async (userId: number) => {
const hasTeamPlan = await MembershipRepository.findFirstAcceptedMembershipByUserId(userId);
return { hasTeamPlan: !!hasTeamPlan };
},
["getCachedHasTeamPlan"],
{
revalidate: NEXTJS_CACHE_TTL,
tags: [CACHE_TAGS.HAS_TEAM_PLAN],
}
);
export const revalidateHasTeamPlan = async () => {
revalidateTag(CACHE_TAGS.HAS_TEAM_PLAN);
};
+11
View File
@@ -0,0 +1,11 @@
"use server";
import { revalidatePath } from "next/cache";
export async function revalidateSettingsProfile() {
revalidatePath("/settings/my-account/profile");
}
export async function revalidateSettingsCalendars() {
revalidatePath("/settings/my-account/calendars");
}
+26
View File
@@ -0,0 +1,26 @@
"use server";
import { revalidateTag } from "next/cache";
import { NEXTJS_CACHE_TTL } from "@calcom/lib/constants";
import { TravelScheduleRepository } from "@calcom/lib/server/repository/travelSchedule";
import { unstable_cache } from "@calcom/lib/unstable_cache";
const CACHE_TAGS = {
TRAVEL_SCHEDULES: "TravelRepository.findTravelSchedulesByUserId",
} as const;
export const getTravelSchedule = unstable_cache(
async (userId: number) => {
return await TravelScheduleRepository.findTravelSchedulesByUserId(userId);
},
["getTravelSchedule"],
{
revalidate: NEXTJS_CACHE_TTL,
tags: [CACHE_TAGS.TRAVEL_SCHEDULES],
}
);
export const revalidateTravelSchedules = async () => {
revalidateTag(CACHE_TAGS.TRAVEL_SCHEDULES);
};