aboutsummaryrefslogtreecommitdiff
path: root/src/app/manga/searchBar.jsx
blob: 763f383b91011ebc6d7f19b981586fb845489a21 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"use client";

import { FaSearch } from "react-icons/fa";
import styles from "./manga.module.css";
import { useState } from "react";
import { useRouter } from "next/navigation";
import Link from "next/link";

// This is the search bar for the mangapage. Nothing extraordinary but just an input box and a search icon. Gets the work done.

export default function SearchBar() {
	const router = useRouter();

	const [title, setMangaTitle] = useState("");

	return (
		<main className={styles.searchMain}>
			<div className={styles.SearchBar}>
				<FaSearch color="white" style={{ marginLeft: 5 }} />
				<input
					type="text"
					name="manga"
					placeholder="Enter manga title"
					autoComplete="off"
					onChange={(e) => setMangaTitle(e.target.value)}
					onKeyDown={(event) => {
						if (
							(event.key === "Enter" ||
								event.code === 13 ||
								event.code === "Enter") &&
							title !== ""
						) {
							router.push(`/manga/${title}`);
						}
					}}
				></input>
			</div>
			<div>
				<Link href={"/manga/history/continueWatching/"}>
					<button>History</button>
				</Link>
			</div>
		</main>
	);
}