mirror of
https://github.com/formbricks/formbricks.git
synced 2026-02-05 02:58:36 -06:00
fix: display count not getting decremented
This commit is contained in:
@@ -30,7 +30,9 @@ export default async function Page({ params }) {
|
||||
getEnvironment(params.environmentId),
|
||||
]);
|
||||
const isSingleUseSurvey = survey.singleUse?.enabled ?? false;
|
||||
const singleUseIds = generateSingleUseIds(survey.singleUse?.isEncrypted ?? false);
|
||||
const singleUseIds = survey.singleUse?.enabled
|
||||
? generateSingleUseIds(survey.singleUse?.isEncrypted ?? false)
|
||||
: undefined;
|
||||
if (!environment) {
|
||||
throw new Error("Environment not found");
|
||||
}
|
||||
|
||||
@@ -374,7 +374,7 @@ export const deleteResponse = async (responseId: string): Promise<TResponse> =>
|
||||
person: responsePrisma.person ? transformPrismaPerson(responsePrisma.person) : null,
|
||||
tags: responsePrisma.tags.map((tagPrisma: { tag: TTag }) => tagPrisma.tag),
|
||||
};
|
||||
deleteDisplayByResponseId(responseId);
|
||||
deleteDisplayByResponseId(responseId, response.surveyId);
|
||||
return response;
|
||||
} catch (error) {
|
||||
if (error instanceof Prisma.PrismaClientKnownRequestError) {
|
||||
|
||||
@@ -41,14 +41,6 @@ const selectDisplay = {
|
||||
},
|
||||
status: true,
|
||||
};
|
||||
export const getDisplayCount = async (surveyId) => {
|
||||
const numDisplays = await prisma.display.findMany({
|
||||
where: {
|
||||
surveyId,
|
||||
},
|
||||
});
|
||||
return numDisplays;
|
||||
};
|
||||
|
||||
export const updateDisplay = async (
|
||||
displayId: string,
|
||||
@@ -214,7 +206,7 @@ export const getDisplaysOfPerson = cache(
|
||||
}
|
||||
);
|
||||
|
||||
export const deleteDisplayByResponseId = async (responseId: string): Promise<void> => {
|
||||
export const deleteDisplayByResponseId = async (responseId: string, surveyId: string): Promise<void> => {
|
||||
validateInputs([responseId, ZId]);
|
||||
try {
|
||||
await prisma.display.delete({
|
||||
@@ -222,13 +214,11 @@ export const deleteDisplayByResponseId = async (responseId: string): Promise<voi
|
||||
responseId,
|
||||
},
|
||||
});
|
||||
console.log("deleted");
|
||||
revalidateTag(getDisplaysCacheTag(surveyId));
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
if (error instanceof Prisma.PrismaClientKnownRequestError) {
|
||||
throw new DatabaseError("Database operation failed");
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user