mirror of
https://github.com/formbricks/formbricks.git
synced 2026-01-06 05:40:02 -06:00
35 lines
932 B
TypeScript
35 lines
932 B
TypeScript
import { revalidateTag } from "next/cache";
|
|
|
|
interface RevalidateProps {
|
|
id?: string;
|
|
environmentId?: string;
|
|
key?: string;
|
|
}
|
|
|
|
export const contactAttributeKeyCache = {
|
|
tag: {
|
|
byId(id: string) {
|
|
return `contactAttributeKey-${id}`;
|
|
},
|
|
byEnvironmentId(environmentId: string) {
|
|
return `environments-${environmentId}-contactAttributeKeys`;
|
|
},
|
|
byEnvironmentIdAndKey(environmentId: string, key: string) {
|
|
return `contactAttributeKey-environment-${environmentId}-key-${key}`;
|
|
},
|
|
},
|
|
revalidate: ({ id, environmentId, key }: RevalidateProps): void => {
|
|
if (id) {
|
|
revalidateTag(contactAttributeKeyCache.tag.byId(id));
|
|
}
|
|
|
|
if (environmentId) {
|
|
revalidateTag(contactAttributeKeyCache.tag.byEnvironmentId(environmentId));
|
|
}
|
|
|
|
if (environmentId && key) {
|
|
revalidateTag(contactAttributeKeyCache.tag.byEnvironmentIdAndKey(environmentId, key));
|
|
}
|
|
},
|
|
};
|