diff --git a/src/App.js b/src/App.js index f92b53c..f24aed4 100644 --- a/src/App.js +++ b/src/App.js @@ -7,6 +7,7 @@ import Footer from './components/Footer'; import Register from './components/Register'; import Login from './components/Login'; import Profile from './components/Profile'; +import Messages from './components/Messages'; import styles from './App.module.css'; const App = () => { @@ -29,6 +30,7 @@ const App = () => { } /> : } /> : } /> + : } /> } /> {/* Главная страница */} diff --git a/src/components/Header.js b/src/components/Header.js index 088d338..f410b02 100644 --- a/src/components/Header.js +++ b/src/components/Header.js @@ -15,7 +15,10 @@ const Header = ({ isAuthenticated, onLogout }) => { {!isAuthenticated && Зарегистрироваться} {isAuthenticated && ( - + <> + Перейти к сообщениям + + )} ); diff --git a/src/components/Header.module.css b/src/components/Header.module.css index fcad573..7de70a1 100644 --- a/src/components/Header.module.css +++ b/src/components/Header.module.css @@ -30,6 +30,16 @@ text-decoration: underline; /* Подчеркивание при наведении */ } +.messagesLink { + color: #ff4500; /* Оранжевый цвет ссылки */ + text-decoration: none; + margin-right: 16px; +} + +.messagesLink:hover { + text-decoration: underline; /* Подчеркивание при наведении */ +} + .logoutButton { background-color: #ff4500; /* Оранжевая кнопка */ color: #ffffff; diff --git a/src/components/Messages.js b/src/components/Messages.js new file mode 100644 index 0000000..6027dc5 --- /dev/null +++ b/src/components/Messages.js @@ -0,0 +1,15 @@ +// src/components/Messages.js + +import React from 'react'; +import styles from './Messages.module.css'; + +const Messages = () => { + return ( +
+

Сообщения

+

Здесь будут ваши сообщения.

+
+ ); +}; + +export default Messages; \ No newline at end of file diff --git a/src/components/Messages.module.css b/src/components/Messages.module.css new file mode 100644 index 0000000..cbe7446 --- /dev/null +++ b/src/components/Messages.module.css @@ -0,0 +1,20 @@ +/* src/components/Messages.module.css */ + +.messagesContainer { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + background-color: #1a1a1a; /* Темный фон */ + color: #ffffff; /* Белый текст */ + padding: 16px; /* Добавляем отступы */ + min-height: 100vh; +} + +.messagesContainer h2 { + margin-bottom: 16px; +} + +.messagesContainer p { + font-size: 18px; +} \ No newline at end of file diff --git a/src/components/Profile.js b/src/components/Profile.js index 465bb7d..00fd550 100644 --- a/src/components/Profile.js +++ b/src/components/Profile.js @@ -1,13 +1,128 @@ // src/components/Profile.js -import React from 'react'; +import React, { useState, useEffect } from 'react'; import styles from './Profile.module.css'; const Profile = () => { + const [profilePicture, setProfilePicture] = useState(null); + const [posts, setPosts] = useState([]); + const [newPostText, setNewPostText] = useState(''); + const [newPostMusic, setNewPostMusic] = useState(null); + const [newPostImage, setNewPostImage] = useState(null); + + useEffect(() => { + // Загружаем посты из localStorage при монтировании компонента + const savedPosts = JSON.parse(localStorage.getItem('posts')) || []; + setPosts(savedPosts); + }, []); + + useEffect(() => { + // Сохраняем посты в localStorage при изменении + localStorage.setItem('posts', JSON.stringify(posts)); + }, [posts]); + + const handleProfilePictureChange = (e) => { + const file = e.target.files[0]; + if (file) { + const reader = new FileReader(); + reader.onloadend = () => { + setProfilePicture(reader.result); + }; + reader.readAsDataURL(file); + } + }; + + const handleNewPostMusicChange = (e) => { + const file = e.target.files[0]; + if (file) { + const reader = new FileReader(); + reader.onloadend = () => { + setNewPostMusic(reader.result); + }; + reader.readAsDataURL(file); + } + }; + + const handleNewPostImageChange = (e) => { + const file = e.target.files[0]; + if (file) { + const reader = new FileReader(); + reader.onloadend = () => { + setNewPostImage(reader.result); + }; + reader.readAsDataURL(file); + } + }; + + const addPost = () => { + if (!newPostText || !newPostMusic) { + alert('Пожалуйста, заполните текст и добавьте музыку.'); + return; + } + + const newPost = { + id: posts.length + 1, + musicUrl: newPostMusic, + text: newPostText, + image: newPostImage + }; + + setPosts([...posts, newPost]); + setNewPostText(''); + setNewPostMusic(null); + setNewPostImage(null); + }; + + const deletePost = (id) => { + const updatedPosts = posts.filter(post => post.id !== id); + setPosts(updatedPosts); + }; + return (
-

Профиль

-

Добро пожаловать в ваш профиль!

+
+
+ {profilePicture ? ( + Profile + ) : ( +
+ Фото +
+ )} + +
+
+

Имя Пользователя

+ +
+
+
+

Посты

+
+