From 3acac648ad6f7c220a48ff9f92f42e814c2097ab Mon Sep 17 00:00:00 2001 From: real-zephex Date: Tue, 26 Mar 2024 13:21:55 +0530 Subject: restructured files --- src/app/search/components/fetchInfo.js | 14 ------ src/app/search/components/fetchedInfo.js | 44 ------------------ src/app/search/page.jsx | 67 -------------------------- src/app/search/search.css | 80 -------------------------------- 4 files changed, 205 deletions(-) delete mode 100644 src/app/search/components/fetchInfo.js delete mode 100644 src/app/search/components/fetchedInfo.js delete mode 100644 src/app/search/page.jsx delete mode 100644 src/app/search/search.css (limited to 'src/app/search') diff --git a/src/app/search/components/fetchInfo.js b/src/app/search/components/fetchInfo.js deleted file mode 100644 index 07b203d..0000000 --- a/src/app/search/components/fetchInfo.js +++ /dev/null @@ -1,14 +0,0 @@ -"use server"; - -export default async function Results(id) { - return await testFunction(id); -} - -async function testFunction(title) { - const res = await fetch( - "https://consumet-api-di2e.onrender.com/anime/gogoanime/" + title, - { cache: "force-cache" } - ); - const data = await res.json(); - return data; -} diff --git a/src/app/search/components/fetchedInfo.js b/src/app/search/components/fetchedInfo.js deleted file mode 100644 index aa03437..0000000 --- a/src/app/search/components/fetchedInfo.js +++ /dev/null @@ -1,44 +0,0 @@ -import "../search.css"; -import Link from "next/link"; -import Image from "next/image"; - -export default async function fetchedInfo(data) { - return ( -
- {data ? ( - data.results && data.results.length > 0 ? ( - data.results.map((item, index) => ( - -
-

{item.title}

- Drama Poster -
- - )) - ) : ( -
-

- No results found -

-
- ) - ) : null} -
- ); -} diff --git a/src/app/search/page.jsx b/src/app/search/page.jsx deleted file mode 100644 index 75f09bd..0000000 --- a/src/app/search/page.jsx +++ /dev/null @@ -1,67 +0,0 @@ -"use client"; - -import "./search.css"; -import { FaSearch } from "react-icons/fa"; // Import the search icon from react-icons library -import { useState } from "react"; -import Results from "./components/fetchInfo"; -import fetchedInfo from "./components/fetchedInfo"; - -export default function Input() { - const [searchedAnime, setSearchedAnime] = useState(null); - const [loading, setLoading] = useState(null); - const [info, setInfo] = useState(null); - - const handleKeyPress = async (event) => { - if ( - (event.code === "Enter" || - event.key === "Enter" || - event.code === 13) && - searchedAnime !== "" - ) { - setLoading(true); - setInfo(await fetchedInfo(await Results(searchedAnime))); - setLoading(false); - } else if ( - (event.code === "Enter" || - event.key === "Enter" || - event.code === 13) && - searchedAnime === "" - ) { - alert("Input cannot be empty"); - } - }; - - return ( -
-
-
- - { - if (event.target.value.trim() !== "") { - setSearchedAnime(event.target.value); - } - }} - onKeyDown={(event) => handleKeyPress(event)} - placeholder="Enter anime title" - > -
-
- - {loading && ( -

- Please wait while we crunch all the data for you -

- )} - - {info} -
- ); -} diff --git a/src/app/search/search.css b/src/app/search/search.css deleted file mode 100644 index 8afb508..0000000 --- a/src/app/search/search.css +++ /dev/null @@ -1,80 +0,0 @@ -.inputContainer { - display: flex; - margin: 30px auto; -} - -.searchContainer input { - border: none; - border-radius: 5px; - color: white; - outline: none; - background: none; - width: 100%; - font-family: "Lato"; - font-size: 16px; -} - -.searchContainer { - display: flex; - align-items: center; - margin: 0px auto; - background-color: #2c2c2c; - padding: 8px; - border-radius: 5px; - width: 20%; -} - -.searchIcon { - color: white; - margin-right: 5px; -} - -.animeEntry { - display: flex; - overflow-x: auto; -} - -.animeEntry::-webkit-scrollbar { - height: 7px; -} - -.animeEntry::-webkit-scrollbar-track { - background-color: #636363; - border-radius: 5px; -} - -.animeEntry::-webkit-scrollbar-thumb { - background-color: rgba(196, 196, 196, 0.692); - border-radius: 5px; - -} - -.anime { - display: flex; - justify-content: space-between; - align-items: center; - padding: 10px; - border-style: dotted; - border-color: #636363; - margin: 10px; - border-radius: 10px; - border-width: 4px; -} - -.anime p { - color: white; - width: 25dvh; - font-family: "Lato"; - font-size: 18px; -} - -.animeImage { - border-radius: 10px; - margin-left: 20px; -} - -@media screen and (max-width: 768px) { - .searchContainer { - width: 70%; - } -} \ No newline at end of file -- cgit v1.2.3