🐛 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={() => { onClick={() => {
field.onChange({ field.onChange({
optionId, 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" 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 <VoteSelector
value={field.value.type} value={field.value?.type}
onChange={(vote) => { onChange={(vote) => {
field.onChange({ optionId, type: vote }); field.onChange({ optionId, type: vote });
}} }}

View file

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