mirror of
https://github.com/formbricks/formbricks.git
synced 2026-03-11 19:52:25 -05:00
Co-authored-by: Matthias Nannt <mail@matthiasnannt.com> Co-authored-by: Dhruwang <dhruwangjariwala18@gmail.com> Co-authored-by: Johannes <72809645+jobenjada@users.noreply.github.com> Co-authored-by: Johannes <johannes@formbricks.com>
40 lines
924 B
TypeScript
40 lines
924 B
TypeScript
import { revalidateTag } from "next/cache";
|
|
|
|
interface RevalidateProps {
|
|
id?: string;
|
|
userId?: string;
|
|
productId?: string;
|
|
organizationId?: string;
|
|
}
|
|
|
|
export const teamCache = {
|
|
tag: {
|
|
byId(id: string) {
|
|
return `team-${id}`;
|
|
},
|
|
byProductId(productId: string) {
|
|
return `product-teams-${productId}`;
|
|
},
|
|
byUserId(userId: string) {
|
|
return `user-${userId}-teams`;
|
|
},
|
|
byOrganizationId(organizationId: string) {
|
|
return `organization-${organizationId}-teams`;
|
|
},
|
|
},
|
|
revalidate({ id, productId, userId, organizationId }: RevalidateProps): void {
|
|
if (id) {
|
|
revalidateTag(this.tag.byId(id));
|
|
}
|
|
if (productId) {
|
|
revalidateTag(this.tag.byProductId(productId));
|
|
}
|
|
if (userId) {
|
|
revalidateTag(this.tag.byUserId(userId));
|
|
}
|
|
if (organizationId) {
|
|
revalidateTag(this.tag.byOrganizationId(organizationId));
|
|
}
|
|
},
|
|
};
|