From 88e1e4f0f3e65ae1f8cf72030268506824c17c27 Mon Sep 17 00:00:00 2001 From: Dozzy7528 Date: Sun, 15 Feb 2026 20:02:33 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20Mainpage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Добавлено отображение задач на Main странице сайта --- src/Mainpage.js | 46 ++++++++++++++++++++++++++++++++------ src/css/Mainpage.css | 53 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 7 deletions(-) create mode 100644 src/css/Mainpage.css diff --git a/src/Mainpage.js b/src/Mainpage.js index a771ced..01fbe34 100644 --- a/src/Mainpage.js +++ b/src/Mainpage.js @@ -1,19 +1,51 @@ -import { useState, useEffect } from 'react'; +import {useState, useEffect} from 'react'; import axios from 'axios'; import Header from './Header'; +import './css/Mainpage.css'; const Mainpage = () => { - const [user, setUser] = useState(null); + const [tasks, setTasks] = useState([]); const [error, setError] = useState(''); - + const [count, setCount] = useState('0'); + + useEffect(() => { + const checkSession = async () => { + try { + const response = await axios.get('/api/users/my_tasks'); + setTasks(response.data.tasks || []); + setCount(response.data.count || 0); + } catch (err) { + setError('Ошибка загрузки задачи'); + } + }; + + checkSession(); + }, []); + return ( <>
-
- +
+ { + error &&
{error}
+ } +
+
+

Задачи ({count})

+ {tasks.length > 0 ? ( +
    + {tasks.map((task, index) => ( +
  • {task.title || task.name || `Задача ${index + 1}`}
  • + ))} +
+ ) : ( +

Нет задач

+ )} +
+
- ); -} + ); +}; export default Mainpage; \ No newline at end of file diff --git a/src/css/Mainpage.css b/src/css/Mainpage.css new file mode 100644 index 0000000..af7977c --- /dev/null +++ b/src/css/Mainpage.css @@ -0,0 +1,53 @@ +.content-wrapper{ + transition: all .4s ease; +} + +.main-layout { + background-color: #1f2430; + border-radius: 8px; + box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); + padding: 20px; + margin: 10px auto; + max-width: 1200px; +} + +.left-content { + flex: 1; + text-align: left; /* Выравнивание текста слева */ +} + +.left-content h1, +.left-content p, +.left-content li { + text-align: left; + color: #CAD1D8; +} + +.tasks-box { + flex: 0 0 300px; /* Фиксированная ширина бокса справа */ + background-color: #33404d; + border-radius: 8px; + padding: 20px; + border: 1px solid #999; + height: fit-content; +} + +.tasks-box h3 { + margin-top: 0; + color: #CAD1D8; + text-align: center; +} + +.tasks-box ul { + list-style-type: none; + padding: 0; +} + +.tasks-box li { + background-color: #1f2430; + margin-bottom: 10px; + padding: 10px; + border-radius: 4px; + color: #CAD1D8; + text-align: left; +}