From a5281181786f6fe856c41b057252d44c65f5d40f Mon Sep 17 00:00:00 2001 From: Humenius Date: Tue, 12 Jan 2021 12:42:27 +0100 Subject: [PATCH] feature(database-connection): Refactor SeasonSwitch.tsx to functional components --- .../components/SeasonSwitch/SeasonSwitch.tsx | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/frontend/src/components/SeasonSwitch/SeasonSwitch.tsx b/frontend/src/components/SeasonSwitch/SeasonSwitch.tsx index 50bce95..35d43b2 100644 --- a/frontend/src/components/SeasonSwitch/SeasonSwitch.tsx +++ b/frontend/src/components/SeasonSwitch/SeasonSwitch.tsx @@ -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 { +const SeasonSwitch: React.FC = (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 (
{ seasonId > 1 - && this.props.onSeasonIdChange('' + (seasonId - 1))}> - - + && props.onSeasonIdChange('' + (seasonId - 1))}> + + } - + { seasonId !== maxSeasonId - && this.props.onSeasonIdChange('' + (seasonId + 1))}> - - + && props.onSeasonIdChange('' + (seasonId + 1))}> + + }
) - } } export default SeasonSwitch;