Files
formbricks-formbricks/packages/lib/action/cache.ts
Anshuman Pandey 53ef8771f3 feat: Make formbricks-js ready for public websites (#1470)
Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
Co-authored-by: Johannes <johannes@formbricks.com>
2023-11-12 09:12:58 +00:00

26 lines
625 B
TypeScript

import { revalidateTag } from "next/cache";
interface RevalidateProps {
environmentId?: string;
personId?: string;
}
export const actionCache = {
tag: {
byEnvironmentId(environmentId: string): string {
return `environments-${environmentId}-actions`;
},
byPersonId(personId: string): string {
return `environments-${personId}-actions`;
},
},
revalidate({ environmentId, personId }: RevalidateProps): void {
if (environmentId) {
revalidateTag(this.tag.byEnvironmentId(environmentId));
}
if (personId) {
revalidateTag(this.tag.byPersonId(personId));
}
},
};