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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
"use client";
import {
Tabs,
Tab,
Card,
CardBody,
Divider,
Image,
Select,
SelectItem,
Button,
} from "@nextui-org/react";
import { FaRegThumbsUp, FaRegStar } from "react-icons/fa";
import Link from "next/link";
import { useState } from "react";
import MangaChapters from "./chapterPages";
const MangaDescriptionTabs = ({ data }) => {
const [pages, setPages] = useState(<></>);
const [url, setUrl] = useState("");
async function get_pages(id) {
setPages(<p className="text-center">Loading...</p>);
setUrl(`https://mangadex-downloader.onrender.com/${id}`);
const data = await MangaChapters(id);
setPages(data);
}
return (
<div className="flex w-full flex-col">
<Tabs aria-label="Options">
<Tab key="description" title="Description">
<Card shadow="sm">
<CardBody
dangerouslySetInnerHTML={{
__html: data.description,
}}
></CardBody>
</Card>
</Tab>
<Tab key="details" title="Details">
<Card shadow="sm">
<CardBody>
<h4>
<strong>Status</strong>:{" "}
<span>{data.status || "not sure"}</span>
</h4>
<h4>
<strong>Type</strong>:{" "}
<span>{data.type || "not sure"}</span>
</h4>
<h4>
<strong className="text-green-400">
Started on
</strong>
:{" "}
<span>
{data.startDate.day}-{data.startDate.month}-
{data.startDate.year}
</span>
</h4>
<h4>
<strong className="text-red-400">
Ended on
</strong>
:{" "}
<span>
{data.endDate.day}-{data.endDate.month}-
{data.endDate.year}
</span>
</h4>
<div className="flex items-center">
<section className="flex items-center">
<FaRegThumbsUp />
<p className="ml-1">{data.popularity}</p>
</section>
<Divider orientation="vertical" />
<section className="ml-2 flex items-center">
<FaRegStar />
<p className="ml-1">
{Number(data.rating) / 10}
</p>
</section>
</div>
</CardBody>
</Card>
</Tab>
<Tab key="recommendations" title="Recommendation">
<Card shadow="sm">
<CardBody>
{data.recommendations &&
data.recommendations.length > 0 &&
data.recommendations.map((item, index) => (
<Link
key={index}
href={`/manga/${item.id}`}
>
<Card
isPressable
isHoverable
shadow="sm"
className="mb-2 flex w-full flex-row items-center"
>
<Image
width={120}
src={item.image}
className="p-1"
shadow="lg"
isBlurred
/>
<CardBody>
<p className="text-xl">
{item.title.english ||
item.title.romaji}
</p>
</CardBody>
</Card>
</Link>
))}
</CardBody>
</Card>
</Tab>
<Tab key="chapter" title="Chapter">
<Card shadow="sm" className="p-2">
<div className="flex items-center">
<Select
className="w-full lg:max-w-md"
label="Select chapter"
>
{data.chapters &&
data.chapters.length > 0 &&
data.chapters.map((item, index) => {
if (item.pages > 0) {
return (
<SelectItem
key={index}
onClick={async () =>
await get_pages(item.id)
}
textValue={item.title}
>
{item.title} -{" "}
{item.chapterNumber}
</SelectItem>
);
} else {
return;
}
})}
</Select>
<Button
as={Link}
href={url}
className="mt-2 ml-2"
size="lg"
color="warning"
variant="ghost"
>
Download
</Button>
</div>
<CardBody>
<div className="w-full">{pages}</div>
</CardBody>
</Card>
</Tab>
</Tabs>
</div>
);
};
export default MangaDescriptionTabs;
|