2021-04-20 21:17:34 +02:00
|
|
|
import * as React from 'react';
|
|
|
|
import {RouteComponentProps} from 'react-router';
|
|
|
|
import {withRouter} from 'react-router-dom';
|
2021-08-20 21:20:33 +02:00
|
|
|
import {callAPI} from 'gowebsecure';
|
2021-04-20 21:17:34 +02:00
|
|
|
import {Link} from 'react-router-dom';
|
|
|
|
import DynamicContentContainer from '../../elements/DynamicContentContainer/DynamicContentContainer';
|
2021-04-28 17:31:38 +02:00
|
|
|
import tileStyle from './EpisodeTile.module.css';
|
|
|
|
import GlobalInfos from '../../utils/GlobalInfos';
|
|
|
|
import {faPlay} from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
|
|
|
|
import PageTitle, {Line} from '../../elements/PageTitle/PageTitle';
|
|
|
|
import SideBar, {SideBarItem, SideBarTitle} from '../../elements/SideBar/SideBar';
|
2021-08-20 21:20:33 +02:00
|
|
|
import {APINode} from '../../types/ApiTypes';
|
2021-04-20 21:17:34 +02:00
|
|
|
|
|
|
|
interface Props extends RouteComponentProps<{id: string}> {}
|
|
|
|
|
|
|
|
interface State {
|
|
|
|
loaded: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface Episode {
|
|
|
|
ID: number;
|
|
|
|
Name: string;
|
|
|
|
Season: number;
|
|
|
|
Episode: number;
|
|
|
|
}
|
|
|
|
|
2021-04-28 17:31:38 +02:00
|
|
|
export class EpisodePage extends React.Component<Props, State> {
|
2021-04-20 21:17:34 +02:00
|
|
|
episodes: Episode[] = [];
|
|
|
|
|
|
|
|
state = {
|
|
|
|
loaded: false
|
|
|
|
};
|
|
|
|
|
|
|
|
componentDidMount(): void {
|
|
|
|
callAPI(APINode.TVShow, {action: 'getEpisodes', ShowID: parseInt(this.props.match.params.id, 10)}, (episodes: Episode[]) => {
|
|
|
|
this.episodes = episodes;
|
|
|
|
this.setState({loaded: true});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
render(): JSX.Element {
|
|
|
|
if (!this.state.loaded) {
|
|
|
|
return <>loading...</>;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2021-04-28 17:31:38 +02:00
|
|
|
<PageTitle title='TV Shows' subtitle='' />
|
|
|
|
<SideBar>
|
|
|
|
<SideBarTitle>Infos:</SideBarTitle>
|
|
|
|
<Line />
|
|
|
|
<SideBarItem>
|
|
|
|
<b>{this.episodes.length}</b> Episodes Total!
|
|
|
|
</SideBarItem>
|
|
|
|
</SideBar>
|
2021-04-20 21:17:34 +02:00
|
|
|
<DynamicContentContainer
|
|
|
|
renderElement={(el): JSX.Element => <EpisodeTile key={el.ID} episode={el} />}
|
|
|
|
data={this.episodes}
|
2021-04-23 21:23:51 +02:00
|
|
|
initialLoadNr={-1}
|
2021-04-20 21:17:34 +02:00
|
|
|
/>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-28 17:31:38 +02:00
|
|
|
export const EpisodeTile = (props: {episode: Episode}): JSX.Element => {
|
|
|
|
const themestyle = GlobalInfos.getThemeStyle();
|
2021-04-20 21:17:34 +02:00
|
|
|
return (
|
|
|
|
<Link to={'/tvplayer/' + props.episode.ID}>
|
2021-04-28 17:31:38 +02:00
|
|
|
<div className={tileStyle.tile + ' ' + themestyle.secbackground + ' ' + themestyle.textcolor}>
|
|
|
|
<FontAwesomeIcon
|
|
|
|
style={{
|
|
|
|
marginRight: '10px'
|
|
|
|
}}
|
|
|
|
icon={faPlay}
|
|
|
|
size='1x'
|
|
|
|
/>
|
|
|
|
Season: {props.episode.Season} Episode: {props.episode.Episode} {props.episode.Name}
|
2021-04-20 21:17:34 +02:00
|
|
|
</div>
|
|
|
|
</Link>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default withRouter(EpisodePage);
|