mirror of
https://github.com/formbricks/formbricks.git
synced 2026-01-06 05:40:02 -06:00
43 lines
952 B
TypeScript
43 lines
952 B
TypeScript
import { revalidateTag } from "next/cache";
|
|
|
|
interface RevalidateProps {
|
|
id?: string;
|
|
surveyId?: string;
|
|
personId?: string | null;
|
|
environmentId?: string;
|
|
}
|
|
|
|
export const displayCache = {
|
|
tag: {
|
|
byId(id: string) {
|
|
return `displays-${id}`;
|
|
},
|
|
bySurveyId(surveyId: string) {
|
|
return `surveys-${surveyId}-displays`;
|
|
},
|
|
byPersonId(personId: string) {
|
|
return `people-${personId}-displays`;
|
|
},
|
|
byEnvironmentId(environmentId: string) {
|
|
return `environments-${environmentId}-displays`;
|
|
},
|
|
},
|
|
revalidate({ id, surveyId, personId, environmentId }: RevalidateProps): void {
|
|
if (id) {
|
|
revalidateTag(this.tag.byId(id));
|
|
}
|
|
|
|
if (surveyId) {
|
|
revalidateTag(this.tag.bySurveyId(surveyId));
|
|
}
|
|
|
|
if (personId) {
|
|
revalidateTag(this.tag.byPersonId(personId));
|
|
}
|
|
|
|
if (environmentId) {
|
|
revalidateTag(this.tag.byEnvironmentId(environmentId));
|
|
}
|
|
},
|
|
};
|