Skip to content

Commit

Permalink
Simplify highlightBorderColor in product type (formbricks#657)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattinannt committed Aug 7, 2023
1 parent fae0719 commit 45637e6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
24 changes: 13 additions & 11 deletions apps/web/components/preview/MultipleChoiceMultiQuestion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down
6 changes: 4 additions & 2 deletions packages/types/v1/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"]),
Expand Down

0 comments on commit 45637e6

Please sign in to comment.