2021-04-09 12:59:28 +02:00
|
|
|
import React from 'react';
|
2021-04-16 21:12:56 +02:00
|
|
|
import Preview from '../../elements/Preview/Preview';
|
2021-04-23 21:23:51 +02:00
|
|
|
import {APINode, callAPI, callAPIPlain} from '../../utils/Api';
|
2021-04-16 22:44:56 +02:00
|
|
|
import {TVShow} from '../../types/ApiTypes';
|
|
|
|
import DynamicContentContainer from '../../elements/DynamicContentContainer/DynamicContentContainer';
|
2021-04-19 20:31:56 +02:00
|
|
|
import {Route, Switch, useRouteMatch} from 'react-router-dom';
|
2021-04-20 21:17:34 +02:00
|
|
|
import EpisodePage from './EpisodePage';
|
2021-04-28 17:31:38 +02:00
|
|
|
import PageTitle, {Line} from '../../elements/PageTitle/PageTitle';
|
|
|
|
import SideBar, {SideBarItem, SideBarTitle} from '../../elements/SideBar/SideBar';
|
2021-04-16 22:44:56 +02:00
|
|
|
|
|
|
|
interface State {
|
|
|
|
loading: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface Props {}
|
|
|
|
|
|
|
|
class TVShowPage extends React.Component<Props, State> {
|
|
|
|
state = {
|
|
|
|
loading: true
|
|
|
|
};
|
|
|
|
|
|
|
|
data: TVShow.TVshowType[] = [];
|
|
|
|
|
|
|
|
componentDidMount(): void {
|
|
|
|
callAPI(APINode.TVShow, {action: 'getTVShows'}, (resp: TVShow.TVshowType[]) => {
|
|
|
|
this.data = resp;
|
|
|
|
this.setState({loading: false});
|
|
|
|
});
|
|
|
|
}
|
2021-04-09 12:59:28 +02:00
|
|
|
|
|
|
|
render(): JSX.Element {
|
2021-04-16 21:12:56 +02:00
|
|
|
return (
|
2021-04-28 17:31:38 +02:00
|
|
|
<>
|
|
|
|
<PageTitle title='TV Shows' subtitle='' />
|
|
|
|
<SideBar>
|
|
|
|
<SideBarTitle>Infos:</SideBarTitle>
|
|
|
|
<Line />
|
|
|
|
<SideBarItem>
|
|
|
|
<b>{this.data.length}</b> TV-Shows Total!
|
|
|
|
</SideBarItem>
|
|
|
|
</SideBar>
|
|
|
|
<div>
|
|
|
|
<DynamicContentContainer
|
|
|
|
renderElement={(elem): JSX.Element => (
|
|
|
|
<Preview
|
|
|
|
key={elem.Id}
|
|
|
|
name={elem.Name}
|
|
|
|
picLoader={(callback: (pic: string) => void): void => {
|
|
|
|
callAPIPlain(
|
|
|
|
APINode.TVShow,
|
|
|
|
{
|
|
|
|
action: 'readThumbnail',
|
|
|
|
Id: elem.Id
|
|
|
|
},
|
|
|
|
(result) => callback(result)
|
|
|
|
);
|
|
|
|
}}
|
|
|
|
linkPath={'/tvshows/' + elem.Id}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
data={this.state.loading ? [] : this.data}
|
|
|
|
initialLoadNr={20}
|
2021-04-20 21:17:34 +02:00
|
|
|
/>
|
2021-04-28 17:31:38 +02:00
|
|
|
</div>
|
|
|
|
</>
|
2021-04-16 21:12:56 +02:00
|
|
|
);
|
2021-04-09 12:59:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-19 20:31:56 +02:00
|
|
|
export default function (): JSX.Element {
|
|
|
|
let match = useRouteMatch();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Switch>
|
2021-04-20 21:17:34 +02:00
|
|
|
<Route path={`${match.path}/:id`}>
|
|
|
|
<EpisodePage />
|
2021-04-19 20:31:56 +02:00
|
|
|
</Route>
|
|
|
|
<Route path={match.path}>
|
|
|
|
<TVShowPage />
|
|
|
|
</Route>
|
|
|
|
</Switch>
|
|
|
|
);
|
|
|
|
}
|