diff --git a/src/components/Calendar/Calendar.tsx b/src/components/Calendar/Calendar.tsx index d792822..774e83b 100644 --- a/src/components/Calendar/Calendar.tsx +++ b/src/components/Calendar/Calendar.tsx @@ -12,6 +12,8 @@ import { Button } from "@/components/UI/Button/Button"; import { Select } from "../UI/Select/Select"; import { Navigate } from "react-router-dom"; import config from "@/config"; +import { LiveIcon } from "../UI/AnimatedIcon/AnimatedIcon"; +import { calendarLiveScoreComponent } from "@/lib/helpers"; type CalendarProps = { weekId: number @@ -39,7 +41,7 @@ export const Calendar = (props: CalendarProps) => { weekId: props.weekId }); - useEffect(() => setState({...state, weekId: props.weekId}), [props]); + useEffect(() => setState({ ...state, weekId: props.weekId }), [props]); const onFilterChange = (name: string, value: string | number) => { const filters: any = Object.assign({}, state.filters, { [name]: value }); @@ -84,9 +86,9 @@ export const Calendar = (props: CalendarProps) => { render: (homeId: any, record: any) => { const clubBadge = `${props.assetsCdn}/badges/${record.home.id}.png`; - return - + return + ; } }, @@ -96,11 +98,13 @@ export const Calendar = (props: CalendarProps) => { dateIndex: "date", width: "20%", render: (txt: any, record: any) => { - const matchDate = dayjs(record.date); - const matchToStart = dayjs().isBefore(matchDate); - return - {matchToStart ? dayjs(record.date).format("HH:mm") : `${record.homeScore} - ${record.awayScore}`} - ; + // const matchDate = dayjs(record.date); + // const matchToStart = dayjs().isBefore(matchDate); + // return + // + // {matchToStart ? dayjs(record.date).format("HH:mm") : `${record.homeScore} - ${record.awayScore}`} + // ; + return calendarLiveScoreComponent(record); } }, { diff --git a/src/components/Calendar/CalendarStyle.tsx b/src/components/Calendar/CalendarStyle.tsx index d77451e..fa59e73 100644 --- a/src/components/Calendar/CalendarStyle.tsx +++ b/src/components/Calendar/CalendarStyle.tsx @@ -49,22 +49,28 @@ table { } .score { - &.started { + font-size: 18px; + display: flex; + justify-content: center; + + &.created, &.played, &.statsimported { + color:gray; } } } } `; -export const ClubDetails = styled.div<{left?: boolean}>` +export const ClubDetails = styled.div` display: flex; + flex-direction: column; padding: 5px; - justify-content: ${(props: any) => props.left ? "flex-end": "flex-start"}; + justify-content: center; align-items: center; `; export const ClubBadgeBg = styled.img` - max-width: 25px; + max-width: 50px; display: inline-block; margin: 5px; ` as any; diff --git a/src/components/UI/AnimatedIcon/AnimatedIcon.tsx b/src/components/UI/AnimatedIcon/AnimatedIcon.tsx new file mode 100644 index 0000000..44d4723 --- /dev/null +++ b/src/components/UI/AnimatedIcon/AnimatedIcon.tsx @@ -0,0 +1,14 @@ +/* eslint-disable react/no-unknown-property */ +import { LiveIconStyle } from "./AnimatedIconStyle"; + +export const LiveIcon = () => { + return ( + + + + + + + + ); +}; \ No newline at end of file diff --git a/src/components/UI/AnimatedIcon/AnimatedIconStyle.tsx b/src/components/UI/AnimatedIcon/AnimatedIconStyle.tsx new file mode 100644 index 0000000..454fe36 --- /dev/null +++ b/src/components/UI/AnimatedIcon/AnimatedIconStyle.tsx @@ -0,0 +1,7 @@ +import styled from "@/styles/styled-components"; + +export const LiveIconStyle = styled.div` +.svg { + margin:auto;background:#fff;display:block; +} +`; \ No newline at end of file diff --git a/src/lib/helpers.tsx b/src/lib/helpers.tsx index 29ccc6f..0e629a3 100644 --- a/src/lib/helpers.tsx +++ b/src/lib/helpers.tsx @@ -5,6 +5,8 @@ import React from "react"; import { toast } from "react-toastify"; import { UserOutlined, DownloadOutlined, SyncOutlined, CheckCircleOutlined, ClockCircleOutlined } from "@ant-design/icons"; import { TFunction } from "i18next"; +import dayjs from "dayjs"; +import { LiveIcon } from "@/components/UI/AnimatedIcon/AnimatedIcon"; declare type RowToPos = { rowNumber: number, @@ -225,4 +227,26 @@ export const getPointsOverviewList = (player: any, t: TFunction<"translation", u } }); return pointsOverview; +}; + +export const calendarLiveScoreComponent = (match: Match) => { + const matchDate = dayjs(match.date); + let text = null; + let icon = null; + let className = ""; + if(dayjs().isBefore(matchDate)) { + text = matchDate.format("HH:mm"); + } else { + if(dayjs().isBefore(matchDate.add(2, "hour"))) { + className = "live"; + text = "live"; + icon = ; + } else { + className = match.status.toLowerCase().replace("_",""); + text = `${match.awayScore} - ${match.homeScore}`; + } + } + + + return {icon?icon:null} {text}; }; \ No newline at end of file diff --git a/src/pages/Points/Points.tsx b/src/pages/Points/Points.tsx index 244314f..0aa8d53 100644 --- a/src/pages/Points/Points.tsx +++ b/src/pages/Points/Points.tsx @@ -24,6 +24,7 @@ import { Stats } from "@/components/Stats/Stats"; import { PointsStats } from "@/components/PointsStats/PointsStats"; import teamBackground from "./../../assets/img/fpl-pitch-no-boarding.svg"; import { MatchdaySelector } from "@/components/MatchdaySelector/MatchdaySelector"; +import { Spin } from "antd"; export const _TeamPoints = (props: AbstractTeamType) => { const { id } = useParams(); @@ -183,8 +184,8 @@ export const _TeamPoints = (props: AbstractTeamType) => { const isPublicRoute = location.pathname.includes("public"); return ( - clubsSuccess && playersSuccess && matchesSuccess && teamSuccess && deadlineInfoSuccess && - + // clubsSuccess && playersSuccess && matchesSuccess && teamSuccess && deadlineInfoSuccess && + { (initializedExternally && visibleWeekId && @@ -297,7 +298,7 @@ export const _TeamPoints = (props: AbstractTeamType) => { ) } - + ); };