this repo has no description
1"use client";
2
3import Link from "next/link";
4import { useState } from "react";
5
6const PageCountInput = ({authors, hiveID, title, url }) => {
7 const [value, setValue] = useState(0);
8
9 const handleSubmit = async () => {
10 try {
11 const response = await fetch("/api/books/pageCount", {
12 body: JSON.stringify({
13 authors,
14 hiveID,
15 title,
16 value
17 }),
18 method: "POST"
19 });
20
21 if (response) {
22 window.location.reload();
23 }
24 } catch (error) {}
25 };
26
27 return (
28 <div className="flex flex-col gap-4">
29 <input
30 className="border-2 border-emerald-900 h-12 px-4 py-2 rounded-lg text-emerald-900"
31 min={0}
32 name=""
33 onChange={(e) => setValue(Number(e.currentTarget.value))}
34 placeholder="Add Page Count"
35 step={1}
36 type="number"
37 value={value}
38 />
39 <button
40 className="active:bg-emerald-800 bg-emerald-900 hover:cursor-pointer flex items-center justify-center h-12 px-4 py-2 text-amber-100 rounded-lg"
41 onClick={handleSubmit}
42 >
43 Submit
44 </button>
45 <Link
46 className="bg-emerald-900 h-12 px-4 py-2 rounded-lg text-amber-100 text-center"
47 href={url}
48 target="_blank"
49 >
50 Goodreads Search Results
51 </Link>
52 </div>
53 );
54};
55
56export default PageCountInput;