mirror of
https://github.com/formbricks/formbricks.git
synced 2026-04-13 12:02:01 -05:00
fix: surveys management api input types (#2837)
This commit is contained in:
@@ -2,7 +2,7 @@ import { authenticateRequest, handleErrorResponse } from "@/app/api/v1/auth";
|
||||
import { responses } from "@/app/lib/api/response";
|
||||
import { transformErrorToDetails } from "@/app/lib/api/validator";
|
||||
import { deleteSurvey, getSurvey, updateSurvey } from "@formbricks/lib/survey/service";
|
||||
import { TSurvey, ZSurvey } from "@formbricks/types/surveys";
|
||||
import { TSurvey, ZSurveyUpdateInput } from "@formbricks/types/surveys";
|
||||
|
||||
const fetchAndAuthorizeSurvey = async (authentication: any, surveyId: string): Promise<TSurvey | null> => {
|
||||
const survey = await getSurvey(surveyId);
|
||||
@@ -68,7 +68,7 @@ export const PUT = async (
|
||||
console.error(`Error parsing JSON input: ${error}`);
|
||||
return responses.badRequestResponse("Malformed JSON input, please check your request body");
|
||||
}
|
||||
const inputValidation = ZSurvey.safeParse({
|
||||
const inputValidation = ZSurveyUpdateInput.safeParse({
|
||||
...survey,
|
||||
...surveyUpdate,
|
||||
});
|
||||
|
||||
@@ -524,6 +524,13 @@ export const ZSurvey = z.object({
|
||||
showLanguageSwitch: z.boolean().nullable(),
|
||||
});
|
||||
|
||||
export const ZSurveyUpdateInput = ZSurvey.omit({ createdAt: true, updatedAt: true }).and(
|
||||
z.object({
|
||||
createdAt: z.coerce.date(),
|
||||
updatedAt: z.coerce.date(),
|
||||
})
|
||||
);
|
||||
|
||||
export const ZSurveyInput = z.object({
|
||||
name: z.string(),
|
||||
type: ZSurveyType.optional(),
|
||||
|
||||
Reference in New Issue
Block a user