aboutsummaryrefslogtreecommitdiff
path: root/pages/components/manga
diff options
context:
space:
mode:
authorFactiven <[email protected]>2023-04-14 00:07:02 +0700
committerFactiven <[email protected]>2023-04-14 00:07:02 +0700
commit482b1c8db5cfeaa20d75ce92fcb10f3ca8433633 (patch)
treef0c12d3acb6bd8ce43e63e01527c97a62dba7e9c /pages/components/manga
parentUpdate index.js (diff)
downloadmoopa-482b1c8db5cfeaa20d75ce92fcb10f3ca8433633.tar.xz
moopa-482b1c8db5cfeaa20d75ce92fcb10f3ca8433633.zip
Update 5th
Diffstat (limited to 'pages/components/manga')
-rw-r--r--pages/components/manga/chapters.js61
1 files changed, 61 insertions, 0 deletions
diff --git a/pages/components/manga/chapters.js b/pages/components/manga/chapters.js
new file mode 100644
index 0000000..7997a73
--- /dev/null
+++ b/pages/components/manga/chapters.js
@@ -0,0 +1,61 @@
+import axios from "axios";
+import Link from "next/link";
+import React, { useEffect, useState } from "react";
+
+export default function Content({ ids, providers }) {
+ const [data, setData] = useState([]);
+ const [isLoading, setIsLoading] = useState(true);
+ const [error, setError] = useState(null);
+
+ async function fetchData() {
+ setIsLoading(true);
+ try {
+ const res = await axios.get(
+ `https://api.eucrypt.my.id/meta/anilist-manga/info/${ids}?provider=${providers}`
+ );
+ const data = res.data;
+ setData(data);
+ setError(null); // Reset error state if data is successfully fetched
+ } catch (error) {
+ setError(error);
+ }
+
+ setIsLoading(false);
+ }
+ useEffect(() => {
+ fetchData();
+ }, [providers]);
+ useEffect(() => {
+ // console.log("Data changed:", data);
+ }, [data]);
+
+ if (error) {
+ // Handle 404 Not Found error
+ return <div>Chapters Not Available</div>;
+ }
+ // console.log(isLoading);
+ return (
+ <>
+ <div className="flex h-[540px] flex-col gap-5 overflow-y-scroll">
+ {isLoading ? (
+ <p>Loading...</p>
+ ) : data.chapters?.length > 0 ? (
+ data.chapters?.map((chapter, index) => {
+ return (
+ <div key={index}>
+ <Link
+ href={`/manga/chapter/[chapter]`}
+ as={`/manga/chapter/read?id=${chapter.id}&provider=${providers}`}
+ >
+ Chapters {index + 1}
+ </Link>
+ </div>
+ );
+ })
+ ) : (
+ <p>No Chapters Available</p>
+ )}
+ </div>
+ </>
+ );
+}