mirror of
https://gitlab.com/megazordpobeda/DataRush.git
synced 2026-05-22 22:07:10 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -1 +1,33 @@
|
||||
# DataRush
|
||||
|
||||
Инновационный сервис для проведения соревнований по анализу данных
|
||||
|
||||
|
||||
## Запуск
|
||||
|
||||
Склонируйте репозиторий и пропишите
|
||||
|
||||
```bash
|
||||
docker compose up
|
||||
```
|
||||
|
||||
## Основные ручки
|
||||
|
||||
* `/` - основное приложение
|
||||
* `/api/v1/docs` - swagger-ui документация
|
||||
* `/admin` - админка
|
||||
* `/admin/grafana` - графана
|
||||
* `/docs` - гайд по анализу данных
|
||||
|
||||
После запуска по методу выше создается пользователь в админке (`/admin`) с данными ниже:`admin`
|
||||
- `admin` - логин
|
||||
- `proooooood` - пароль
|
||||
|
||||
|
||||
## Тесты
|
||||
|
||||
Написаны unit-тесты (на базе Django TestCase) и E2E (Postman коллекция)
|
||||
|
||||

|
||||
|
||||
![django test]()
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 261 KiB |
@@ -67,3 +67,4 @@ class TaskAttachmentSchema(ModelSchema):
|
||||
class TaskStatusSchema(Schema):
|
||||
task_name: str
|
||||
result: int
|
||||
max_points: int
|
||||
|
||||
@@ -196,14 +196,21 @@ def get_competition_results(request, competition_id: UUID):
|
||||
for task in tasks:
|
||||
submissions = CompetitionTaskSubmission.objects.filter(
|
||||
user=request.auth, task=task
|
||||
).filter(status="checked").all()
|
||||
).filter(status="checked").order_by("-earned_points").all()
|
||||
if not submissions:
|
||||
result = 0
|
||||
all_submissions_count = CompetitionTaskSubmission.objects.filter(
|
||||
user=request.auth, task=task
|
||||
).count()
|
||||
if all_submissions_count == 0:
|
||||
result = -2
|
||||
else:
|
||||
result = -1
|
||||
else:
|
||||
result = submissions[0].earned_points
|
||||
data.append(TaskStatusSchema(
|
||||
task_name=task.title,
|
||||
result=result
|
||||
result=result,
|
||||
max_points=task.points,
|
||||
))
|
||||
|
||||
return status.OK, data
|
||||
|
||||
@@ -21,12 +21,12 @@ def analyze_data_task(self, submission_id):
|
||||
{
|
||||
"url": (
|
||||
f"{settings.MINIO_DEFAULT_CUSTOM_ENDPOINT_URL}/"
|
||||
f"{urlparse(submission.content.url).path}"
|
||||
f"{urlparse(attachment.file.url).path}"
|
||||
),
|
||||
"bind_path": attachment.bind_at,
|
||||
}
|
||||
for attachment in submission.task.attachments.filter(
|
||||
bind_path__isnull=False
|
||||
bind_at__isnull=False
|
||||
)
|
||||
]
|
||||
|
||||
@@ -37,7 +37,7 @@ def analyze_data_task(self, submission_id):
|
||||
"code_url": code_url,
|
||||
"answer_file_path": submission.task.answer_file_path,
|
||||
"expected_hash": hashlib.sha256(
|
||||
submission.task.correct_answer_file.read().encode()
|
||||
submission.task.correct_answer_file.read()
|
||||
).hexdigest(),
|
||||
},
|
||||
timeout=30,
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
"name": "frontend",
|
||||
"dependencies": {
|
||||
"@monaco-editor/react": "^4.7.0",
|
||||
"@radix-ui/react-accordion": "^1.2.3",
|
||||
"@radix-ui/react-dialog": "^1.1.6",
|
||||
"@radix-ui/react-dropdown-menu": "^2.1.6",
|
||||
"@radix-ui/react-label": "^2.1.2",
|
||||
@@ -154,8 +155,12 @@
|
||||
|
||||
"@radix-ui/primitive": ["@radix-ui/primitive@1.1.1", "", {}, "sha512-SJ31y+Q/zAyShtXJc8x83i9TYdbAfHZ++tUZnvjJJqFjzsdUnKsxPL6IEtBlxKkU7yzer//GQtZSV4GbldL3YA=="],
|
||||
|
||||
"@radix-ui/react-accordion": ["@radix-ui/react-accordion@1.2.3", "", { "dependencies": { "@radix-ui/primitive": "1.1.1", "@radix-ui/react-collapsible": "1.1.3", "@radix-ui/react-collection": "1.1.2", "@radix-ui/react-compose-refs": "1.1.1", "@radix-ui/react-context": "1.1.1", "@radix-ui/react-direction": "1.1.0", "@radix-ui/react-id": "1.1.0", "@radix-ui/react-primitive": "2.0.2", "@radix-ui/react-use-controllable-state": "1.1.0" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-RIQ15mrcvqIkDARJeERSuXSry2N8uYnxkdDetpfmalT/+0ntOXLkFOsh9iwlAsCv+qcmhZjbdJogIm6WBa6c4A=="],
|
||||
|
||||
"@radix-ui/react-arrow": ["@radix-ui/react-arrow@1.1.2", "", { "dependencies": { "@radix-ui/react-primitive": "2.0.2" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-G+KcpzXHq24iH0uGG/pF8LyzpFJYGD4RfLjCIBfGdSLXvjLHST31RUiRVrupIBMvIppMgSzQ6l66iAxl03tdlg=="],
|
||||
|
||||
"@radix-ui/react-collapsible": ["@radix-ui/react-collapsible@1.1.3", "", { "dependencies": { "@radix-ui/primitive": "1.1.1", "@radix-ui/react-compose-refs": "1.1.1", "@radix-ui/react-context": "1.1.1", "@radix-ui/react-id": "1.1.0", "@radix-ui/react-presence": "1.1.2", "@radix-ui/react-primitive": "2.0.2", "@radix-ui/react-use-controllable-state": "1.1.0", "@radix-ui/react-use-layout-effect": "1.1.0" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-jFSerheto1X03MUC0g6R7LedNW9EEGWdg9W1+MlpkMLwGkgkbUXLPBH/KIuWKXUoeYRVY11llqbTBDzuLg7qrw=="],
|
||||
|
||||
"@radix-ui/react-collection": ["@radix-ui/react-collection@1.1.2", "", { "dependencies": { "@radix-ui/react-compose-refs": "1.1.1", "@radix-ui/react-context": "1.1.1", "@radix-ui/react-primitive": "2.0.2", "@radix-ui/react-slot": "1.1.2" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-9z54IEKRxIa9VityapoEYMuByaG42iSy1ZXlY2KcuLSEtq8x4987/N6m15ppoMffgZX72gER2uHe1D9Y6Unlcw=="],
|
||||
|
||||
"@radix-ui/react-compose-refs": ["@radix-ui/react-compose-refs@1.1.1", "", { "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-Y9VzoRDSJtgFMUCoiZBDVo084VQ5hfpXxVE+NgkdNsjiDBByiImMZKKhxMwCbdHvhlENG6a833CbFkOQvTricw=="],
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@monaco-editor/react": "^4.7.0",
|
||||
"@radix-ui/react-accordion": "^1.2.3",
|
||||
"@radix-ui/react-dialog": "^1.1.6",
|
||||
"@radix-ui/react-dropdown-menu": "^2.1.6",
|
||||
"@radix-ui/react-label": "^2.1.2",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { DataRush } from "@/components/ui/icons/datarush";
|
||||
import { ChevronDown } from "lucide-react";
|
||||
import { ChevronDown, FileText } from "lucide-react";
|
||||
import { Link, useNavigate } from "react-router";
|
||||
import { useUserStore } from "@/shared/stores/user";
|
||||
import {
|
||||
@@ -14,6 +14,13 @@ import { removeToken } from "@/shared/token";
|
||||
export const Header = () => {
|
||||
const navigate = useNavigate();
|
||||
const user = useUserStore((state) => state.user);
|
||||
const clearUser = useUserStore((state) => state.clearUser);
|
||||
|
||||
const handleLogout = () => {
|
||||
removeToken();
|
||||
clearUser();
|
||||
navigate("/login");
|
||||
};
|
||||
|
||||
return (
|
||||
<header className="bg-card sticky top-0 z-30 flex h-[72px] w-full items-center justify-center px-4 sm:px-6">
|
||||
@@ -21,33 +28,39 @@ export const Header = () => {
|
||||
<Link to="/">
|
||||
<DataRush />
|
||||
</Link>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<button className="flex cursor-pointer items-center gap-1 rounded-md px-2 py-1 text-left transition-opacity hover:opacity-80">
|
||||
<span className="font-hse-sans text-lg font-semibold">
|
||||
{user?.username}
|
||||
</span>
|
||||
<ChevronDown size={20} />
|
||||
</button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent>
|
||||
<Link to="/profile">
|
||||
<DropdownMenuItem>Аккаунт</DropdownMenuItem>
|
||||
</Link>
|
||||
<DropdownMenuSeparator />
|
||||
|
||||
<DropdownMenuItem
|
||||
variant="destructive"
|
||||
onClick={() => {
|
||||
removeToken();
|
||||
navigate("/login");
|
||||
}}
|
||||
>
|
||||
Выйти
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
|
||||
<div className="flex items-center gap-4">
|
||||
<a
|
||||
href="/docs/"
|
||||
className="text-sm font-medium text-gray-700 hover:text-gray-900 transition-colors flex items-center gap-1"
|
||||
>
|
||||
<FileText className="h-4 w-4" />
|
||||
</a>
|
||||
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<button className="flex cursor-pointer items-center gap-1 rounded-md px-2 py-1 text-left transition-opacity hover:opacity-80">
|
||||
<span className="font-hse-sans text-lg font-semibold">
|
||||
{user?.username}
|
||||
</span>
|
||||
<ChevronDown size={20} />
|
||||
</button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent>
|
||||
<Link to="/profile">
|
||||
<DropdownMenuItem>Аккаунт</DropdownMenuItem>
|
||||
</Link>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem
|
||||
variant="destructive"
|
||||
onClick={handleLogout}
|
||||
>
|
||||
Выйти
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,64 @@
|
||||
import * as React from "react"
|
||||
import * as AccordionPrimitive from "@radix-ui/react-accordion"
|
||||
import { ChevronDownIcon } from "lucide-react"
|
||||
|
||||
import { cn } from "@/shared/lib/utils"
|
||||
|
||||
function Accordion({
|
||||
...props
|
||||
}: React.ComponentProps<typeof AccordionPrimitive.Root>) {
|
||||
return <AccordionPrimitive.Root data-slot="accordion" {...props} />
|
||||
}
|
||||
|
||||
function AccordionItem({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof AccordionPrimitive.Item>) {
|
||||
return (
|
||||
<AccordionPrimitive.Item
|
||||
data-slot="accordion-item"
|
||||
className={cn("border-b last:border-b-0", className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function AccordionTrigger({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}: React.ComponentProps<typeof AccordionPrimitive.Trigger>) {
|
||||
return (
|
||||
<AccordionPrimitive.Header className="flex">
|
||||
<AccordionPrimitive.Trigger
|
||||
data-slot="accordion-trigger"
|
||||
className={cn(
|
||||
"focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<ChevronDownIcon className="text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200" />
|
||||
</AccordionPrimitive.Trigger>
|
||||
</AccordionPrimitive.Header>
|
||||
)
|
||||
}
|
||||
|
||||
function AccordionContent({
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}: React.ComponentProps<typeof AccordionPrimitive.Content>) {
|
||||
return (
|
||||
<AccordionPrimitive.Content
|
||||
data-slot="accordion-content"
|
||||
className="data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm"
|
||||
{...props}
|
||||
>
|
||||
<div className={cn("pt-0 pb-4", className)}>{children}</div>
|
||||
</AccordionPrimitive.Content>
|
||||
)
|
||||
}
|
||||
|
||||
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent }
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useState } from "react";
|
||||
import { useParams, Navigate } from "react-router-dom";
|
||||
import { useState, useEffect } from "react";
|
||||
import { useParams, Navigate, useNavigate } from "react-router-dom";
|
||||
import CompetitionHeader from "./components/CompetitionHeader";
|
||||
import TaskContent from "./components/TaskContent";
|
||||
import TaskSolution from "./modules/TaskSolution";
|
||||
@@ -13,8 +13,10 @@ const CompetitionSession = () => {
|
||||
const { id, taskId } = useParams<{ id: string; taskId?: string }>();
|
||||
const [answer, setAnswer] = useState("");
|
||||
const [selectedFile, setSelectedFile] = useState<File | null>(null);
|
||||
const [isReloading, setIsReloading] = useState(false);
|
||||
const competitionId = id || "";
|
||||
const queryClient = useQueryClient();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const competitionQuery = useQuery({
|
||||
queryKey: ["competition", competitionId],
|
||||
@@ -45,8 +47,12 @@ const CompetitionSession = () => {
|
||||
queryKey: ['solutionHistory', competitionId, taskId]
|
||||
});
|
||||
|
||||
setAnswer("");
|
||||
setSelectedFile(null);
|
||||
setIsReloading(true);
|
||||
|
||||
setTimeout(() => {
|
||||
window.location.reload()
|
||||
setIsReloading(false);
|
||||
}, 2500);
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error("Error submitting solution:", error);
|
||||
@@ -89,6 +95,13 @@ const CompetitionSession = () => {
|
||||
|
||||
const competitionTitle = competition?.title || "Загрузка соревнования...";
|
||||
|
||||
useEffect(() => {
|
||||
setAnswer("");
|
||||
setSelectedFile(null);
|
||||
}, [taskId]);
|
||||
|
||||
const isSubmitting = submitMutation.isPending || isReloading;
|
||||
|
||||
return (
|
||||
<div className="flex min-h-screen flex-col">
|
||||
<CompetitionHeader
|
||||
@@ -123,7 +136,7 @@ const CompetitionSession = () => {
|
||||
selectedFile={selectedFile}
|
||||
setSelectedFile={setSelectedFile}
|
||||
onSubmit={handleSubmit}
|
||||
isSubmitting={submitMutation.isPending}
|
||||
isSubmitting={isSubmitting}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
|
||||
@@ -27,7 +27,7 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
|
||||
selectedFile,
|
||||
setSelectedFile,
|
||||
onSubmit,
|
||||
isSubmitting = false
|
||||
isSubmitting = false,
|
||||
}) => {
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
const [isHistoryOpen, setIsHistoryOpen] = useState(false);
|
||||
@@ -70,14 +70,6 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
|
||||
}
|
||||
}, [task.id, solutionHistory]);
|
||||
|
||||
// useEffect(() => {
|
||||
// if (solutionHistory.length > 0 &&
|
||||
// (!displayedSolution ||
|
||||
// (solutionHistory[solutionHistory.length - 1].id !== displayedSolution.id))) {
|
||||
// setDisplayedSolution(solutionHistory[solutionHistory.length - 1]);
|
||||
// }
|
||||
// }, [solutionHistory, displayedSolution]);
|
||||
|
||||
useEffect(() => {
|
||||
const loadSolutionContent = async () => {
|
||||
if (!displayedSolution || !displayedSolution.content) return;
|
||||
@@ -122,9 +114,6 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
|
||||
<div className="md:w-[500px] flex flex-col gap-4">
|
||||
{displayedSolution ? (
|
||||
<>
|
||||
<div className="bg-gray-100 rounded-lg p-4 text-gray-600 font-hse-sans">
|
||||
Результат последней посылки:
|
||||
</div>
|
||||
<SolutionStatus key={displayedSolution.id} solution={displayedSolution} maxPoints={task.points}/>
|
||||
</>
|
||||
) : (
|
||||
|
||||
@@ -3,7 +3,11 @@ import { CompetitionGrid } from "./modules/CompetitionsGrid";
|
||||
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { getCompetitions } from "@/shared/api/competitions";
|
||||
import { NoCompetitions } from "./modules/NoCompetitions";
|
||||
import {
|
||||
NoActiveCompetitions,
|
||||
NoCompetitions,
|
||||
NoCompletedCompetitions,
|
||||
} from "./modules/NoCompetitions";
|
||||
import { TabsContent } from "@radix-ui/react-tabs";
|
||||
import { Loading } from "@/components/ui/loading";
|
||||
import { CompetitionState } from "@/shared/types/competition";
|
||||
@@ -54,8 +58,8 @@ const CompetitionsPage = () => {
|
||||
return (
|
||||
<div className="flex flex-col gap-6 sm:gap-8">
|
||||
{(activeCompetitionsQuery.data ?? []).length > 0 && (
|
||||
<Section>
|
||||
<Tabs value={activeTab} onValueChange={setActiveTab}>
|
||||
<Tabs value={activeTab} onValueChange={setActiveTab} asChild>
|
||||
<Section>
|
||||
<SectionHeader>
|
||||
<SectionTitle>Мои события</SectionTitle>
|
||||
|
||||
@@ -70,14 +74,22 @@ const CompetitionsPage = () => {
|
||||
</SectionHeader>
|
||||
|
||||
<TabsContent value={CompetitionTab.ONGOING} asChild>
|
||||
<CompetitionGrid competitions={startedCompetitions} />
|
||||
{startedCompetitions.length > 0 ? (
|
||||
<CompetitionGrid competitions={startedCompetitions} />
|
||||
) : (
|
||||
<NoActiveCompetitions />
|
||||
)}
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value={CompetitionTab.COMPLETED} asChild>
|
||||
<CompetitionGrid competitions={finishedCompetitions} />
|
||||
{finishedCompetitions.length > 0 ? (
|
||||
<CompetitionGrid competitions={finishedCompetitions} />
|
||||
) : (
|
||||
<NoCompletedCompetitions />
|
||||
)}
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</Section>
|
||||
</Section>
|
||||
</Tabs>
|
||||
)}
|
||||
|
||||
<Section>
|
||||
|
||||
@@ -13,3 +13,27 @@ export const NoCompetitions = () => {
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export const NoActiveCompetitions = () => {
|
||||
return (
|
||||
<div className="flex flex-col items-center gap-4">
|
||||
<Ban size={32} />
|
||||
<div className="flex flex-col items-center gap-2">
|
||||
<h2 className="text-2xl font-semibold">Нет активных событий</h2>
|
||||
<p className="text-muted-foreground text-lg">Начните новое</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export const NoCompletedCompetitions = () => {
|
||||
return (
|
||||
<div className="flex flex-col items-center gap-4">
|
||||
<Ban size={32} />
|
||||
<div className="flex flex-col items-center gap-2">
|
||||
<h2 className="text-2xl font-semibold">Завершенных событий нет</h2>
|
||||
<p className="text-muted-foreground text-lg">Завершите начатое</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { User } from "@/shared/types/user";
|
||||
import { UserInfo } from "./widgets/user-info";
|
||||
import { UserAchievements } from "./widgets/user-achievements";
|
||||
import { UserStats } from "./widgets/user-stats";
|
||||
|
||||
@@ -1,13 +1,22 @@
|
||||
import { buttonVariants } from "@/components/ui/button";
|
||||
import { DataRushReview } from "@/components/ui/icons/datarush-review";
|
||||
import { Reviewer } from "@/shared/types/review";
|
||||
import { Link } from "react-router";
|
||||
import { useUserStore } from "@/shared/stores/user";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
interface ReviewHeaderProps {
|
||||
reviewer: Reviewer;
|
||||
}
|
||||
|
||||
export const ReviewHeader = ({ reviewer }: ReviewHeaderProps) => {
|
||||
const clearUser = useUserStore((state) => state.clearUser);
|
||||
const navigate = useNavigate();
|
||||
|
||||
const handleLogout = () => {
|
||||
clearUser();
|
||||
navigate("/");
|
||||
};
|
||||
|
||||
return (
|
||||
<header className="flex h-[90px] items-center justify-between gap-4">
|
||||
<DataRushReview />
|
||||
@@ -15,13 +24,13 @@ export const ReviewHeader = ({ reviewer }: ReviewHeaderProps) => {
|
||||
<p className="text-right font-semibold">
|
||||
{reviewer.name} {reviewer.surname}
|
||||
</p>
|
||||
<Link
|
||||
to="/"
|
||||
<button
|
||||
onClick={handleLogout}
|
||||
className={buttonVariants({ size: "sm", variant: "secondary" })}
|
||||
>
|
||||
Выйти
|
||||
</Link>
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
};
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
import { userFetch } from ".";
|
||||
import { Competition } from "../types/competition";
|
||||
import { Competition, CompetitionResult } from "../types/competition";
|
||||
|
||||
export const getCompetitions = async (participating?: boolean) => {
|
||||
return await userFetch<Competition[]>("/competitions", {
|
||||
@@ -13,6 +13,10 @@ export const getCompetition = async (id: string) => {
|
||||
return await userFetch<Competition>(`/competitions/${id}`);
|
||||
};
|
||||
|
||||
export const getCompetitionResults = async (id: string) => {
|
||||
return await userFetch<CompetitionResult>(`/competitions/${id}/results`);
|
||||
}
|
||||
|
||||
export const startCompetition = async (competitionId: string) => {
|
||||
return await userFetch(`/competitions/${competitionId}/start`, {
|
||||
method: "POST",
|
||||
|
||||
@@ -24,3 +24,8 @@ export enum CompetitionType {
|
||||
export enum CompetitionParticipationType {
|
||||
SOLO = "solo",
|
||||
}
|
||||
|
||||
export interface CompetitionResult {
|
||||
task_name: string;
|
||||
result: number;
|
||||
}
|
||||
Reference in New Issue
Block a user