blob: d031c3bd601540b4c9b74bbd073d0187eb9ba15a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
import { useEffect } from "react";
import ChapterSelector from "./chapters";
import axios from "axios";
import pls from "@/utils/request";
export default function ChaptersComponent({
info,
mangaId,
aniId,
setWatch,
chapter,
setChapter,
loading,
setLoading,
notFound,
setNotFound,
}) {
useEffect(() => {
setLoading(true);
}, [aniId]);
useEffect(() => {
async function fetchData() {
try {
setLoading(true);
// console.log(mangaId);
if (mangaId) {
const Chapters = await pls.get(
`https://api.anify.tv/chapters/${mangaId}`
);
// console.log("clean this balls");
if (!Chapters) {
setLoading(false);
setNotFound(true);
} else {
setChapter(Chapters);
setLoading(false);
}
}
} catch (error) {
console.error(error);
} finally {
setLoading(false);
}
}
fetchData();
}, [mangaId]);
return (
<div>
{!loading ? (
notFound ? (
<div className="h-[20vh] lg:w-full flex-center flex-col gap-5">
<p className="text-center font-karla font-bold lg:text-lg">
Oops!<br></br> It looks like this manga is not available.
</p>
</div>
) : info && chapter && chapter.length > 0 ? (
<ChapterSelector
chaptersData={chapter}
mangaId={mangaId}
data={info}
setWatch={setWatch}
/>
) : (
<div className="flex justify-center">
<div className="lds-ellipsis">
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</div>
)
) : (
<div className="flex justify-center">
<div className="lds-ellipsis">
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</div>
)}
</div>
);
}
|