upload mission
This commit is contained in:
69
src/views/home/missions/MissionItem.tsx
Normal file
69
src/views/home/missions/MissionItem.tsx
Normal file
@@ -0,0 +1,69 @@
|
||||
import { cn } from "../../../lib/cn";
|
||||
import { IconError, IconSuccess } from "../../../assets/icons/missions";
|
||||
|
||||
export interface MissionItemProps {
|
||||
id: number;
|
||||
authorId: number;
|
||||
name: string;
|
||||
difficulty: "Easy" | "Medium" | "Hard";
|
||||
tags: string[];
|
||||
timeLimit: number;
|
||||
memoryLimit: number;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
type: "first" | "second";
|
||||
status: "empty" | "success" | "error";
|
||||
}
|
||||
|
||||
export function formatMilliseconds(ms: number): string {
|
||||
const rounded = Math.round(ms) / 1000;
|
||||
const formatted = rounded.toString().replace(/\.?0+$/, '');
|
||||
return `${formatted} c`;
|
||||
}
|
||||
|
||||
export function formatBytesToMB(bytes: number): string {
|
||||
const megabytes = Math.floor(bytes / (1024 * 1024));
|
||||
return `${megabytes} МБ`;
|
||||
}
|
||||
|
||||
const MissionItem: React.FC<MissionItemProps> = ({
|
||||
id, name, difficulty, timeLimit, memoryLimit, type, status
|
||||
}) => {
|
||||
console.log(id);
|
||||
return (
|
||||
<div className={cn("h-[44px] w-full relative rounded-[10px] text-liquid-white",
|
||||
type == "first" ? "bg-liquid-lighter" : "bg-liquid-background",
|
||||
"grid grid-cols-[80px,1fr,1fr,60px,24px] grid-flow-col gap-[20px] px-[20px] box-border items-center",
|
||||
status == "error" && "border-l-[11px] border-l-liquid-red pl-[9px]",
|
||||
status == "success" && "border-l-[11px] border-l-liquid-green pl-[9px]",
|
||||
)}>
|
||||
<div className="text-[18px] font-bold">
|
||||
#{id}
|
||||
</div>
|
||||
<div className="text-[18px] font-bold">
|
||||
{name}
|
||||
</div>
|
||||
<div className="text-[12px] text-right">
|
||||
стандартный ввод/вывод {formatMilliseconds(timeLimit)}, {formatBytesToMB(memoryLimit)}
|
||||
</div>
|
||||
<div className={cn(
|
||||
"text-center text-[18px]",
|
||||
difficulty == "Hard" && "text-liquid-red",
|
||||
difficulty == "Medium" && "text-liquid-orange",
|
||||
difficulty == "Easy" && "text-liquid-green",
|
||||
)}>
|
||||
{difficulty}
|
||||
</div>
|
||||
<div className="h-[24px] w-[24px]">
|
||||
{
|
||||
status == "error" && <img src={IconError}/>
|
||||
}
|
||||
{
|
||||
status == "success" && <img src={IconSuccess}/>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default MissionItem;
|
||||
507
src/views/home/missions/Missions.tsx
Normal file
507
src/views/home/missions/Missions.tsx
Normal file
@@ -0,0 +1,507 @@
|
||||
import MissionItem from "./MissionItem";
|
||||
import { SecondaryButton } from "../../../components/button/SecondaryButton";
|
||||
import { useAppDispatch } from "../../../redux/hooks";
|
||||
import { useEffect } from "react";
|
||||
import { setMenuActivePage } from "../../../redux/slices/store";
|
||||
|
||||
|
||||
export interface Mission {
|
||||
id: number;
|
||||
authorId: number;
|
||||
name: string;
|
||||
difficulty: "Easy" | "Medium" | "Hard";
|
||||
tags: string[];
|
||||
timeLimit: number;
|
||||
memoryLimit: number;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
|
||||
const Missions = () => {
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
const missions: Mission[] = [
|
||||
{
|
||||
"id": 1,
|
||||
"authorId": 1,
|
||||
"name": "Todo List App",
|
||||
"difficulty": "Easy",
|
||||
"tags": ["react", "state", "list"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:13.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:13.000Z"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"authorId": 1,
|
||||
"name": "Search Filter Component",
|
||||
"difficulty": "Medium",
|
||||
"tags": ["filter", "props", "hooks"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:14.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:14.000Z"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"authorId": 1,
|
||||
"name": "User Card List",
|
||||
"difficulty": "Easy",
|
||||
"tags": ["components", "props", "array"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:15.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:15.000Z"
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"authorId": 1,
|
||||
"name": "Theme Switcher",
|
||||
"difficulty": "Medium",
|
||||
"tags": ["context", "theme", "hooks"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:16.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:16.000Z"
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"authorId": 1,
|
||||
"name": "Debounced Input",
|
||||
"difficulty": "Hard",
|
||||
"tags": ["debounce", "hooks", "events"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:17.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:17.000Z"
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"authorId": 1,
|
||||
"name": "Pagination Component",
|
||||
"difficulty": "Medium",
|
||||
"tags": ["pagination", "array", "state"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:18.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:18.000Z"
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"authorId": 1,
|
||||
"name": "Modal Window",
|
||||
"difficulty": "Easy",
|
||||
"tags": ["ui", "portal", "events"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:19.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:19.000Z"
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"authorId": 1,
|
||||
"name": "Form Validation",
|
||||
"difficulty": "Hard",
|
||||
"tags": ["form", "validation", "hooks"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:20.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:20.000Z"
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"authorId": 1,
|
||||
"name": "Countdown Timer",
|
||||
"difficulty": "Medium",
|
||||
"tags": ["timer", "hooks", "state"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:21.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:21.000Z"
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"authorId": 1,
|
||||
"name": "Drag And Drop List",
|
||||
"difficulty": "Hard",
|
||||
"tags": ["dragdrop", "array", "events"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:22.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:22.000Z"
|
||||
},
|
||||
{
|
||||
"id": 11,
|
||||
"authorId": 1,
|
||||
"name": "Custom Hook Use Fetch",
|
||||
"difficulty": "Medium",
|
||||
"tags": ["hook", "fetch", "async"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:23.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:23.000Z"
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"authorId": 1,
|
||||
"name": "Infinite Scroll",
|
||||
"difficulty": "Hard",
|
||||
"tags": ["scroll", "pagination", "api"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:24.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:24.000Z"
|
||||
},
|
||||
{
|
||||
"id": 13,
|
||||
"authorId": 1,
|
||||
"name": "Responsive Navbar",
|
||||
"difficulty": "Easy",
|
||||
"tags": ["css", "layout", "responsive"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:25.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:25.000Z"
|
||||
},
|
||||
{
|
||||
"id": 14,
|
||||
"authorId": 1,
|
||||
"name": "Accordion Component",
|
||||
"difficulty": "Easy",
|
||||
"tags": ["ui", "state", "events"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:26.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:26.000Z"
|
||||
},
|
||||
{
|
||||
"id": 15,
|
||||
"authorId": 1,
|
||||
"name": "File Upload Preview",
|
||||
"difficulty": "Hard",
|
||||
"tags": ["file", "events", "preview"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:27.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:27.000Z"
|
||||
},
|
||||
{
|
||||
"id": 16,
|
||||
"authorId": 1,
|
||||
"name": "Dark Mode Toggle",
|
||||
"difficulty": "Easy",
|
||||
"tags": ["theme", "context", "localStorage"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:28.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:28.000Z"
|
||||
},
|
||||
{
|
||||
"id": 17,
|
||||
"authorId": 1,
|
||||
"name": "Realtime Clock",
|
||||
"difficulty": "Easy",
|
||||
"tags": ["date", "state", "interval"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:29.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:29.000Z"
|
||||
},
|
||||
{
|
||||
"id": 18,
|
||||
"authorId": 1,
|
||||
"name": "Chart With Recharts",
|
||||
"difficulty": "Medium",
|
||||
"tags": ["chart", "data", "props"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:30.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:30.000Z"
|
||||
},
|
||||
{
|
||||
"id": 19,
|
||||
"authorId": 1,
|
||||
"name": "Router Navigation",
|
||||
"difficulty": "Medium",
|
||||
"tags": ["router", "navigation", "hooks"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:31.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:31.000Z"
|
||||
},
|
||||
{
|
||||
"id": 20,
|
||||
"authorId": 1,
|
||||
"name": "Data Table Sortable",
|
||||
"difficulty": "Hard",
|
||||
"tags": ["table", "sort", "filter"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:32.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:32.000Z"
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"authorId": 1,
|
||||
"name": "Todo List App",
|
||||
"difficulty": "Easy",
|
||||
"tags": ["react", "state", "list"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:13.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:13.000Z"
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"authorId": 1,
|
||||
"name": "Search Filter Component",
|
||||
"difficulty": "Medium",
|
||||
"tags": ["filter", "props", "hooks"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:14.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:14.000Z"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"authorId": 1,
|
||||
"name": "User Card List",
|
||||
"difficulty": "Easy",
|
||||
"tags": ["components", "props", "array"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:15.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:15.000Z"
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"authorId": 1,
|
||||
"name": "Theme Switcher",
|
||||
"difficulty": "Medium",
|
||||
"tags": ["context", "theme", "hooks"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:16.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:16.000Z"
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"authorId": 1,
|
||||
"name": "Debounced Input",
|
||||
"difficulty": "Hard",
|
||||
"tags": ["debounce", "hooks", "events"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:17.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:17.000Z"
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"authorId": 1,
|
||||
"name": "Pagination Component",
|
||||
"difficulty": "Medium",
|
||||
"tags": ["pagination", "array", "state"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:18.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:18.000Z"
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"authorId": 1,
|
||||
"name": "Modal Window",
|
||||
"difficulty": "Easy",
|
||||
"tags": ["ui", "portal", "events"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:19.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:19.000Z"
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"authorId": 1,
|
||||
"name": "Form Validation",
|
||||
"difficulty": "Hard",
|
||||
"tags": ["form", "validation", "hooks"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:20.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:20.000Z"
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"authorId": 1,
|
||||
"name": "Countdown Timer",
|
||||
"difficulty": "Medium",
|
||||
"tags": ["timer", "hooks", "state"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:21.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:21.000Z"
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"authorId": 1,
|
||||
"name": "Drag And Drop List",
|
||||
"difficulty": "Hard",
|
||||
"tags": ["dragdrop", "array", "events"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:22.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:22.000Z"
|
||||
},
|
||||
{
|
||||
"id": 11,
|
||||
"authorId": 1,
|
||||
"name": "Custom Hook Use Fetch",
|
||||
"difficulty": "Medium",
|
||||
"tags": ["hook", "fetch", "async"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:23.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:23.000Z"
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"authorId": 1,
|
||||
"name": "Infinite Scroll",
|
||||
"difficulty": "Hard",
|
||||
"tags": ["scroll", "pagination", "api"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:24.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:24.000Z"
|
||||
},
|
||||
{
|
||||
"id": 13,
|
||||
"authorId": 1,
|
||||
"name": "Responsive Navbar",
|
||||
"difficulty": "Easy",
|
||||
"tags": ["css", "layout", "responsive"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:25.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:25.000Z"
|
||||
},
|
||||
{
|
||||
"id": 14,
|
||||
"authorId": 1,
|
||||
"name": "Accordion Component",
|
||||
"difficulty": "Easy",
|
||||
"tags": ["ui", "state", "events"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:26.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:26.000Z"
|
||||
},
|
||||
{
|
||||
"id": 15,
|
||||
"authorId": 1,
|
||||
"name": "File Upload Preview",
|
||||
"difficulty": "Hard",
|
||||
"tags": ["file", "events", "preview"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:27.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:27.000Z"
|
||||
},
|
||||
{
|
||||
"id": 16,
|
||||
"authorId": 1,
|
||||
"name": "Dark Mode Toggle",
|
||||
"difficulty": "Easy",
|
||||
"tags": ["theme", "context", "localStorage"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:28.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:28.000Z"
|
||||
},
|
||||
{
|
||||
"id": 17,
|
||||
"authorId": 1,
|
||||
"name": "Realtime Clock",
|
||||
"difficulty": "Easy",
|
||||
"tags": ["date", "state", "interval"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:29.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:29.000Z"
|
||||
},
|
||||
{
|
||||
"id": 18,
|
||||
"authorId": 1,
|
||||
"name": "Chart With Recharts",
|
||||
"difficulty": "Medium",
|
||||
"tags": ["chart", "data", "props"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:30.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:30.000Z"
|
||||
},
|
||||
{
|
||||
"id": 19,
|
||||
"authorId": 1,
|
||||
"name": "Router Navigation",
|
||||
"difficulty": "Medium",
|
||||
"tags": ["router", "navigation", "hooks"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:31.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:31.000Z"
|
||||
},
|
||||
{
|
||||
"id": 20,
|
||||
"authorId": 1,
|
||||
"name": "Data Table Sortable",
|
||||
"difficulty": "Hard",
|
||||
"tags": ["table", "sort", "filter"],
|
||||
"timeLimit": 1000,
|
||||
"memoryLimit": 268435456,
|
||||
"createdAt": "2025-10-28T13:23:32.000Z",
|
||||
"updatedAt": "2025-10-28T13:23:32.000Z"
|
||||
}
|
||||
];
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(setMenuActivePage("missions"))
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className=" h-full w-full box-border p-[20px] pt-[20px]">
|
||||
<div className="h-full box-border">
|
||||
|
||||
<div className="relative flex items-center mb-[20px]">
|
||||
<div className="h-[50px] text-[40px] font-bold text-liquid-white flex items-center">
|
||||
Задачи
|
||||
</div>
|
||||
<SecondaryButton
|
||||
onClick={() => {}}
|
||||
text="Создать задачу"
|
||||
className="absolute right-0"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="bg-liquid-lighter h-[50px] mb-[20px]">
|
||||
|
||||
</div>
|
||||
|
||||
<div>
|
||||
|
||||
{missions.map((v, i) => (
|
||||
<MissionItem key={i} {...v} type={i % 2 == 0 ? "first" : "second"} status={i == 0 || i == 3 || i == 7 ? "success" : (i == 2 || i == 4 || i == 9 ? "error" : "empty")}/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
|
||||
<div>
|
||||
pages
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Missions;
|
||||
Reference in New Issue
Block a user