This commit is contained in:
Aria Moradi
2021-03-14 23:57:33 +03:30
parent 53ef836326
commit 1128f40bac
14 changed files with 66 additions and 46 deletions

View File

@@ -16,6 +16,7 @@ export default function Manga() {
const { id } = useParams<{id: string}>();
const [manga, setManga] = useState<IManga>();
const [source, setSource] = useState<ISource>();
const [chapters, setChapters] = useState<IChapter[]>([]);
useEffect(() => {
@@ -27,6 +28,16 @@ export default function Manga() {
});
}, []);
useEffect(() => {
if (manga !== undefined) {
client.get(`/api/v1/source/${manga.sourceId}`)
.then((response) => response.data)
.then((data: ISource) => {
setSource(data);
});
}
}, [manga]);
useEffect(() => {
client.get(`/api/v1/manga/${id}/chapters`)
.then((response) => response.data)
@@ -41,7 +52,7 @@ export default function Manga() {
return (
<>
{manga && <MangaDetails manga={manga} />}
{(manga && source) && <MangaDetails manga={manga} source={source} />}
{chapterCards}
</>
);