From d52943e31e6547ced6c5054c1ee5aa8c77026427 Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Fri, 17 Oct 2025 23:24:08 +0200 Subject: [PATCH] Fix --- web/components/votes/vote-buttons.tsx | 70 +++++++++++++-------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/web/components/votes/vote-buttons.tsx b/web/components/votes/vote-buttons.tsx index 9172e1d1..d2c080e5 100644 --- a/web/components/votes/vote-buttons.tsx +++ b/web/components/votes/vote-buttons.tsx @@ -1,13 +1,42 @@ -import { Row } from 'web/components/layout/row' -import { Button } from 'web/components/buttons/button' +import {Row} from 'web/components/layout/row' +import {Button} from 'web/components/buttons/button' import clsx from 'clsx' import toast from 'react-hot-toast' -import { api } from 'web/lib/api' -import { useState } from 'react' +import {api} from 'web/lib/api' +import {useState} from 'react' import {useUser} from "web/hooks/use-user"; export type VoteChoice = 'for' | 'abstain' | 'against' +function VoteButton(props: { + color: string + count: number + title: string + disabled?: boolean + onClick?: () => void +}) { + const {color, count, title, disabled, onClick} = props + return ( + + ) +} + +const priorities = [ + {label: 'Urgent', value: 3}, + {label: 'High', value: 2}, + {label: 'Medium', value: 1}, + {label: 'Low', value: 0}, +] as const + export function VoteButtons(props: { voteId: number counts: { for: number; abstain: number; against: number } @@ -15,7 +44,7 @@ export function VoteButtons(props: { className?: string }) { const user = useUser() - const { voteId, counts, onVoted, className } = props + const {voteId, counts, onVoted, className} = props const [loading, setLoading] = useState(null) const [showPriority, setShowPriority] = useState(false) const disabled = loading !== null @@ -27,7 +56,7 @@ export function VoteButtons(props: { toast.error('Please sign in to vote') return } - await api('vote', { voteId, choice, priority }) + await api('vote', {voteId, choice, priority}) toast.success(`Voted ${choice}${choice === 'for' ? ` with priority ${priority}` : ''}`) await onVoted?.() } catch (e) { @@ -48,35 +77,6 @@ export function VoteButtons(props: { await sendVote(choice, 0) } -function VoteButton(props: { - color: string - count: number - title: string - disabled?: boolean - onClick?: () => void -}) { - const { color, count, title, disabled, onClick } = props - return ( - - ) -} - - const priorities = [ - { label: 'Urgent', value: 3 }, - { label: 'High', value: 2 }, - { label: 'Medium', value: 1 }, - { label: 'Low', value: 0 }, - ] as const - return (