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; +}