better genre handling

This commit is contained in:
Aria Moradi
2021-08-21 06:19:56 +04:30
parent 889c9c68ac
commit 058d4cd18d
2 changed files with 3 additions and 5 deletions

View File

@@ -135,9 +135,7 @@ export default function MangaDetails(props: IProps) {
const { setAction } = useContext(NavbarContext); const { setAction } = useContext(NavbarContext);
const { manga } = props; const { manga } = props;
if (manga.genre == null) {
manga.genre = '';
}
const [inLibrary, setInLibrary] = useState<string>( const [inLibrary, setInLibrary] = useState<string>(
manga.inLibrary ? 'In Library' : 'Add To Library', manga.inLibrary ? 'In Library' : 'Add To Library',
); );
@@ -249,7 +247,7 @@ export default function MangaDetails(props: IProps) {
<p>{manga.description}</p> <p>{manga.description}</p>
</div> </div>
<div className={classes.genre}> <div className={classes.genre}>
{manga.genre.split(', ').map((g) => <h5 key={g}>{g}</h5>)} {manga.genre?.split(', ').map((g) => <h5 key={g}>{g}</h5>)}
</div> </div>
</div> </div>
</div> </div>

2
src/typings.d.ts vendored
View File

@@ -46,7 +46,7 @@ interface IManga {
artist: string artist: string
author: string author: string
description: string description: string
genre: string genre: string | null
status: string status: string
inLibrary: boolean inLibrary: boolean