From f7f61127040642d57905fe3923e5237ceb2adef4 Mon Sep 17 00:00:00 2001
From: IrynaSlavinska <133566139+IrynaSlavinska@users.noreply.github.com>
Date: Sun, 7 Jan 2024 18:47:56 +0200
Subject: [PATCH] cleared
---
src/components/App.jsx | 7 +--
src/components/Filter/Filter.jsx | 54 +-------------------
src/components/Filter/Filter.styled.jsx | 14 -----
src/pages/NotAuthPage/NotAuthPage.jsx | 20 --------
src/pages/NotAuthPage/NotAuthPage.styled.jsx | 22 --------
src/redux/auth/authSlice.js | 5 +-
src/redux/group/groupFilters.js | 7 ---
src/redux/group/groupSlice.js | 17 ------
src/redux/reducer.js | 2 -
src/routes/PrivateRoute.js | 5 +-
10 files changed, 7 insertions(+), 146 deletions(-)
delete mode 100644 src/pages/NotAuthPage/NotAuthPage.jsx
delete mode 100644 src/pages/NotAuthPage/NotAuthPage.styled.jsx
delete mode 100644 src/redux/group/groupFilters.js
delete mode 100644 src/redux/group/groupSlice.js
diff --git a/src/components/App.jsx b/src/components/App.jsx
index 2af6b8a..a072937 100644
--- a/src/components/App.jsx
+++ b/src/components/App.jsx
@@ -13,7 +13,6 @@ const LoginPage = lazy(() => import('pages/LoginPage/LoginPage'));
const ContactsPage = lazy(() => import('pages/ContactsPage/ContactsPage'));
const RegisterPage = lazy(() => import('pages/RegisterPage/RegisterPage'));
const NotFound = lazy(() => import('pages/NotFound/NotFound'));
-const NotAuthPage = lazy(() => import('pages/NotAuthPage/NotAuthPage'));
const App = () => {
const dispatch = useDispatch();
@@ -37,14 +36,10 @@ const App = () => {
path="login"
element={} />}
/>
- } />
}
- />
+ } />
}
/>
diff --git a/src/components/Filter/Filter.jsx b/src/components/Filter/Filter.jsx
index 4d33357..0041b59 100644
--- a/src/components/Filter/Filter.jsx
+++ b/src/components/Filter/Filter.jsx
@@ -2,26 +2,12 @@ import { useDispatch, useSelector } from 'react-redux';
import { selectFilterValue } from '../../redux/selectors';
import { setSearchFilterAction } from '../../redux/filter/filterSlice';
-import {
- FilterContainer,
- Label,
- Input,
- SortContainer,
- SortButton,
-} from './Filter.styled';
-
-import { groupFilters } from '../../redux/group/groupFilters';
-import { selectGroupFilters } from '../../redux/selectors';
-import { setGroupFilters } from '../../redux/group/groupSlice';
+import { FilterContainer, Label, Input } from './Filter.styled';
export const Filter = () => {
const dispatch = useDispatch();
const { filter } = useSelector(selectFilterValue);
- const group = useSelector(selectGroupFilters);
-
- const handleGroupChange = group => dispatch(setGroupFilters(group));
-
const filterChange = e => {
dispatch(setSearchFilterAction(e.target.value));
};
@@ -38,44 +24,6 @@ export const Filter = () => {
onChange={filterChange}
/>
-
-
- handleGroupChange(groupFilters.all)}
- >
- All
-
- handleGroupChange(groupFilters.family)}
- >
- Family
-
- handleGroupChange(groupFilters.friends)}
- >
- Friends
-
- handleGroupChange(groupFilters.work)}
- >
- Work
-
- handleGroupChange(groupFilters.others)}
- >
- Oters
-
-
);
};
diff --git a/src/components/Filter/Filter.styled.jsx b/src/components/Filter/Filter.styled.jsx
index 666cc7e..d17a4d6 100644
--- a/src/components/Filter/Filter.styled.jsx
+++ b/src/components/Filter/Filter.styled.jsx
@@ -13,7 +13,6 @@ export const Label = styled.label`
display: flex;
align-items: center;
gap: 20px;
- margin-bottom: 10px;
`;
export const Input = styled.input`
@@ -30,16 +29,3 @@ export const Input = styled.input`
border-color: #e9af3d;
}
`;
-
-export const SortContainer = styled.div`
- display: flex;
- justify-content: space-between;
- gap: 6px;
-`;
-
-export const SortButton = styled.button`
- padding: 8px 12px;
- font-size: 16px;
- color: #000000;
- background-color: #e9af3d;
-`;
diff --git a/src/pages/NotAuthPage/NotAuthPage.jsx b/src/pages/NotAuthPage/NotAuthPage.jsx
deleted file mode 100644
index e16599a..0000000
--- a/src/pages/NotAuthPage/NotAuthPage.jsx
+++ /dev/null
@@ -1,20 +0,0 @@
-import {
- NotAuthContainer,
- Title,
- Text,
- StyledLink,
-} from './NotAuthPage.styled';
-
-const NotAuthPage = () => {
- return (
-
- Unauthorized user
- You have profile
- Log in
- Register now
- Register
-
- );
-};
-
-export default NotAuthPage;
diff --git a/src/pages/NotAuthPage/NotAuthPage.styled.jsx b/src/pages/NotAuthPage/NotAuthPage.styled.jsx
deleted file mode 100644
index 5d76820..0000000
--- a/src/pages/NotAuthPage/NotAuthPage.styled.jsx
+++ /dev/null
@@ -1,22 +0,0 @@
-import styled from '@emotion/styled';
-import { NavLink } from 'react-router-dom';
-
-export const NotAuthContainer = styled.div`
- text-align: center;
- background-color: #1dacd6;
- padding: 20px;
- border-radius: 4px;
-`;
-
-export const Title = styled.h1`
- font-size: 60px;
-`;
-
-export const Text = styled.p`
- font-size: 18px;
-`;
-
-export const StyledLink = styled(NavLink)`
- color: #000000;
- font-size: 44px;
-`;
diff --git a/src/redux/auth/authSlice.js b/src/redux/auth/authSlice.js
index c0f9ffd..72dd8dc 100644
--- a/src/redux/auth/authSlice.js
+++ b/src/redux/auth/authSlice.js
@@ -5,7 +5,7 @@ const initialState = {
user: { name: null, email: null },
token: null,
isLoggedIn: false,
- isRefreshing: false,
+ isRefreshing: true,
};
const authSlice = createSlice({
@@ -28,9 +28,6 @@ const authSlice = createSlice({
state.token = null;
state.isLoggedIn = false;
})
- .addCase(operations.refreshUser.pending, state => {
- state.isRefreshing = true;
- })
.addCase(operations.refreshUser.fulfilled, (state, action) => {
state.user = action.payload;
state.isLoggedIn = true;
diff --git a/src/redux/group/groupFilters.js b/src/redux/group/groupFilters.js
deleted file mode 100644
index 71cbe62..0000000
--- a/src/redux/group/groupFilters.js
+++ /dev/null
@@ -1,7 +0,0 @@
-export const groupFilters = Object.freeze({
- all: 'all',
- family: 'family',
- friends: 'friends',
- work: 'work',
- others: 'others',
-});
diff --git a/src/redux/group/groupSlice.js b/src/redux/group/groupSlice.js
deleted file mode 100644
index e1dd5a2..0000000
--- a/src/redux/group/groupSlice.js
+++ /dev/null
@@ -1,17 +0,0 @@
-import { createSlice } from '@reduxjs/toolkit';
-import { groupFilters } from './groupFilters';
-
-const groupSlice = createSlice({
- name: 'group',
- initialState: {
- group: groupFilters.all,
- },
- reducers: {
- setGroupFilters(state, action) {
- state.group = action.payload;
- },
- },
-});
-
-export const { setGroupFilters } = groupSlice.actions;
-export const sortReducer = groupSlice.reducer;
diff --git a/src/redux/reducer.js b/src/redux/reducer.js
index a67b962..a6ca202 100644
--- a/src/redux/reducer.js
+++ b/src/redux/reducer.js
@@ -4,7 +4,6 @@ import storage from 'redux-persist/lib/storage';
import { contactsReducer } from './contacts/contactsSlice';
import { filterReducer } from './filter/filterSlice';
import { authReducer } from './auth/authSlice';
-import { sortReducer } from './group/groupSlice.js';
const authPersistConfig = {
key: 'auth',
@@ -15,6 +14,5 @@ const authPersistConfig = {
export const reducer = {
contacts: contactsReducer,
filter: filterReducer,
- sort: sortReducer,
auth: persistReducer(authPersistConfig, authReducer),
};
diff --git a/src/routes/PrivateRoute.js b/src/routes/PrivateRoute.js
index 143e2ec..7d865b2 100644
--- a/src/routes/PrivateRoute.js
+++ b/src/routes/PrivateRoute.js
@@ -1,7 +1,10 @@
import { Navigate } from 'react-router-dom';
import { useAuth } from '../hooks/useAuth';
-export const PrivateRoute = ({ component: Component, redirectTo = '/' }) => {
+export const PrivateRoute = ({
+ component: Component,
+ redirectTo = '/contacts',
+}) => {
const { isLoggedIn, isRefreshing } = useAuth();
const shouldRedirect = !isLoggedIn && !isRefreshing;