Skip to content

Commit

Permalink
Merge pull request #952 from AlejandroSuero/feature/fix-votes-filtering
Browse files Browse the repository at this point in the history
fix(#951): fixed `voteId` filtering for `POST /api/votes/<combatId>`
  • Loading branch information
midudev authored May 13, 2024
2 parents 57849df + 4579e2f commit 4a0b853
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/pages/api/votes/[combatId].ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ export const POST: APIRoute = async ({ params, request }) => {
if (!success) return res("Bad request", { status: 400 })

const { voteId } = output
const boxerData = combatData.boxers.find((b) => b === voteId)
let boxerData: string | undefined
if (combatData.teams !== undefined) {
boxerData = combatData.teams.find((t) => t === voteId)
} else {
boxerData = combatData.boxers.find((b) => b === voteId)
}
if (!boxerData) return res("Boxer not found", { status: 404 })

const userId = session.user.id
Expand Down

0 comments on commit 4a0b853

Please sign in to comment.