From 1eee181e219dfd993d396ac3169e7aad3dd285eb Mon Sep 17 00:00:00 2001 From: Factiven Date: Sun, 16 Jul 2023 22:35:39 +0700 Subject: 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) --- pages/index.js | 626 +++------------------------------------------------------ 1 file changed, 26 insertions(+), 600 deletions(-) (limited to 'pages/index.js') diff --git a/pages/index.js b/pages/index.js index 1c65970..6f020fb 100644 --- a/pages/index.js +++ b/pages/index.js @@ -1,606 +1,32 @@ -import { aniListData } from "../lib/AniList"; -import React, { useState, useEffect } from "react"; -import Head from "next/head"; -import Link from "next/link"; -import Footer from "../components/footer"; -import Image from "next/image"; -import Content from "../components/hero/content"; -import { useRouter } from "next/router"; +import { parseCookies } from "nookies"; -import { motion } from "framer-motion"; - -import { useSession, signIn, signOut } from "next-auth/react"; -import { useAniList } from "../lib/useAnilist"; -import { getServerSession } from "next-auth/next"; -import { authOptions } from "./api/auth/[...nextauth]"; -import SearchBar from "../components/searchBar"; -import Genres from "../components/hero/genres"; - -export function Navigasi() { - const { data: sessions, status } = useSession(); - const [year, setYear] = useState(new Date().getFullYear()); - const [season, setSeason] = useState(getCurrentSeason()); - - const router = useRouter(); - - const handleFormSubmission = (inputValue) => { - router.push(`/search/${encodeURIComponent(inputValue)}`); - }; - - const handleKeyDown = async (event) => { - if (event.key === "Enter") { - event.preventDefault(); - const inputValue = event.target.value; - handleFormSubmission(inputValue); - } - }; - return ( - <> - {/* NAVBAR PC */} -
-
-
- - moopa - -
    -
  • - - This Season - -
  • -
  • - Manga -
  • -
  • - Anime -
  • - - {status === "loading" ? ( -
  • Loading...
  • - ) : ( - <> - {!sessions && ( -
  • - -
  • - )} - {sessions && ( -
  • - - My List - -
  • - )} - - )} -
-
-
-
- -
- -
-
-
-
-
- - ); -} - -export default function Home({ detail, populars, sessions }) { - const { media: current } = useAniList(sessions, { stats: "CURRENT" }); - const { media: plan } = useAniList(sessions, { stats: "PLANNING" }); - - const [isVisible, setIsVisible] = useState(false); - const [list, setList] = useState(null); - const [planned, setPlanned] = useState(null); - const [greeting, setGreeting] = useState(""); - const [onGoing, setOnGoing] = useState(null); - - const [prog, setProg] = useState(null); - - const popular = populars?.data; - const data = detail.data[0]; - - const handleShowClick = () => { - setIsVisible(true); - }; - - const handleHideClick = () => { - setIsVisible(false); - }; - - useEffect(() => { - const time = new Date().getHours(); - let greeting = ""; - - if (time >= 5 && time < 12) { - greeting = "Good morning"; - } else if (time >= 12 && time < 18) { - greeting = "Good afternoon"; - } else if (time >= 18 && time < 22) { - greeting = "Good evening"; - } else if (time >= 22 || time < 5) { - greeting = "Good night"; - } - - setGreeting(greeting); - - async function userData() { - if (!sessions) return; - const getMedia = - current.filter((item) => item.status === "CURRENT")[0] || null; - const list = getMedia?.entries - .map(({ media }) => media) - .filter((media) => media); - - const prog = getMedia?.entries.filter( - (item) => item.media.nextAiringEpisode !== null - ); - - setProg(prog); - - const planned = plan?.[0]?.entries - .map(({ media }) => media) - .filter((media) => media); - - const onGoing = list?.filter((item) => item.nextAiringEpisode !== null); - setOnGoing(onGoing); - - if (list) { - setList(list.reverse()); - } - if (planned) { - setPlanned(planned.reverse()); - } - } - userData(); - }, [sessions, current, plan]); - - // console.log(log); - - return ( - <> - - Moopa - - - - - - - - - {/* NAVBAR */} -
- {!isVisible && ( - - )} -
- - {/* Mobile Menu */} -
- {isVisible && sessions && ( - - user avatar - - )} - {isVisible && ( -
-
- - - - {sessions ? ( - - ) : ( - - )} -
- -
- )} -
- -
- - - {/* PC / TABLET */} -
-
-
-

- {data.title.english || data.title.romaji || data.title.native} -

-

- -

-
-
-
-
- - {`alt -
-
-
-
- {/* {!sessions && ( -

- {greeting}! -

- )} */} - {sessions && ( -
-
- {greeting},

{sessions?.user.name}

- -
-
- )} - -
- - {sessions && onGoing && ( - - - - )} - - {sessions && list && ( - - - - )} - - {/* SECTION 2 */} - {sessions && planned && ( - - - - )} - - {/* SECTION 3 */} - {detail && ( - - - - )} - - {/* SECTION 4 */} - {popular && ( - - - - )} - - - - - -
-
-