Skip to content

Commit

Permalink
Fixed addQuestion in UnpublishedElection for accepting metadata f…
Browse files Browse the repository at this point in the history
…or questions and choices
  • Loading branch information
marcvelmer committed Oct 25, 2024
1 parent f5f0b5c commit 8da4777
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/types/election/unpublished.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ export class UnpublishedElection extends Election {
public addQuestion(
title: string | MultiLanguage<string>,
description: string | MultiLanguage<string>,
choices: Array<{ title: string; value: number } | { title: MultiLanguage<string>; value: number }>
choices: Array<
| { title: string; value: number; meta?: CustomMeta }
| { title: MultiLanguage<string>; value: number; meta?: CustomMeta }
>,
meta?: CustomMeta
): UnpublishedElection {
this._questions.push({
title: typeof title === 'string' ? { default: title } : title,
Expand All @@ -51,8 +55,10 @@ export class UnpublishedElection extends Election {
return {
title: typeof choice.title === 'string' ? { default: choice.title } : choice.title,
value: choice.value,
...(choice.meta && { meta: choice.meta }),
} as IChoice;
}),
...(meta && { meta: meta }),
});

return this;
Expand Down

0 comments on commit 8da4777

Please sign in to comment.