use eslint to lint project
drop code quality job
This commit is contained in:
@ -11,7 +11,7 @@ import {DefaultTags, GeneralSuccess} from '../../types/GeneralTypes';
|
||||
import {Button} from '../../elements/GPElements/Button';
|
||||
import SubmitPopup from '../../elements/Popups/SubmitPopup/SubmitPopup';
|
||||
|
||||
interface CategoryViewProps extends RouteComponentProps<{ id: string }> {}
|
||||
interface CategoryViewProps extends RouteComponentProps<{id: string}> {}
|
||||
|
||||
interface CategoryViewState {
|
||||
loaded: boolean;
|
||||
@ -34,42 +34,51 @@ export class CategoryView extends React.Component<CategoryViewProps, CategoryVie
|
||||
}
|
||||
|
||||
componentDidMount(): void {
|
||||
this.fetchVideoData(parseInt(this.props.match.params.id));
|
||||
this.fetchVideoData(parseInt(this.props.match.params.id, 10));
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps: Readonly<CategoryViewProps>, prevState: Readonly<CategoryViewState>): void {
|
||||
componentDidUpdate(prevProps: Readonly<CategoryViewProps>): void {
|
||||
// trigger video refresh if id changed
|
||||
if (prevProps.match.params.id !== this.props.match.params.id) {
|
||||
this.setState({loaded: false});
|
||||
this.fetchVideoData(parseInt(this.props.match.params.id));
|
||||
this.reloadVideoData();
|
||||
}
|
||||
}
|
||||
|
||||
reloadVideoData(): void {
|
||||
this.setState({loaded: false});
|
||||
this.fetchVideoData(parseInt(this.props.match.params.id, 10));
|
||||
}
|
||||
|
||||
render(): JSX.Element {
|
||||
return (
|
||||
<>
|
||||
<PageTitle
|
||||
title='Categories'
|
||||
subtitle={this.videodata.length + ' Videos'}/>
|
||||
<PageTitle title='Categories' subtitle={this.videodata.length + ' Videos'} />
|
||||
|
||||
<SideBar>
|
||||
<SideBarTitle>Default Tags:</SideBarTitle>
|
||||
<Tag tagInfo={DefaultTags.all}/>
|
||||
<Tag tagInfo={DefaultTags.fullhd}/>
|
||||
<Tag tagInfo={DefaultTags.hd}/>
|
||||
<Tag tagInfo={DefaultTags.lowq}/>
|
||||
<Tag tagInfo={DefaultTags.all} />
|
||||
<Tag tagInfo={DefaultTags.fullhd} />
|
||||
<Tag tagInfo={DefaultTags.hd} />
|
||||
<Tag tagInfo={DefaultTags.lowq} />
|
||||
|
||||
<Line/>
|
||||
<Button title='Delete Tag' onClick={(): void => {this.deleteTag(false);}} color={{backgroundColor: 'red'}}/>
|
||||
</SideBar>
|
||||
{this.state.loaded ?
|
||||
<VideoContainer
|
||||
data={this.videodata}/> : null}
|
||||
|
||||
<button data-testid='backbtn' className='btn btn-success'
|
||||
<Line />
|
||||
<Button
|
||||
title='Delete Tag'
|
||||
onClick={(): void => {
|
||||
this.props.history.push('/categories');
|
||||
}}>Back to Categories
|
||||
this.deleteTag(false);
|
||||
}}
|
||||
color={{backgroundColor: 'red'}}
|
||||
/>
|
||||
</SideBar>
|
||||
{this.state.loaded ? <VideoContainer data={this.videodata} /> : null}
|
||||
|
||||
<button
|
||||
data-testid='backbtn'
|
||||
className='btn btn-success'
|
||||
onClick={(): void => {
|
||||
this.props.history.push('/categories');
|
||||
}}>
|
||||
Back to Categories
|
||||
</button>
|
||||
{this.handlePopups()}
|
||||
</>
|
||||
@ -78,9 +87,14 @@ export class CategoryView extends React.Component<CategoryViewProps, CategoryVie
|
||||
|
||||
private handlePopups(): JSX.Element {
|
||||
if (this.state.submitForceDelete) {
|
||||
return (<SubmitPopup
|
||||
onHide={(): void => this.setState({submitForceDelete: false})}
|
||||
submit={(): void => {this.deleteTag(true);}}/>);
|
||||
return (
|
||||
<SubmitPopup
|
||||
onHide={(): void => this.setState({submitForceDelete: false})}
|
||||
submit={(): void => {
|
||||
this.deleteTag(true);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
return <></>;
|
||||
}
|
||||
@ -91,7 +105,7 @@ export class CategoryView extends React.Component<CategoryViewProps, CategoryVie
|
||||
* @param id tagid
|
||||
*/
|
||||
private fetchVideoData(id: number): void {
|
||||
callAPI<VideoTypes.VideoUnloadedType[]>(APINode.Video, {action: 'getMovies', tag: id}, result => {
|
||||
callAPI<VideoTypes.VideoUnloadedType[]>(APINode.Video, {action: 'getMovies', tag: id}, (result) => {
|
||||
this.videodata = result;
|
||||
this.setState({loaded: true});
|
||||
});
|
||||
@ -101,19 +115,23 @@ export class CategoryView extends React.Component<CategoryViewProps, CategoryVie
|
||||
* delete the current tag
|
||||
*/
|
||||
private deleteTag(force: boolean): void {
|
||||
callAPI<GeneralSuccess>(APINode.Tags, {
|
||||
action: 'deleteTag',
|
||||
TagId: parseInt(this.props.match.params.id),
|
||||
Force: force
|
||||
}, result => {
|
||||
console.log(result.result);
|
||||
if (result.result === 'success') {
|
||||
this.props.history.push('/categories');
|
||||
} else if (result.result === 'not empty tag') {
|
||||
// show submisison tag to ask if really delete
|
||||
this.setState({submitForceDelete: true});
|
||||
callAPI<GeneralSuccess>(
|
||||
APINode.Tags,
|
||||
{
|
||||
action: 'deleteTag',
|
||||
TagId: parseInt(this.props.match.params.id, 10),
|
||||
Force: force
|
||||
},
|
||||
(result) => {
|
||||
console.log(result.result);
|
||||
if (result.result === 'success') {
|
||||
this.props.history.push('/categories');
|
||||
} else if (result.result === 'not empty tag') {
|
||||
// show submisison tag to ask if really delete
|
||||
this.setState({submitForceDelete: true});
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user