mirror of
https://gitlab.com/megazordpobeda/DataRush.git
synced 2026-05-22 23:17:09 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -1 +1,33 @@
|
|||||||
# DataRush
|
# 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):
|
class TaskStatusSchema(Schema):
|
||||||
task_name: str
|
task_name: str
|
||||||
result: int
|
result: int
|
||||||
|
max_points: int
|
||||||
|
|||||||
@@ -196,14 +196,21 @@ def get_competition_results(request, competition_id: UUID):
|
|||||||
for task in tasks:
|
for task in tasks:
|
||||||
submissions = CompetitionTaskSubmission.objects.filter(
|
submissions = CompetitionTaskSubmission.objects.filter(
|
||||||
user=request.auth, task=task
|
user=request.auth, task=task
|
||||||
).filter(status="checked").all()
|
).filter(status="checked").order_by("-earned_points").all()
|
||||||
if not submissions:
|
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:
|
else:
|
||||||
result = submissions[0].earned_points
|
result = submissions[0].earned_points
|
||||||
data.append(TaskStatusSchema(
|
data.append(TaskStatusSchema(
|
||||||
task_name=task.title,
|
task_name=task.title,
|
||||||
result=result
|
result=result,
|
||||||
|
max_points=task.points,
|
||||||
))
|
))
|
||||||
|
|
||||||
return status.OK, data
|
return status.OK, data
|
||||||
|
|||||||
@@ -21,12 +21,12 @@ def analyze_data_task(self, submission_id):
|
|||||||
{
|
{
|
||||||
"url": (
|
"url": (
|
||||||
f"{settings.MINIO_DEFAULT_CUSTOM_ENDPOINT_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,
|
"bind_path": attachment.bind_at,
|
||||||
}
|
}
|
||||||
for attachment in submission.task.attachments.filter(
|
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,
|
"code_url": code_url,
|
||||||
"answer_file_path": submission.task.answer_file_path,
|
"answer_file_path": submission.task.answer_file_path,
|
||||||
"expected_hash": hashlib.sha256(
|
"expected_hash": hashlib.sha256(
|
||||||
submission.task.correct_answer_file.read().encode()
|
submission.task.correct_answer_file.read()
|
||||||
).hexdigest(),
|
).hexdigest(),
|
||||||
},
|
},
|
||||||
timeout=30,
|
timeout=30,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
"name": "frontend",
|
"name": "frontend",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@monaco-editor/react": "^4.7.0",
|
"@monaco-editor/react": "^4.7.0",
|
||||||
|
"@radix-ui/react-accordion": "^1.2.3",
|
||||||
"@radix-ui/react-dialog": "^1.1.6",
|
"@radix-ui/react-dialog": "^1.1.6",
|
||||||
"@radix-ui/react-dropdown-menu": "^2.1.6",
|
"@radix-ui/react-dropdown-menu": "^2.1.6",
|
||||||
"@radix-ui/react-label": "^2.1.2",
|
"@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/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-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-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=="],
|
"@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": {
|
"dependencies": {
|
||||||
"@monaco-editor/react": "^4.7.0",
|
"@monaco-editor/react": "^4.7.0",
|
||||||
|
"@radix-ui/react-accordion": "^1.2.3",
|
||||||
"@radix-ui/react-dialog": "^1.1.6",
|
"@radix-ui/react-dialog": "^1.1.6",
|
||||||
"@radix-ui/react-dropdown-menu": "^2.1.6",
|
"@radix-ui/react-dropdown-menu": "^2.1.6",
|
||||||
"@radix-ui/react-label": "^2.1.2",
|
"@radix-ui/react-label": "^2.1.2",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { DataRush } from "@/components/ui/icons/datarush";
|
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 { Link, useNavigate } from "react-router";
|
||||||
import { useUserStore } from "@/shared/stores/user";
|
import { useUserStore } from "@/shared/stores/user";
|
||||||
import {
|
import {
|
||||||
@@ -14,6 +14,13 @@ import { removeToken } from "@/shared/token";
|
|||||||
export const Header = () => {
|
export const Header = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const user = useUserStore((state) => state.user);
|
const user = useUserStore((state) => state.user);
|
||||||
|
const clearUser = useUserStore((state) => state.clearUser);
|
||||||
|
|
||||||
|
const handleLogout = () => {
|
||||||
|
removeToken();
|
||||||
|
clearUser();
|
||||||
|
navigate("/login");
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<header className="bg-card sticky top-0 z-30 flex h-[72px] w-full items-center justify-center px-4 sm:px-6">
|
<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="/">
|
<Link to="/">
|
||||||
<DataRush />
|
<DataRush />
|
||||||
</Link>
|
</Link>
|
||||||
<DropdownMenu>
|
|
||||||
<DropdownMenuTrigger asChild>
|
<div className="flex items-center gap-4">
|
||||||
<button className="flex cursor-pointer items-center gap-1 rounded-md px-2 py-1 text-left transition-opacity hover:opacity-80">
|
<a
|
||||||
<span className="font-hse-sans text-lg font-semibold">
|
href="/docs/"
|
||||||
{user?.username}
|
className="text-sm font-medium text-gray-700 hover:text-gray-900 transition-colors flex items-center gap-1"
|
||||||
</span>
|
>
|
||||||
<ChevronDown size={20} />
|
<FileText className="h-4 w-4" />
|
||||||
</button>
|
</a>
|
||||||
</DropdownMenuTrigger>
|
|
||||||
<DropdownMenuContent>
|
<DropdownMenu>
|
||||||
<Link to="/profile">
|
<DropdownMenuTrigger asChild>
|
||||||
<DropdownMenuItem>Аккаунт</DropdownMenuItem>
|
<button className="flex cursor-pointer items-center gap-1 rounded-md px-2 py-1 text-left transition-opacity hover:opacity-80">
|
||||||
</Link>
|
<span className="font-hse-sans text-lg font-semibold">
|
||||||
<DropdownMenuSeparator />
|
{user?.username}
|
||||||
|
</span>
|
||||||
<DropdownMenuItem
|
<ChevronDown size={20} />
|
||||||
variant="destructive"
|
</button>
|
||||||
onClick={() => {
|
</DropdownMenuTrigger>
|
||||||
removeToken();
|
<DropdownMenuContent>
|
||||||
navigate("/login");
|
<Link to="/profile">
|
||||||
}}
|
<DropdownMenuItem>Аккаунт</DropdownMenuItem>
|
||||||
>
|
</Link>
|
||||||
Выйти
|
<DropdownMenuSeparator />
|
||||||
</DropdownMenuItem>
|
<DropdownMenuItem
|
||||||
</DropdownMenuContent>
|
variant="destructive"
|
||||||
</DropdownMenu>
|
onClick={handleLogout}
|
||||||
|
>
|
||||||
|
Выйти
|
||||||
|
</DropdownMenuItem>
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</DropdownMenu>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</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 { useState, useEffect } from "react";
|
||||||
import { useParams, Navigate } from "react-router-dom";
|
import { useParams, Navigate, useNavigate } from "react-router-dom";
|
||||||
import CompetitionHeader from "./components/CompetitionHeader";
|
import CompetitionHeader from "./components/CompetitionHeader";
|
||||||
import TaskContent from "./components/TaskContent";
|
import TaskContent from "./components/TaskContent";
|
||||||
import TaskSolution from "./modules/TaskSolution";
|
import TaskSolution from "./modules/TaskSolution";
|
||||||
@@ -13,8 +13,10 @@ const CompetitionSession = () => {
|
|||||||
const { id, taskId } = useParams<{ id: string; taskId?: string }>();
|
const { id, taskId } = useParams<{ id: string; taskId?: string }>();
|
||||||
const [answer, setAnswer] = useState("");
|
const [answer, setAnswer] = useState("");
|
||||||
const [selectedFile, setSelectedFile] = useState<File | null>(null);
|
const [selectedFile, setSelectedFile] = useState<File | null>(null);
|
||||||
|
const [isReloading, setIsReloading] = useState(false);
|
||||||
const competitionId = id || "";
|
const competitionId = id || "";
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const competitionQuery = useQuery({
|
const competitionQuery = useQuery({
|
||||||
queryKey: ["competition", competitionId],
|
queryKey: ["competition", competitionId],
|
||||||
@@ -45,8 +47,12 @@ const CompetitionSession = () => {
|
|||||||
queryKey: ['solutionHistory', competitionId, taskId]
|
queryKey: ['solutionHistory', competitionId, taskId]
|
||||||
});
|
});
|
||||||
|
|
||||||
setAnswer("");
|
setIsReloading(true);
|
||||||
setSelectedFile(null);
|
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.reload()
|
||||||
|
setIsReloading(false);
|
||||||
|
}, 2500);
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
console.error("Error submitting solution:", error);
|
console.error("Error submitting solution:", error);
|
||||||
@@ -89,6 +95,13 @@ const CompetitionSession = () => {
|
|||||||
|
|
||||||
const competitionTitle = competition?.title || "Загрузка соревнования...";
|
const competitionTitle = competition?.title || "Загрузка соревнования...";
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setAnswer("");
|
||||||
|
setSelectedFile(null);
|
||||||
|
}, [taskId]);
|
||||||
|
|
||||||
|
const isSubmitting = submitMutation.isPending || isReloading;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex min-h-screen flex-col">
|
<div className="flex min-h-screen flex-col">
|
||||||
<CompetitionHeader
|
<CompetitionHeader
|
||||||
@@ -123,7 +136,7 @@ const CompetitionSession = () => {
|
|||||||
selectedFile={selectedFile}
|
selectedFile={selectedFile}
|
||||||
setSelectedFile={setSelectedFile}
|
setSelectedFile={setSelectedFile}
|
||||||
onSubmit={handleSubmit}
|
onSubmit={handleSubmit}
|
||||||
isSubmitting={submitMutation.isPending}
|
isSubmitting={isSubmitting}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
|
|||||||
selectedFile,
|
selectedFile,
|
||||||
setSelectedFile,
|
setSelectedFile,
|
||||||
onSubmit,
|
onSubmit,
|
||||||
isSubmitting = false
|
isSubmitting = false,
|
||||||
}) => {
|
}) => {
|
||||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||||
const [isHistoryOpen, setIsHistoryOpen] = useState(false);
|
const [isHistoryOpen, setIsHistoryOpen] = useState(false);
|
||||||
@@ -70,14 +70,6 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
|
|||||||
}
|
}
|
||||||
}, [task.id, solutionHistory]);
|
}, [task.id, solutionHistory]);
|
||||||
|
|
||||||
// useEffect(() => {
|
|
||||||
// if (solutionHistory.length > 0 &&
|
|
||||||
// (!displayedSolution ||
|
|
||||||
// (solutionHistory[solutionHistory.length - 1].id !== displayedSolution.id))) {
|
|
||||||
// setDisplayedSolution(solutionHistory[solutionHistory.length - 1]);
|
|
||||||
// }
|
|
||||||
// }, [solutionHistory, displayedSolution]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadSolutionContent = async () => {
|
const loadSolutionContent = async () => {
|
||||||
if (!displayedSolution || !displayedSolution.content) return;
|
if (!displayedSolution || !displayedSolution.content) return;
|
||||||
@@ -122,9 +114,6 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
|
|||||||
<div className="md:w-[500px] flex flex-col gap-4">
|
<div className="md:w-[500px] flex flex-col gap-4">
|
||||||
{displayedSolution ? (
|
{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}/>
|
<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 { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { getCompetitions } from "@/shared/api/competitions";
|
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 { TabsContent } from "@radix-ui/react-tabs";
|
||||||
import { Loading } from "@/components/ui/loading";
|
import { Loading } from "@/components/ui/loading";
|
||||||
import { CompetitionState } from "@/shared/types/competition";
|
import { CompetitionState } from "@/shared/types/competition";
|
||||||
@@ -54,8 +58,8 @@ const CompetitionsPage = () => {
|
|||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-6 sm:gap-8">
|
<div className="flex flex-col gap-6 sm:gap-8">
|
||||||
{(activeCompetitionsQuery.data ?? []).length > 0 && (
|
{(activeCompetitionsQuery.data ?? []).length > 0 && (
|
||||||
<Section>
|
<Tabs value={activeTab} onValueChange={setActiveTab} asChild>
|
||||||
<Tabs value={activeTab} onValueChange={setActiveTab}>
|
<Section>
|
||||||
<SectionHeader>
|
<SectionHeader>
|
||||||
<SectionTitle>Мои события</SectionTitle>
|
<SectionTitle>Мои события</SectionTitle>
|
||||||
|
|
||||||
@@ -70,14 +74,22 @@ const CompetitionsPage = () => {
|
|||||||
</SectionHeader>
|
</SectionHeader>
|
||||||
|
|
||||||
<TabsContent value={CompetitionTab.ONGOING} asChild>
|
<TabsContent value={CompetitionTab.ONGOING} asChild>
|
||||||
<CompetitionGrid competitions={startedCompetitions} />
|
{startedCompetitions.length > 0 ? (
|
||||||
|
<CompetitionGrid competitions={startedCompetitions} />
|
||||||
|
) : (
|
||||||
|
<NoActiveCompetitions />
|
||||||
|
)}
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
|
|
||||||
<TabsContent value={CompetitionTab.COMPLETED} asChild>
|
<TabsContent value={CompetitionTab.COMPLETED} asChild>
|
||||||
<CompetitionGrid competitions={finishedCompetitions} />
|
{finishedCompetitions.length > 0 ? (
|
||||||
|
<CompetitionGrid competitions={finishedCompetitions} />
|
||||||
|
) : (
|
||||||
|
<NoCompletedCompetitions />
|
||||||
|
)}
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
</Tabs>
|
</Section>
|
||||||
</Section>
|
</Tabs>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Section>
|
<Section>
|
||||||
|
|||||||
@@ -13,3 +13,27 @@ export const NoCompetitions = () => {
|
|||||||
</div>
|
</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 { UserInfo } from "./widgets/user-info";
|
||||||
import { UserAchievements } from "./widgets/user-achievements";
|
import { UserAchievements } from "./widgets/user-achievements";
|
||||||
import { UserStats } from "./widgets/user-stats";
|
import { UserStats } from "./widgets/user-stats";
|
||||||
|
|||||||
@@ -1,13 +1,22 @@
|
|||||||
import { buttonVariants } from "@/components/ui/button";
|
import { buttonVariants } from "@/components/ui/button";
|
||||||
import { DataRushReview } from "@/components/ui/icons/datarush-review";
|
import { DataRushReview } from "@/components/ui/icons/datarush-review";
|
||||||
import { Reviewer } from "@/shared/types/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 {
|
interface ReviewHeaderProps {
|
||||||
reviewer: Reviewer;
|
reviewer: Reviewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ReviewHeader = ({ reviewer }: ReviewHeaderProps) => {
|
export const ReviewHeader = ({ reviewer }: ReviewHeaderProps) => {
|
||||||
|
const clearUser = useUserStore((state) => state.clearUser);
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
const handleLogout = () => {
|
||||||
|
clearUser();
|
||||||
|
navigate("/");
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<header className="flex h-[90px] items-center justify-between gap-4">
|
<header className="flex h-[90px] items-center justify-between gap-4">
|
||||||
<DataRushReview />
|
<DataRushReview />
|
||||||
@@ -15,13 +24,13 @@ export const ReviewHeader = ({ reviewer }: ReviewHeaderProps) => {
|
|||||||
<p className="text-right font-semibold">
|
<p className="text-right font-semibold">
|
||||||
{reviewer.name} {reviewer.surname}
|
{reviewer.name} {reviewer.surname}
|
||||||
</p>
|
</p>
|
||||||
<Link
|
<button
|
||||||
to="/"
|
onClick={handleLogout}
|
||||||
className={buttonVariants({ size: "sm", variant: "secondary" })}
|
className={buttonVariants({ size: "sm", variant: "secondary" })}
|
||||||
>
|
>
|
||||||
Выйти
|
Выйти
|
||||||
</Link>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { userFetch } from ".";
|
import { userFetch } from ".";
|
||||||
import { Competition } from "../types/competition";
|
import { Competition, CompetitionResult } from "../types/competition";
|
||||||
|
|
||||||
export const getCompetitions = async (participating?: boolean) => {
|
export const getCompetitions = async (participating?: boolean) => {
|
||||||
return await userFetch<Competition[]>("/competitions", {
|
return await userFetch<Competition[]>("/competitions", {
|
||||||
@@ -13,6 +13,10 @@ export const getCompetition = async (id: string) => {
|
|||||||
return await userFetch<Competition>(`/competitions/${id}`);
|
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) => {
|
export const startCompetition = async (competitionId: string) => {
|
||||||
return await userFetch(`/competitions/${competitionId}/start`, {
|
return await userFetch(`/competitions/${competitionId}/start`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
|||||||
@@ -24,3 +24,8 @@ export enum CompetitionType {
|
|||||||
export enum CompetitionParticipationType {
|
export enum CompetitionParticipationType {
|
||||||
SOLO = "solo",
|
SOLO = "solo",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface CompetitionResult {
|
||||||
|
task_name: string;
|
||||||
|
result: number;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user