feature(database-connection): Refactor SeasonSwitch.tsx to functional components
This commit is contained in:
@@ -5,31 +5,29 @@ import './SeasonSwitch.scss';
|
|||||||
import SeasonDetail from '../SeasonDetail/SeasonDetail';
|
import SeasonDetail from '../SeasonDetail/SeasonDetail';
|
||||||
import {IUserListProperties} from "../UserList/UserList";
|
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">
|
<div className="SeasonSwitch" data-testid="SeasonSwitch">
|
||||||
{
|
{
|
||||||
seasonId > 1
|
seasonId > 1
|
||||||
&& <Link to={"/season/" + (seasonId - 1)} onClick={() => this.props.onSeasonIdChange('' + (seasonId - 1))}>
|
&& <Link to={"/season/" + (seasonId - 1)} onClick={() => props.onSeasonIdChange('' + (seasonId - 1))}>
|
||||||
<FontAwesomeIcon icon="arrow-circle-left"/>
|
<FontAwesomeIcon icon="arrow-circle-left"/>
|
||||||
</Link>
|
</Link>
|
||||||
}
|
}
|
||||||
|
|
||||||
<SeasonDetail {...this.props} />
|
<SeasonDetail {...props} />
|
||||||
|
|
||||||
{
|
{
|
||||||
seasonId !== maxSeasonId
|
seasonId !== maxSeasonId
|
||||||
&& <Link to={"/season/" + (seasonId + 1)} onClick={() => this.props.onSeasonIdChange('' + (seasonId + 1))}>
|
&& <Link to={"/season/" + (seasonId + 1)} onClick={() => props.onSeasonIdChange('' + (seasonId + 1))}>
|
||||||
<FontAwesomeIcon icon="arrow-circle-right"/>
|
<FontAwesomeIcon icon="arrow-circle-right"/>
|
||||||
</Link>
|
</Link>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
export default SeasonSwitch;
|
export default SeasonSwitch;
|
||||||
|
|||||||
Reference in New Issue
Block a user