mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-18 21:16:47 +00:00
fix(client): send multiple_choice from the desktop poll form
This commit is contained in:
@@ -30,7 +30,7 @@ const buildPoll = (overrides: Record<string, unknown> = {}) => ({
|
||||
{ id: 1, text: 'Paris', label: 'Paris', voters: [] },
|
||||
{ id: 2, text: 'Rome', label: 'Rome', voters: [] },
|
||||
],
|
||||
multi_choice: false,
|
||||
multiple_choice: false,
|
||||
is_closed: false,
|
||||
deadline: null,
|
||||
created_by: 1,
|
||||
|
||||
@@ -26,7 +26,7 @@ interface Poll {
|
||||
id: number
|
||||
question: string
|
||||
options: PollOption[]
|
||||
multi_choice: boolean
|
||||
multiple_choice: boolean
|
||||
is_closed: boolean
|
||||
deadline: string | null
|
||||
created_by: number
|
||||
@@ -59,7 +59,7 @@ function totalVotes(poll) {
|
||||
// ── Create Poll Modal ────────────────────────────────────────────────────────
|
||||
interface CreatePollModalProps {
|
||||
onClose: () => void
|
||||
onCreate: (data: { question: string; options: string[]; multi_choice: boolean }) => Promise<void>
|
||||
onCreate: (data: { question: string; options: string[]; multiple_choice: boolean }) => Promise<void>
|
||||
t: (key: string) => string
|
||||
}
|
||||
|
||||
@@ -80,7 +80,9 @@ function CreatePollModal({ onClose, onCreate, t }: CreatePollModalProps) {
|
||||
if (!canSubmit) return
|
||||
setSubmitting(true)
|
||||
try {
|
||||
await onCreate({ question: question.trim(), options: options.filter(o => o.trim()), multi_choice: multiChoice })
|
||||
// `multiple_choice` is the field the server reads (nest/collab/collab.service.ts);
|
||||
// the old `multi_choice` name was silently dropped, losing desktop multi-choice.
|
||||
await onCreate({ question: question.trim(), options: options.filter(o => o.trim()), multiple_choice: multiChoice })
|
||||
onClose()
|
||||
} catch {} finally { setSubmitting(false) }
|
||||
}
|
||||
@@ -232,7 +234,7 @@ function PollCard({ poll, currentUser, canEdit, onVote, onClose, onDelete, t }:
|
||||
<Clock size={8} /> {remaining}
|
||||
</span>
|
||||
)}
|
||||
{poll.multi_choice && (
|
||||
{poll.multiple_choice && (
|
||||
<span style={{ fontSize: 'calc(9px * var(--fs-scale-caption, 1))', fontWeight: 600, color: 'var(--text-faint)', background: 'var(--bg-tertiary)', padding: '2px 7px', borderRadius: 99 }}>
|
||||
{t('collab.polls.multiChoice')}
|
||||
</span>
|
||||
|
||||
@@ -97,8 +97,8 @@ export default function MCollabPolls({ planner }: MCollabPollsProps) {
|
||||
const res = (await collabApi.createPoll(tripId, {
|
||||
question: data.question,
|
||||
options: data.options,
|
||||
// Server reads `data.multiple || data.multiple_choice` (collabService.ts) —
|
||||
// both are sent so either shape lands correctly.
|
||||
// Server reads `data.multiple || data.multiple_choice`
|
||||
// (nest/collab/collab.service.ts) — both are sent so either shape lands.
|
||||
multiple: data.multipleChoice,
|
||||
multiple_choice: data.multipleChoice,
|
||||
deadline: data.deadline || undefined,
|
||||
|
||||
Reference in New Issue
Block a user