Spaces:
Build error
Build error
File size: 466 Bytes
7e5cb25 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
"use client"
import { useState } from "react"
export default function UpvoteBtn({ id }) {
const [upvoted, setUpvoted] = useState(false)
const upvote = async (id) => {
const response = await fetch(`/api/upvote?prompt=${id}`)
const data = await response.text()
if (data === "ok") return setUpvoted(true)
alert(data)
}
return (
<a href="#" onClick={() => upvote(id)}>
<small>{upvoted ? "Upvoted" : "Upvote"}</small>
</a>
)
}
|