mirror of
https://github.com/formbricks/formbricks.git
synced 2026-04-24 06:28:49 -05:00
295754480e
Co-authored-by: Matthias Nannt <mail@matthiasnannt.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));
|
|
}
|
|
},
|
|
};
|