From b1f4f412059760d85f531c3d6e2ee626c9002d28 Mon Sep 17 00:00:00 2001
From: real-zephex <zephex-1@outlook.com>
Date: Mon, 18 Mar 2024 14:03:32 +0530
Subject: fixes: change the file extension to .jsx and fixed the video player
 sizes for tablets

---
 src/app/search/page.jsx | 92 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 92 insertions(+)
 create mode 100644 src/app/search/page.jsx

(limited to 'src/app/search/page.jsx')

diff --git a/src/app/search/page.jsx b/src/app/search/page.jsx
new file mode 100644
index 0000000..e6d4f08
--- /dev/null
+++ b/src/app/search/page.jsx
@@ -0,0 +1,92 @@
+"use client";
+
+import "./search.css";
+import { FaSearch } from "react-icons/fa"; // Import the search icon from react-icons library
+import { useState } from "react";
+import Image from "next/image";
+import Link from "next/link";
+
+export default function Input() {
+	const [searchedAnime, setSearchedAnime] = useState(null);
+	const [loading, setLoading] = useState(null);
+
+	const handleKeyPress = (event) => {
+		if (
+			(event.code === "Enter" ||
+				event.key === "Enter" ||
+				event.code === 13) &&
+			searchedAnime != ""
+		) {
+			fetch_animes(searchedAnime);
+		} else if (
+			(event.code === "Enter" ||
+				event.key === "Enter" ||
+				event.code === 13) &&
+			searchedAnime === ""
+		) {
+			alert("Input cannot be empty");
+		}
+	};
+
+	const [search1, setSearch] = useState(null);
+	const fetch_animes = (title) => {
+		fetch("https://dramalama-api.vercel.app/anime/gogoanime/" + title)
+			.then(setLoading(true))
+			.then((res) => res.json())
+			.then((data) => {
+				setSearch(data);
+				setLoading(false);
+			});
+	};
+
+	return (
+		<div>
+			<div className="inputContainer">
+				<div className="searchContainer">
+					<FaSearch className="searchIcon" />
+					<input
+						onChange={(event) =>
+							setSearchedAnime(event.target.value)
+						}
+						onKeyDown={(event) => handleKeyPress(event)}
+						placeholder="Enter anime title"
+					></input>
+				</div>
+			</div>
+
+			{loading && (
+				<p style={{ color: "white", textAlign: "center" }}>
+					Please wait while we crunch all the data for you.
+				</p>
+			)}
+			<div className="animeEntry">
+				{search1 ? (
+					search1.results && search1.results.length > 0 ? (
+						search1.results.map((item, index) => (
+							<Link
+								key={index}
+								href={`/info/${item.id}`}
+								style={{ textDecoration: "none" }}
+							>
+								<div className="anime">
+									<p>{item.title}</p>
+									<Image
+										src={item.image}
+										className="animeImage"
+										width={120}
+										height={160}
+										alt="Drama Poster"
+									/>
+								</div>
+							</Link>
+						))
+					) : (
+						<div style={{ margin: "0px auto" }}>
+							<p style={{ color: "white" }}>No results found</p>
+						</div>
+					)
+				) : null}
+			</div>
+		</div>
+	);
+}
-- 
cgit v1.2.3

