add vote result comparison view, wire into legislation detail page
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import { castVoteSchema } from "./schema"
|
||||
import {
|
||||
castVote,
|
||||
getLegislation,
|
||||
getLegislationResults,
|
||||
getLegislationText,
|
||||
getUpcomingLegislation,
|
||||
getUserVote,
|
||||
@@ -48,6 +49,17 @@ legislationRouter.post("/:id/vote", async (c) => {
|
||||
return c.json({ ok: true }, 201)
|
||||
})
|
||||
|
||||
legislationRouter.get("/:id/results/:deviceId", async (c) => {
|
||||
const id = Number(c.req.param("id"))
|
||||
const deviceId = c.req.param("deviceId")
|
||||
if (Number.isNaN(id)) return c.json({ error: "invalid id" }, 400)
|
||||
|
||||
const results = await getLegislationResults(id, deviceId)
|
||||
if (!results) return c.json({ error: "no results yet" }, 404)
|
||||
|
||||
return c.json(results)
|
||||
})
|
||||
|
||||
legislationRouter.get("/:id/vote/:deviceId", async (c) => {
|
||||
const id = Number(c.req.param("id"))
|
||||
const deviceId = c.req.param("deviceId")
|
||||
|
||||
Reference in New Issue
Block a user