From 6d22602fae4bab6e110451c7b37319e1b004af2b Mon Sep 17 00:00:00 2001 From: rngsurrounded Date: Mon, 3 Mar 2025 05:35:46 +0900 Subject: [PATCH] feat: started adding timers support for events --- .../frontend/src/pages/Competition/index.tsx | 59 +++++++++++++++++-- .../components/CompetitionCard/index.tsx | 38 +++++++++++- 2 files changed, 91 insertions(+), 6 deletions(-) diff --git a/services/frontend/src/pages/Competition/index.tsx b/services/frontend/src/pages/Competition/index.tsx index 2c87809..e472ddb 100644 --- a/services/frontend/src/pages/Competition/index.tsx +++ b/services/frontend/src/pages/Competition/index.tsx @@ -1,11 +1,12 @@ import { useParams, Link, useNavigate } from "react-router-dom"; import { Button } from "@/components/ui/button"; -import { ArrowLeft } from "lucide-react"; +import { ArrowLeft, Clock, Trophy, BookOpen } from "lucide-react"; import ReactMarkdown from "react-markdown"; import { useQuery, useMutation } from "@tanstack/react-query"; import { getCompetition, startCompetition } from "@/shared/api/competitions"; import { getCompetitionTasks } from "@/shared/api/session"; import { Loading } from "@/components/ui/loading"; +import { CompetitionType } from "@/shared/types/competition"; const CompetitionPage = () => { const { id } = useParams<{ id: string }>(); @@ -38,6 +39,19 @@ const CompetitionPage = () => { console.error("Failed to start competition:", error); } }); + const formatDate = (date?: Date | string) => { + if (!date) return ""; + + const dateObj = typeof date === 'string' ? new Date(date) : date; + + return dateObj.toLocaleString('ru-RU', { + day: '2-digit', + month: '2-digit', + year: 'numeric', + hour: '2-digit', + minute: '2-digit', + }); + }; const handleStart = () => { startMutation.mutate(); @@ -74,13 +88,50 @@ const CompetitionPage = () => {
-

- {competition.title} -

+
+
+
+ {competition.type === CompetitionType.COMPETITIVE ? ( + <> + + Соревнование + + ) : ( + <> + + Тренировка + + )} +
+
+ +

+ {competition.title} +

+ + {competition.type === CompetitionType.COMPETITIVE && ( +
+ {competition.start_date && ( +
+ + Начало: {formatDate(competition.start_date)} +
+ )} + {competition.end_date && ( +
+ + Окончание: {formatDate(competition.end_date)} +
+ )} +
+ )} +
+
{competition.description || ""}
+
- +
@@ -46,11 +61,30 @@ export function CompetitionCard({ )}
+

{competition.title}

+ + {competition.type === CompetitionType.COMPETITIVE && ( +
+ {competition.start_date && ( +
+ + Начало: {formatDate(competition.start_date)} +
+ )} + + {competition.end_date && ( +
+ + Конец: {formatDate(competition.end_date)} +
+ )} +
+ )}
); -} +} \ No newline at end of file