From 0c7581bb601b748bdb54ba9496b32a34f30c1abe Mon Sep 17 00:00:00 2001 From: real-zephex Date: Sat, 6 Apr 2024 15:31:11 +0530 Subject: added search functionality --- src/app/kdrama/components/search.jsx | 56 ++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/app/kdrama/components/search.jsx (limited to 'src/app/kdrama/components/search.jsx') diff --git a/src/app/kdrama/components/search.jsx b/src/app/kdrama/components/search.jsx new file mode 100644 index 0000000..4c9d00c --- /dev/null +++ b/src/app/kdrama/components/search.jsx @@ -0,0 +1,56 @@ +"use client"; + +import styles from "../styles/search.module.css"; +import { useState } from "react"; +import { FaSearch } from "react-icons/fa"; +import FetchSearchTitle from "./searchQuery"; +import Image from "next/image"; +import Link from "next/link"; + +export default function DramaSearch() { + const [title, setTitle] = useState(""); + const [infoTitle, setInfoTitle] = useState(null); + + async function getSearchResults(title) { + const data = await FetchSearchTitle(title); + setInfoTitle(data); + } + + return ( +
+
+ + setTitle(event.target.value)} + onKeyDown={async (e) => { + if ((e.key === "Enter" || e.code === 13) && title) { + await getSearchResults(e.target.value); + } + }} + > +
+ +
+ {infoTitle && + infoTitle.results.map((item, index) => ( + +
+

{item.title}

+ Drama Poster +
+ + ))} +
+
+ ); +} -- cgit v1.2.3