From a56c354e84e790ab4de8c58ce8ed4aad6d434564 Mon Sep 17 00:00:00 2001 From: Dhruwang Jariwala <67850763+Dhruwang@users.noreply.github.com> Date: Wed, 13 Mar 2024 14:40:09 +0530 Subject: [PATCH] fix: Incorrect created_at value while duplicating a survey (#2217) Co-authored-by: Matti Nannt --- packages/lib/survey/service.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/lib/survey/service.ts b/packages/lib/survey/service.ts index 4e0346f7c6..7776722c3c 100644 --- a/packages/lib/survey/service.ts +++ b/packages/lib/survey/service.ts @@ -503,7 +503,7 @@ export const createSurvey = async (environmentId: string, surveyBody: TSurveyInp export const duplicateSurvey = async (environmentId: string, surveyId: string, userId: string) => { validateInputs([environmentId, ZId], [surveyId, ZId]); const existingSurvey = await getSurvey(surveyId); - + const currentDate = new Date(); if (!existingSurvey) { throw new ResourceNotFoundError("Survey", surveyId); } @@ -516,6 +516,8 @@ export const duplicateSurvey = async (environmentId: string, surveyId: string, u ...existingSurvey, id: undefined, // id is auto-generated environmentId: undefined, // environmentId is set below + createdAt: currentDate, + updatedAt: currentDate, createdBy: undefined, name: `${existingSurvey.name} (copy)`, status: "draft",