mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-19 13:21:46 +00:00
fix(collab): show poll option labels in the UI
The poll API formatted each option as { label, voters }, but the React poll
component renders opt.text - so every option button came out blank. Emit text
alongside label (kept for any other consumer) so options render again.
This commit is contained in:
@@ -229,12 +229,17 @@ export function getPollWithVotes(pollId: number | bigint | string) {
|
||||
WHERE v.poll_id = ?
|
||||
`).all(pollId) as PollVoteRow[];
|
||||
|
||||
const formattedOptions = options.map((label: string | { label: string }, idx: number) => ({
|
||||
label: typeof label === 'string' ? label : label.label || label,
|
||||
const formattedOptions = options.map((label: string | { label: string }, idx: number) => {
|
||||
const text = typeof label === 'string' ? label : label.label || label;
|
||||
return {
|
||||
// The client renders `opt.text`; keep `label` too for any other consumer.
|
||||
text,
|
||||
label: text,
|
||||
voters: votes
|
||||
.filter(v => v.option_index === idx)
|
||||
.map(v => ({ id: v.user_id, user_id: v.user_id, username: v.username, avatar: v.avatar, avatar_url: avatarUrl(v) })),
|
||||
}));
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
...poll,
|
||||
|
||||
Reference in New Issue
Block a user