From 8da477790458e913925d2786009c48b7e3c89d53 Mon Sep 17 00:00:00 2001 From: Marc Velmer Date: Fri, 25 Oct 2024 11:29:36 +0200 Subject: [PATCH] Fixed `addQuestion` in `UnpublishedElection` for accepting metadata for questions and choices --- src/types/election/unpublished.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/types/election/unpublished.ts b/src/types/election/unpublished.ts index 88a932c..fb87bee 100644 --- a/src/types/election/unpublished.ts +++ b/src/types/election/unpublished.ts @@ -42,7 +42,11 @@ export class UnpublishedElection extends Election { public addQuestion( title: string | MultiLanguage, description: string | MultiLanguage, - choices: Array<{ title: string; value: number } | { title: MultiLanguage; value: number }> + choices: Array< + | { title: string; value: number; meta?: CustomMeta } + | { title: MultiLanguage; value: number; meta?: CustomMeta } + >, + meta?: CustomMeta ): UnpublishedElection { this._questions.push({ title: typeof title === 'string' ? { default: title } : title, @@ -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;