From bb50d08f5e0476fc302ca45aa2e377471d10b118 Mon Sep 17 00:00:00 2001 From: real-zephex Date: Sun, 17 Mar 2024 06:47:32 +0530 Subject: minor fixes and feature improvements: added an indicator which shows when the animes are being loaded and also indicates when no anime with given title is found --- src/app/search/page.js | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) (limited to 'src/app/search') diff --git a/src/app/search/page.js b/src/app/search/page.js index c64030c..f384d85 100644 --- a/src/app/search/page.js +++ b/src/app/search/page.js @@ -9,6 +9,7 @@ import Link from 'next/link'; export default function Input() { const [searchedAnime, setSearchedAnime] = useState(null) + const [loading, setLoading] = useState(null) const handleKeyPress = (event) => { if ( @@ -31,11 +32,12 @@ 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) - console.log(search1) + setLoading(false) } ) } @@ -54,21 +56,37 @@ export default function Input() { + + {loading && ( +

+ Please wait while we crunch all the data for you. +

+ )}
- {search1 && search1.results.map((item, index) => ( - -
-

{item.title}

- + {search1 ? ( + search1.results && search1.results.length > 0 ? ( + search1.results.map((item, index) => ( + +
+

{item.title}

+ Drama Poster +
+ + )) + ) : ( +
+

No results found

- - ))} + ) + ) : null}
+
) -- cgit v1.2.3