mirror of
https://github.com/formbricks/formbricks.git
synced 2025-12-30 18:30:32 -06:00
40 lines
949 B
TypeScript
40 lines
949 B
TypeScript
import { revalidateTag } from "next/cache";
|
|
|
|
interface RevalidateProps {
|
|
id?: string;
|
|
userId?: string;
|
|
projectId?: string;
|
|
organizationId?: string;
|
|
}
|
|
|
|
export const teamCache = {
|
|
tag: {
|
|
byId(id: string) {
|
|
return `team-${id}`;
|
|
},
|
|
byProjectId(projectId: string) {
|
|
return `project-teams-${projectId}`;
|
|
},
|
|
byUserId(userId: string) {
|
|
return `user-${userId}-teams`;
|
|
},
|
|
byOrganizationId(organizationId: string) {
|
|
return `organization-${organizationId}-teams`;
|
|
},
|
|
},
|
|
revalidate: ({ id, projectId, userId, organizationId }: RevalidateProps): void => {
|
|
if (id) {
|
|
revalidateTag(teamCache.tag.byId(id));
|
|
}
|
|
if (projectId) {
|
|
revalidateTag(teamCache.tag.byProjectId(projectId));
|
|
}
|
|
if (userId) {
|
|
revalidateTag(teamCache.tag.byUserId(userId));
|
|
}
|
|
if (organizationId) {
|
|
revalidateTag(teamCache.tag.byOrganizationId(organizationId));
|
|
}
|
|
},
|
|
};
|