mirror of
https://github.com/formbricks/formbricks.git
synced 2026-03-03 21:10:09 -06:00
Fix Link Survey not pulling the right product (#726)
This commit is contained in:
@@ -8,18 +8,17 @@ import { getProductByEnvironmentId } from "@formbricks/lib/services/product";
|
||||
import SurveyInactive from "@/app/s/[surveyId]/SurveyInactive";
|
||||
|
||||
export default async function LinkSurveyPage({ params }) {
|
||||
const [survey, product] = await Promise.all([
|
||||
getSurvey(params.surveyId),
|
||||
getProductByEnvironmentId(params.environmentId),
|
||||
]);
|
||||
const survey = await getSurvey(params.surveyId);
|
||||
|
||||
if (!survey) {
|
||||
return <SurveyInactive status="not found" />;
|
||||
}
|
||||
|
||||
if (survey && survey.status !== "inProgress") {
|
||||
return <SurveyInactive status={survey.status} surveyClosedMessage={survey.surveyClosedMessage} />;
|
||||
}
|
||||
|
||||
if (survey === null) {
|
||||
return <SurveyInactive status="not found" />;
|
||||
}
|
||||
const product = await getProductByEnvironmentId(survey.environmentId);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -23,6 +23,9 @@ const selectProduct = {
|
||||
};
|
||||
|
||||
export const getProductByEnvironmentId = cache(async (environmentId: string): Promise<TProduct> => {
|
||||
if (!environmentId) {
|
||||
throw new ValidationError("EnvironmentId is required");
|
||||
}
|
||||
let productPrisma;
|
||||
try {
|
||||
productPrisma = await prisma.product.findFirst({
|
||||
|
||||
Reference in New Issue
Block a user