mirror of
https://github.com/formbricks/formbricks.git
synced 2026-01-06 05:40:02 -06: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>
27 lines
608 B
TypeScript
27 lines
608 B
TypeScript
import { revalidateTag } from "next/cache";
|
|
|
|
interface RevalidateProps {
|
|
userId?: string;
|
|
organizationId?: string;
|
|
}
|
|
|
|
export const membershipCache = {
|
|
tag: {
|
|
byOrganizationId(organizationId: string) {
|
|
return `organizations-${organizationId}-memberships`;
|
|
},
|
|
byUserId(userId: string) {
|
|
return `users-${userId}-memberships`;
|
|
},
|
|
},
|
|
revalidate({ organizationId, userId }: RevalidateProps): void {
|
|
if (organizationId) {
|
|
revalidateTag(this.tag.byOrganizationId(organizationId));
|
|
}
|
|
|
|
if (userId) {
|
|
revalidateTag(this.tag.byUserId(userId));
|
|
}
|
|
},
|
|
};
|