2025-12-08 16:31:30 +03:00

16 lines
544 B
TypeScript

import { NextRequest, NextResponse } from 'next/server'
import { submitVote } from '@/lib/db/polls'
export async function POST(request: NextRequest) {
try {
const { pollId, userId, userAddress, optionId, amount, txHash } = await request.json()
const vote = await submitVote(pollId, userId, userAddress, optionId, amount, txHash)
return NextResponse.json(vote)
} catch (error) {
console.error('Failed to submit vote:', error)
return NextResponse.json({ error: 'Failed to submit vote' }, { status: 500 })
}
}