Skip to content

Commit

Permalink
cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
AnWhiteM committed Jun 20, 2024
1 parent 1b82371 commit 9c3669e
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 128 deletions.
5 changes: 0 additions & 5 deletions src/components/AppBar/AppBar.jsx

This file was deleted.

1 change: 0 additions & 1 deletion src/components/RestrictedRoute/RestrictedRoute.jsx
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
96 changes: 1 addition & 95 deletions src/components/ThemeModal/ThemeModal.jsx
Original file line number Diff line number Diff line change
@@ -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 (
// <div className={css.backdrop} onClick={() => closeMenuModal()}>
// <div className={css.themeModal} onClick={handleMenuClick}>
// <ul className={css.list}>
// <li>
// <button
// className={getBtnClassName("light")}
// onClick={() => handleThemeChange("light")}
// >
// Light
// </button>
// </li>
// <li>
// <button
// className={getBtnClassName("dark")}
// onClick={() => handleThemeChange("dark")}
// >
// Dark
// </button>
// </li>
// <li>
// <button
// className={getBtnClassName("violet")}
// onClick={() => handleThemeChange("violet")}
// >
// Violet
// </button>
// </li>
// </ul>
// </div>
// </div>
// );
// }

// import { useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
import { sendThemeToServer } from "../../redux/theme/operation";
import { setTheme } from "../../redux/theme/slice";
Expand All @@ -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) => {
Expand Down
5 changes: 1 addition & 4 deletions src/components/UserEditModal/UserEditModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function UserEditModal({ onClose }) {
const user = useSelector(selectUser);
const dispatch = useDispatch();

// ссылка к скрытому тнпуту тип файл

const fileInputRef = useRef(null);

const handleMenuClick = (ev) => {
Expand All @@ -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",
Expand All @@ -53,7 +51,6 @@ export default function UserEditModal({ onClose }) {
);
const url = response.data.avatarURL;
if (url) {
// Установ новый URL аватара в стейт пользователя
dispatch(updAvatarURL(url));
}
} catch (error) {
Expand Down
18 changes: 0 additions & 18 deletions src/pages/LoginPage/LoginPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -24,18 +22,6 @@ export default function LoginPage() {


/>
{/* <picture className={css.img}>
<source
srcSet={`
https://res.cloudinary.com/dqwyuuuzd/image/upload/v1718235452/p6ex38slxwvcjwcwnbxj.png 124w,
https://res.cloudinary.com/dqwyuuuzd/image/upload/v1718235452/ixq02fsx2ekcu2qu7nb0.png 248w`}
sizes="(min-width: 1440px) 162px, (min-width: 1280px) 162px, (min-width: 768px) 162px, (min-width: 320px) 124px"
/>
<img
src="https://res.cloudinary.com/dqwyuuuzd/image/upload/v1718235452/ixq02fsx2ekcu2qu7nb0.png"
alt="man after the laptop"
/>
</picture> */}

<div className={css.title}>
<div className={css.logoBox}>
Expand All @@ -57,10 +43,6 @@ export default function LoginPage() {
</NavLink>
</>
)}
{/* <Routes>
<Route path="/auth/register" element={<Register />} />
<Route path="/auth/login" element={<Login />} />
</Routes> */}
</div>
);
}
5 changes: 0 additions & 5 deletions src/redux/boards/slice.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 9c3669e

Please sign in to comment.