🐛 Fix crash when options change mid voting (#1239)

This commit is contained in:
Luke Vella 2024-08-03 22:16:11 +01:00 committed by GitHub
parent 02f7c3ac06
commit 7e2ffd8d2b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 6 deletions

View file

@ -111,13 +111,13 @@ const ParticipantRowForm = ({
onClick={() => {
field.onChange({
optionId,
type: toggleVote(field.value.type),
type: toggleVote(field.value?.type),
});
}}
className="absolute inset-0 flex cursor-pointer items-center justify-center hover:bg-gray-100 active:bg-gray-200/50 active:ring-1 active:ring-inset active:ring-gray-200"
>
<VoteSelector
value={field.value.type}
value={field.value?.type}
onChange={(vote) => {
field.onChange({ optionId, type: vote });
}}

View file

@ -24,10 +24,12 @@ const formSchema = z.object({
mode: z.enum(["new", "edit", "view"]),
participantId: z.string().optional(),
votes: z.array(
z.object({
z
.object({
optionId: z.string(),
type: z.enum(["yes", "no", "ifNeedBe"]).optional(),
}),
})
.optional(),
),
});