From 7932b71d55f621ad5cfa4a96d637ce90f366a10c Mon Sep 17 00:00:00 2001
From: real-zephex <zephex-1@outlook.com>
Date: Thu, 21 Mar 2024 10:08:56 +0530
Subject: fixes: anime section is fully server rendered, added a loading screen
 for info and video page, minor css optimizations

---
 src/app/search/page.jsx | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

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

diff --git a/src/app/search/page.jsx b/src/app/search/page.jsx
index e6d4f08..00309f6 100644
--- a/src/app/search/page.jsx
+++ b/src/app/search/page.jsx
@@ -5,19 +5,24 @@ import { FaSearch } from "react-icons/fa"; // Import the search icon from react-
 import { useState } from "react";
 import Image from "next/image";
 import Link from "next/link";
+import testFunction from "./api/fetchInfo";
 
 export default function Input() {
 	const [searchedAnime, setSearchedAnime] = useState(null);
 	const [loading, setLoading] = useState(null);
+	const [search1, setSearch] = useState(null);
 
-	const handleKeyPress = (event) => {
+	const handleKeyPress = async (event) => {
 		if (
 			(event.code === "Enter" ||
 				event.key === "Enter" ||
 				event.code === 13) &&
 			searchedAnime != ""
 		) {
-			fetch_animes(searchedAnime);
+			setLoading(true);
+			let x = await testFunction(searchedAnime);
+			setSearch(x);
+			setLoading(false);
 		} else if (
 			(event.code === "Enter" ||
 				event.key === "Enter" ||
@@ -28,17 +33,6 @@ export default function Input() {
 		}
 	};
 
-	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">
-- 
cgit v1.2.3

