diff --git a/src/pages/Contests.page.jsx b/src/pages/Contests.page.jsx index 64d18be..e24e6e9 100644 --- a/src/pages/Contests.page.jsx +++ b/src/pages/Contests.page.jsx @@ -1,95 +1,148 @@ -import React, {useContext, useEffect} from 'react' -import {Button, Card, Divider, Image, List, Row, Skeleton, Typography} from 'antd' -import Meta from 'antd/lib/card/Meta'; -import {parseDate} from "../utils/utils"; -import {BarChartOutlined, ClockCircleOutlined, EnterOutlined} from '@ant-design/icons' -import './contests.page.css' +import React, { useContext, useEffect } from "react"; +import { + Button, + Card, + Divider, + Image, + List, + Row, + Skeleton, + Typography, +} from "antd"; +import Meta from "antd/lib/card/Meta"; +import { parseDate } from "../utils/utils"; +import { + BarChartOutlined, + ClockCircleOutlined, + EnterOutlined, +} from "@ant-design/icons"; +import "./contests.page.css"; import GlobalContext from "../context/GlobalContext"; -const {Title} = Typography; - +const { Title } = Typography; function Contests(props) { + const globalContext = useContext(GlobalContext); - const globalContext = useContext(GlobalContext) - - useEffect(() => { - // eslint-disable-next-line - }, []); + useEffect(() => { + // eslint-disable-next-line + }, []); - async function handleEnterContest(contest) { - props.history.push('/contests/' + contest.contest_id.id) + async function handleEnterContest(contest) { + try { + props.history.push("/contests/" + contest.contest_id.id); + } catch (e) { + console.log(e); } - async function handleEnterLeaderboard(contest) { - props.history.push('/leaderboard/' + contest.contest_id.id) + } + async function handleEnterLeaderboard(contest) { + try { + props.history.push("/leaderboard/" + contest.contest_id.id); + } catch (e) { + console.log(e); } + } - return ( -
- Contests - - - ( - - } - > - - {!globalContext.isContestsLoading && <>{item.contest_id.name}} - /> -
-

  - Starts: {parseDate(item.contest_id.start_time)} -

-

  - Ends: {parseDate(item.contest_id.end_time)}

- - } - - { - globalContext.isContestsLoading || (!globalContext.isContestsLoading && (new Date(item.contest_id.end_time) < new Date()))? - : - - } - - - + return ( +
+ Contests + - - - + ( + + + } + > + + {!globalContext.isContestsLoading && ( + <> + + {item.contest_id.name} + + } + /> +
+

+ +   + Starts:{" "} + {parseDate(item.contest_id.start_time)} +

+

+ +   + Ends: {parseDate(item.contest_id.end_time)} +

+ + + )} + + {globalContext.isContestsLoading || + (!globalContext.isContestsLoading && + new Date(item.contest_id.end_time) < new Date()) ? ( + + ) : ( + )} - /> -
- ) +
+
+
+ )} + /> +
+ ); } -export default Contests +export default Contests;