From 89dae8f1d806ac49b770741c535dd482053787ab Mon Sep 17 00:00:00 2001 From: Matti Nannt Date: Mon, 7 Aug 2023 16:50:24 +0200 Subject: [PATCH] Simplify highlightBorderColor in product type (#657) --- .../preview/MultipleChoiceMultiQuestion.tsx | 24 ++++++++++--------- packages/types/v1/product.ts | 6 +++-- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/apps/web/components/preview/MultipleChoiceMultiQuestion.tsx b/apps/web/components/preview/MultipleChoiceMultiQuestion.tsx index 939ffb82dea..1285043a77e 100644 --- a/apps/web/components/preview/MultipleChoiceMultiQuestion.tsx +++ b/apps/web/components/preview/MultipleChoiceMultiQuestion.tsx @@ -39,19 +39,21 @@ export default function MultipleChoiceMultiQuestion({ .map((choice) => choice.label); useEffect(() => { - if(Array.isArray(storedResponseValue)){ + if (Array.isArray(storedResponseValue)) { const nonOtherSavedChoices = storedResponseValue?.filter((answer) => - nonOtherChoiceLabels.includes(answer) - ); - const savedOtherSpecified = storedResponseValue?.find((answer) => !nonOtherChoiceLabels.includes(answer)); - - setSelectedChoices(nonOtherSavedChoices ?? []); - - if (savedOtherSpecified) { - setOtherSpecified(savedOtherSpecified); - setShowOther(true); + nonOtherChoiceLabels.includes(answer) + ); + const savedOtherSpecified = storedResponseValue?.find( + (answer) => !nonOtherChoiceLabels.includes(answer) + ); + + setSelectedChoices(nonOtherSavedChoices ?? []); + + if (savedOtherSpecified) { + setOtherSpecified(savedOtherSpecified); + setShowOther(true); + } } - } // eslint-disable-next-line react-hooks/exhaustive-deps }, [storedResponseValue, question.id]); diff --git a/packages/types/v1/product.ts b/packages/types/v1/product.ts index 1b31cc93695..2e49f638ee2 100644 --- a/packages/types/v1/product.ts +++ b/packages/types/v1/product.ts @@ -7,8 +7,10 @@ export const ZProduct = z.object({ name: z.string(), teamId: z.string(), brandColor: z.string().regex(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/), - highlightBorderColor: z.union([z.string().regex(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/), z.null()]), - + highlightBorderColor: z + .string() + .regex(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/) + .nullable(), recontactDays: z.number().int(), formbricksSignature: z.boolean(), placement: z.enum(["bottomLeft", "bottomRight", "topLeft", "topRight", "center"]),