From 9c3669ed04f703e0e44679fd7a2694ede93a17b0 Mon Sep 17 00:00:00 2001 From: Ivan Grivtsov Date: Thu, 20 Jun 2024 10:09:26 +0300 Subject: [PATCH] cleaning --- src/components/AppBar/AppBar.jsx | 5 - .../RestrictedRoute/RestrictedRoute.jsx | 1 - src/components/ThemeModal/ThemeModal.jsx | 96 +------------------ .../UserEditModal/UserEditModal.jsx | 5 +- src/pages/LoginPage/LoginPage.jsx | 18 ---- src/redux/boards/slice.js | 5 - 6 files changed, 2 insertions(+), 128 deletions(-) delete mode 100644 src/components/AppBar/AppBar.jsx diff --git a/src/components/AppBar/AppBar.jsx b/src/components/AppBar/AppBar.jsx deleted file mode 100644 index 656cfe4..0000000 --- a/src/components/AppBar/AppBar.jsx +++ /dev/null @@ -1,5 +0,0 @@ -// import css from "./AppBar.module.css"; - -export default function AppBar() { - return
; -} diff --git a/src/components/RestrictedRoute/RestrictedRoute.jsx b/src/components/RestrictedRoute/RestrictedRoute.jsx index 46fc8da..743a365 100644 --- a/src/components/RestrictedRoute/RestrictedRoute.jsx +++ b/src/components/RestrictedRoute/RestrictedRoute.jsx @@ -1,5 +1,4 @@ import { Navigate } from "react-router-dom"; -// import { useAuth } from "../hooks/useAuth"; import { selectIsLoggedIn } from "../../redux/auth/selectors"; import { useSelector } from "react-redux"; diff --git a/src/components/ThemeModal/ThemeModal.jsx b/src/components/ThemeModal/ThemeModal.jsx index d5f3699..856f590 100644 --- a/src/components/ThemeModal/ThemeModal.jsx +++ b/src/components/ThemeModal/ThemeModal.jsx @@ -1,83 +1,3 @@ -// import { useState, useEffect } from "react"; -// import axios from "axios"; -// import css from "../ThemeModal/ThemeModal.module.css"; - -// export default function ThemeModal({ closeMenuModal }) { -// const getInitialTheme = () => { -// const savedTheme = localStorage.getItem("theme"); -// return savedTheme ? savedTheme : "dark"; -// }; - -// const [theme, setTheme] = useState(getInitialTheme); - -// useEffect(() => { -// document.body.className = `${theme}-theme`; -// sendThemeToServer(theme); -// localStorage.setItem("theme", theme); -// }, [theme]); - -// const handleThemeChange = (selectedTheme) => { -// setTheme(selectedTheme); -// }; - -// // const sendThemeToServer = async (theme) => { -// // try { -// // const response = await axios.put('/users/theme', { theme }); - -// // if (response.status !== 200) { -// // throw new Error('Network response was not ok'); -// // } - -// // } catch (error) { -// // // console.error('Error updating theme:', error); -// // } -// // }; - -// const getBtnClassName = (selectedColor) => { -// return `${css.btn} ${css.transition} ${ -// theme === selectedColor ? css.btnActive : css.btnInactive -// }`; -// }; - -// const handleMenuClick = (ev) => { -// ev.stopPropagation(); -// }; - -// return ( -//
closeMenuModal()}> -//
-//
    -//
  • -// -//
  • -//
  • -// -//
  • -//
  • -// -//
  • -//
-//
-//
-// ); -// } - -// import { useEffect } from "react"; import { useDispatch, useSelector } from "react-redux"; import { sendThemeToServer } from "../../redux/theme/operation"; import { setTheme } from "../../redux/theme/slice"; @@ -87,23 +7,9 @@ export default function ThemeModal({ closeMenuModal }) { const dispatch = useDispatch(); const theme = useSelector((state) => state.theme.theme); - // useEffect(() => { - // const savedTheme = localStorage.getItem("theme"); - // if (savedTheme) { - // dispatch(setTheme(savedTheme)); - // } - // }, [dispatch]); - - // useEffect(() => { - // if (theme) { - // document.body.className = `${theme}-theme`; - // localStorage.setItem("theme", theme); // Збереження теми в локальному сховищі - // } - // }, [theme]); - const handleThemeChange = (selectedTheme) => { dispatch(setTheme(selectedTheme)); - dispatch(sendThemeToServer(selectedTheme)); // Відправка теми на сервер + dispatch(sendThemeToServer(selectedTheme)); }; const getBtnClassName = (selectedColor) => { diff --git a/src/components/UserEditModal/UserEditModal.jsx b/src/components/UserEditModal/UserEditModal.jsx index c115c54..747e3c4 100644 --- a/src/components/UserEditModal/UserEditModal.jsx +++ b/src/components/UserEditModal/UserEditModal.jsx @@ -23,7 +23,7 @@ export default function UserEditModal({ onClose }) { const user = useSelector(selectUser); const dispatch = useDispatch(); - // ссылка к скрытому тнпуту тип файл + const fileInputRef = useRef(null); const handleMenuClick = (ev) => { @@ -38,9 +38,7 @@ export default function UserEditModal({ onClose }) { const file = event.target.files[0]; if (file) { try { - //создаем новый объект FormData для отправки файла на сервер const formData = new FormData(); - //добавляем выбранный файл в объект FormData formData.append("avatar", file); const response = await axios.put( "https://project06back.onrender.com/users/avatar", @@ -53,7 +51,6 @@ export default function UserEditModal({ onClose }) { ); const url = response.data.avatarURL; if (url) { - // Установ новый URL аватара в стейт пользователя dispatch(updAvatarURL(url)); } } catch (error) { diff --git a/src/pages/LoginPage/LoginPage.jsx b/src/pages/LoginPage/LoginPage.jsx index d42c4da..9f05f6b 100644 --- a/src/pages/LoginPage/LoginPage.jsx +++ b/src/pages/LoginPage/LoginPage.jsx @@ -2,8 +2,6 @@ import svg from "../../img/icons.svg"; import { NavLink } from "react-router-dom"; import css from "./LoginPage.module.css"; import { useLocation } from "react-router-dom"; -// import Register from "../Register/Register"; -// import Login from "../Login/Login"; export default function LoginPage() { const location = useLocation(); @@ -24,18 +22,6 @@ export default function LoginPage() { /> - {/* - - man after the laptop - */}
@@ -57,10 +43,6 @@ export default function LoginPage() { )} - {/* - } /> - } /> - */}
); } diff --git a/src/redux/boards/slice.js b/src/redux/boards/slice.js index 39e57dc..ec2afd5 100644 --- a/src/redux/boards/slice.js +++ b/src/redux/boards/slice.js @@ -16,11 +16,6 @@ const boardSlice = createSlice({ loading: false, error: null, }, - // reducers: { - // setCurrentBoardId(state, action) { - // state.currentBoardId = action.payload; - // }, - // }, extraReducers: (builder) => builder .addCase(getBoards.pending, (state) => {