diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx index f2a5f82..448e0d1 100644 --- a/src/pages/Home.tsx +++ b/src/pages/Home.tsx @@ -7,6 +7,7 @@ import { useAppDispatch, useAppSelector } from "../redux/hooks"; import { useEffect } from "react"; import { fetchWhoAmI } from "../redux/slices/auth"; import Problems from "../views/home/problems/Problems"; +import Articles from "../views/home/articles/Articles"; const Home = () => { const name = useAppSelector((state) => state.auth.username); @@ -19,7 +20,7 @@ const Home = () => { return ( -
+
@@ -29,10 +30,15 @@ const Home = () => { } /> } /> } /> + } /> -
+ { + +
} /> + + } ); }; diff --git a/src/views/home/articles/ArticleItem.tsx b/src/views/home/articles/ArticleItem.tsx new file mode 100644 index 0000000..838daf2 --- /dev/null +++ b/src/views/home/articles/ArticleItem.tsx @@ -0,0 +1,50 @@ +import { Logo } from "../../../assets/logos"; +import { Account, Clipboard, Cup, Home, Openbook, Users } from "../../../assets/icons/menu"; +// import MenuItem from "./MenuItem"; +import { cn } from "../../../lib/cn"; +import { IconError, IconSuccess } from "../../../assets/icons/problems"; + +export interface ArticleItemProps { + id: number; + authorId: number; + name: string; + tags: string[]; + createdAt: string; + updatedAt: string; +} + +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 ArticleItem: React.FC = ({ + id, authorId, name, tags, createdAt, updatedAt +}) => { + console.log(id); + return ( +
+
+ #{id} +
+
+ {name} +
+
+ {/* стандартный ввод/вывод {formatMilliseconds(timeLimit)}, {formatBytesToMB(memoryLimit)} */} +
+ +
+ ); +}; + +export default ArticleItem; diff --git a/src/views/home/articles/Articles.tsx b/src/views/home/articles/Articles.tsx new file mode 100644 index 0000000..618e678 --- /dev/null +++ b/src/views/home/articles/Articles.tsx @@ -0,0 +1,107 @@ +import { Logo } from "../../../assets/logos"; +import { Account, Clipboard, Cup, Home, Openbook, Users } from "../../../assets/icons/menu"; +// import MenuItem from "./MenuItem"; +import { useAppSelector } from "../../../redux/hooks"; +// import ProblemItem from "./ProblemItem"; +import { SecondaryButton } from "../../../components/button/SecondaryButton"; + + +export interface Problem { + id: number; + authorId: number; + name: string; + difficulty: "Easy" | "Medium" | "Hard"; + tags: string[]; + timeLimit: number; + memoryLimit: number; + createdAt: string; + updatedAt: string; +} + + +const Articles = () => { + + const problems: Problem[] = [ + { + "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" + } + ]; + + + return ( +
+
+ +
+
+ База статей +
+ {}} + text="Создать статью" + className="absolute right-0" + /> +
+ +
+ +
+ +
+ + {/* {problems.map((v, i) => ( + + ))} */} +
+ + +
+ pages +
+
+
+ ); +}; + +export default Articles; diff --git a/src/views/home/menu/Menu.tsx b/src/views/home/menu/Menu.tsx index 5616e2a..f2ccfea 100644 --- a/src/views/home/menu/Menu.tsx +++ b/src/views/home/menu/Menu.tsx @@ -7,7 +7,7 @@ const Menu = () => { const menuItems = [ {text: "Главная", href: "/home", icon: Home, page: "home" }, {text: "Задачи", href: "/home/problems", icon: Clipboard, page: "clipboard" }, - {text: "Статьи", href: "/home", icon: Openbook, page: "openbool" }, + {text: "Статьи", href: "/home/articles", icon: Openbook, page: "openbool" }, {text: "Группы", href: "/home", icon: Users, page: "users" }, {text: "Контесты", href: "/home", icon: Cup, page: "cup" }, {text: "Аккаунт", href: "/home/account", icon: Account, page: "account" }, diff --git a/src/views/home/problems/Problems.tsx b/src/views/home/problems/Problems.tsx index 1523049..9507a26 100644 --- a/src/views/home/problems/Problems.tsx +++ b/src/views/home/problems/Problems.tsx @@ -466,8 +466,8 @@ const Problems = () => { return ( -
-
+
+