feature(database-connection): Refactor SeasonSwitch.tsx to functional components
This commit is contained in:
@@ -1,35 +1,33 @@
|
||||
import React from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import {Link} from 'react-router-dom';
|
||||
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
|
||||
import './SeasonSwitch.scss';
|
||||
import SeasonDetail from '../SeasonDetail/SeasonDetail';
|
||||
import {IUserListProperties} from "../UserList/UserList";
|
||||
|
||||
class SeasonSwitch extends React.Component<IUserListProperties> {
|
||||
const SeasonSwitch: React.FC<IUserListProperties> = (props: IUserListProperties) => {
|
||||
const seasonId = Number(props.userStats.seasonId)
|
||||
const maxSeasonId = Number(props.userStats.maxSeasonId)
|
||||
|
||||
render() {
|
||||
let seasonId = Number(this.props.userStats.seasonId)
|
||||
let maxSeasonId = Number(this.props.userStats.maxSeasonId)
|
||||
return(
|
||||
return (
|
||||
<div className="SeasonSwitch" data-testid="SeasonSwitch">
|
||||
{
|
||||
seasonId > 1
|
||||
&& <Link to={"/season/" + (seasonId - 1)} onClick={() => this.props.onSeasonIdChange('' + (seasonId - 1))}>
|
||||
<FontAwesomeIcon icon="arrow-circle-left" />
|
||||
</Link>
|
||||
&& <Link to={"/season/" + (seasonId - 1)} onClick={() => props.onSeasonIdChange('' + (seasonId - 1))}>
|
||||
<FontAwesomeIcon icon="arrow-circle-left"/>
|
||||
</Link>
|
||||
}
|
||||
|
||||
<SeasonDetail {...this.props} />
|
||||
<SeasonDetail {...props} />
|
||||
|
||||
{
|
||||
seasonId !== maxSeasonId
|
||||
&& <Link to={"/season/" + (seasonId + 1)} onClick={() => this.props.onSeasonIdChange('' + (seasonId + 1))}>
|
||||
<FontAwesomeIcon icon="arrow-circle-right" />
|
||||
</Link>
|
||||
&& <Link to={"/season/" + (seasonId + 1)} onClick={() => props.onSeasonIdChange('' + (seasonId + 1))}>
|
||||
<FontAwesomeIcon icon="arrow-circle-right"/>
|
||||
</Link>
|
||||
}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default SeasonSwitch;
|
||||
|
||||
Reference in New Issue
Block a user