mirror of
https://github.com/C9Glax/tranga-website.git
synced 2025-04-19 14:53:20 +02:00
24 lines
713 B
TypeScript
24 lines
713 B
TypeScript
import React, {ReactElement, useEffect} from "react";
|
|
import {getData} from "../../App";
|
|
|
|
export default interface IAuthor {
|
|
authorId: string;
|
|
authorName: string;
|
|
}
|
|
|
|
export function AuthorElement({apiUri, authorId} : {apiUri: string, authorId: string | null}) : ReactElement{
|
|
if(authorId === null)
|
|
return (<p className="Manga-Author-Name">Author</p>);
|
|
|
|
let [name, setName] = React.useState<string>(authorId);
|
|
|
|
useEffect(()=> {
|
|
getData(`${apiUri}/v2/Query/Author/${authorId}`)
|
|
.then((json) => {
|
|
let ret = json as IAuthor;
|
|
setName(ret.authorName);
|
|
});
|
|
}, [])
|
|
|
|
return (<p className="Manga-Author-Name">{name}</p>);
|
|
} |