diff --git a/frontend/src/pages/MainPage/MainPage.tsx b/frontend/src/pages/MainPage/MainPage.tsx index e5f3c1e..d5bba38 100644 --- a/frontend/src/pages/MainPage/MainPage.tsx +++ b/frontend/src/pages/MainPage/MainPage.tsx @@ -1,4 +1,4 @@ -import React, {FC, useCallback, useEffect, useState} from "react"; +import React, {FC, useEffect, useState} from "react"; import UserStatsMockService from "../../mock/UserStatsMockService"; import Header from "../../components/Header/Header"; import UserList from "../../components/UserList/UserList"; @@ -11,90 +11,12 @@ import RequestError from "../../models/RequestError"; import './MainPage.scss'; import {ClipLoader} from "react-spinners"; -// class MainPage extends React.Component { -// -// private apiService: UserStatsService = new UserStatsService(); -// private mockService = new UserStatsMockService(); -// -// constructor(props: IMainPageProps) { -// super(props) -// -// console.log("this.props.match.params.id = " + this.props.match.params.id) -// -// -// -// let seasonId = !this.props.match.params.id ? "1" : this.props.match.params.id -// -// console.log("seasonId = " + seasonId) -// -// this.state = { -// id: seasonId, -// error: undefined, -// loading: false, -// users: this.mockService.getStatsWithoutPromise("1") -// } -// } -// -// componentWillMount() { -// this.fetchData(); -// } -// -// componentDidUpdate(prevProps: Readonly) { -// const element = findDOMNode(this); -// if (element != null) { -// window.scrollTo(0, 0); -// } -// -// if(prevProps.match.params.id !== this.props.match.params.id) { -// this.setState({ id: this.props.match.params.id }) -// this.fetchData() -// } -// } -// -// private fetchData() { -// this.setState({ loading: true }) -// // this.apiService.getStats(this.state.id) -// // .then(data => this.setState({ -// // loading: false, -// // users: data -// // })) -// this.mockService.getStats(this.state.id) -// .then(data => this.setState({ -// loading: false, -// users: data -// })) -// } -// -// render() { -// console.log("this.state.id = " + this.state.id) -// console.log("this.state.users.seasonId = " + this.state.users.seasonId) -// -// return ( -//
-//
-// { -// this.state.error && -// } -// { -// (this.state.loading) -// ? -// : -// } -// {/* { this.state.error != null ?

{ this.state.error } Please try again later!

: null} */} -//
-//
-// ) -// } -// } - const MainPage: FC = (props: IMainPageProps) => { const [seasonId, setSeasonId] = useState(props.match.params.id) const [error, setError] = useState(undefined) const [loading, setLoadingState] = useState(true) const [seasonStats, setSeasonStats] = useState(UserStatsMockService.getStatsWithoutPromise(seasonId)) - const [spinnerColor, setSpinnerColor] = useState('#61dafb') - - const toggleLoading = useCallback(() => setLoadingState(!loading), [setLoadingState, loading]) + const [spinnerColor] = useState('#61dafb') useEffect(() => { UserStatsMockService.getStats(seasonId) @@ -117,22 +39,11 @@ const MainPage: FC = (props: IMainPageProps) => { { error && } - { + +
+ +
- } - { - // (loading) - // ? - // : - - } - {/*
*/} - -
- -
- {/*
*/} - {/* { this.state.error != null ?

{ this.state.error } Please try again later!

: null} */}