mirror of
https://github.com/formbricks/formbricks.git
synced 2026-05-01 11:50:43 -05:00
718a199d5b
Co-authored-by: Dhruwang <dhruwangjariwala18@gmail.com>
33 lines
821 B
TypeScript
33 lines
821 B
TypeScript
import "server-only";
|
|
import { Prisma } from "@prisma/client";
|
|
import { cache as reactCache } from "react";
|
|
import { prisma } from "@formbricks/database";
|
|
import { DatabaseError } from "@formbricks/types/errors";
|
|
|
|
export interface PublishedLinkSurvey {
|
|
id: string;
|
|
name: string;
|
|
}
|
|
|
|
export const getPublishedLinkSurveys = reactCache(
|
|
async (environmentId: string): Promise<PublishedLinkSurvey[]> => {
|
|
try {
|
|
const surveys = await prisma.survey.findMany({
|
|
where: { environmentId, status: "inProgress", type: "link" },
|
|
select: {
|
|
id: true,
|
|
name: true,
|
|
},
|
|
});
|
|
|
|
return surveys;
|
|
} catch (error) {
|
|
if (error instanceof Prisma.PrismaClientKnownRequestError) {
|
|
throw new DatabaseError(error.message);
|
|
}
|
|
|
|
throw error;
|
|
}
|
|
}
|
|
);
|