migrate genre type

This commit is contained in:
Aria Moradi
2021-09-05 01:11:25 +04:30
parent ba26d852dc
commit e4853864ec
7 changed files with 29 additions and 7 deletions

View File

@@ -117,7 +117,7 @@ const useStyles = (inLibrary: string) => makeStyles((theme: Theme) => ({
}));
interface IProps{
manga: IManga
manga: IAnime
}
function getSourceName(source: ISource) {

View File

@@ -247,7 +247,7 @@ export default function MangaDetails(props: IProps) {
<p>{manga.description}</p>
</div>
<div className={classes.genre}>
{manga.genre?.split(', ').map((g) => <h5 key={g}>{g}</h5>)}
{manga.genre.map((g) => <h5 key={g}>{g}</h5>)}
</div>
</div>
</div>

View File

@@ -49,7 +49,7 @@ export default function Anime() {
const { id } = useParams<{ id: string }>();
const [manga, setManga] = useState<IManga>();
const [manga, setManga] = useState<IAnime>();
const [episodes, setEpisodes] = useState<IEpisode[]>([]);
const [fetchedEpisodes, setFetchedEpisodes] = useState(false);
const [noEpisodesFound, setNoEpisodesFound] = useState(false);
@@ -63,7 +63,7 @@ export default function Anime() {
if (manga === undefined || !manga.freshData) {
client.get(`/api/v1/anime/anime/${id}/?onlineFetch=${manga !== undefined}`)
.then((response) => response.data)
.then((data: IManga) => {
.then((data: IAnime) => {
setManga(data);
setTitle(data.title);
});

View File

@@ -63,7 +63,7 @@ export default function AnimeSearchSingle() {
if (searchTerm.length > 0) {
client.get(`/api/v1/anime/source/${sourceId}/search/${searchTerm}/${lastPageNum}`)
.then((response) => response.data)
.then((data: { mangaList: IManga[], hasNextPage: boolean }) => {
.then((data: { mangaList: IAnime[], hasNextPage: boolean }) => {
setMessage('');
if (data.mangaList.length > 0) {
setMangas([

View File

@@ -45,7 +45,7 @@ export default function Player() {
setTitle('Reader');
client.get(`/api/v1/anime/anime/${animeId}/`)
.then((response) => response.data)
.then((data: IManga) => {
.then((data: IAnime) => {
setTitle(data.title);
});
}, [episodeIndex]);

View File

@@ -30,7 +30,7 @@ export default function SourceAnimes(props: { popular: boolean }) {
const sourceType = props.popular ? 'popular' : 'latest';
client.get(`/api/v1/anime/source/${sourceId}/${sourceType}/${lastPageNum}`)
.then((response) => response.data)
.then((data: { mangaList: IManga[], hasNextPage: boolean }) => {
.then((data: { mangaList: IAnime[], hasNextPage: boolean }) => {
setMangas([
...mangas,
...data.mangaList.map((it) => ({

22
src/typings.d.ts vendored
View File

@@ -44,6 +44,28 @@ interface IManga {
title: string
thumbnailUrl: string
artist: string
author: string
description: string
genre: string[]
status: string
inLibrary: boolean
source: ISource
realUrl: string
freshData: boolean
}
interface IAnime {
id: number
sourceId: string
url: string
title: string
thumbnailUrl: string
artist: string
author: string
description: string