diff options
| author | Factiven <[email protected]> | 2023-07-16 22:35:39 +0700 |
|---|---|---|
| committer | Factiven <[email protected]> | 2023-07-16 22:35:39 +0700 |
| commit | 1eee181e219dfd993d396ac3169e7aad3dd285eb (patch) | |
| tree | 23fe54e9c3f8810f3ac9ab6b29070b4f0d4b9d20 /components/searchBar.js | |
| parent | removed console.log (diff) | |
| download | moopa-1eee181e219dfd993d396ac3169e7aad3dd285eb.tar.xz moopa-1eee181e219dfd993d396ac3169e7aad3dd285eb.zip | |
Update v3.6.4
- Added Manga page with a working tracker for AniList user
- Added schedule component to home page
- Added disqus comment section so you can fight on each other (not recommended)
- Added /id and /en route for english and indonesian subs (id route still work in progress)
Diffstat (limited to 'components/searchBar.js')
| -rw-r--r-- | components/searchBar.js | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/components/searchBar.js b/components/searchBar.js index 35e9b45..20d2d7c 100644 --- a/components/searchBar.js +++ b/components/searchBar.js @@ -1,7 +1,7 @@ import { useState, useEffect, useRef } from "react"; import { motion as m, AnimatePresence } from "framer-motion"; import { MagnifyingGlassIcon } from "@heroicons/react/24/outline"; -import { useAniList } from "../lib/useAnilist"; +import { useAniList } from "../lib/anilist/useAnilist"; import Image from "next/image"; import Link from "next/link"; import { useRouter } from "next/router"; @@ -16,6 +16,8 @@ const SearchBar = () => { const [data, setData] = useState(null); const [query, setQuery] = useState(""); + const [lang, setLang] = useState("en"); + useEffect(() => { if (isOpen) { searchBoxRef.current.querySelector("input").focus(); @@ -58,10 +60,19 @@ const SearchBar = () => { } }, [query]); + useEffect(() => { + const lang = localStorage.getItem("lang") || "id"; + if (lang === "en" || lang === null) { + setLang("en"); + } else if (lang === "id") { + setLang("id"); + } + }, []); + function handleSubmit(e) { e.preventDefault(); if (data?.media.length) { - router.push(`/anime/${data?.media[0].id}`); + router.push(`${lang}/anime/${data?.media[0].id}`); } } @@ -92,7 +103,7 @@ const SearchBar = () => { {data?.media.map((i) => ( <Link key={i.id} - href={i.type === "ANIME" ? `/anime/${i.id}` : `/`} + href={i.type === "ANIME" ? `${lang}/anime/${i.id}` : `/`} className="flex hover:bg-[#3e3e3e] rounded-md" > <Image @@ -131,7 +142,7 @@ const SearchBar = () => { {query && ( <button className="flex items-center gap-2 justify-center"> <MagnifyingGlassIcon className="h-5 w-5" /> - <Link href={`/search/${query}`}>More Results...</Link> + <Link href={`${lang}/search/${query}`}>More Results...</Link> </button> )} </div> |