generated from sofiialives/goit-react-hw-07-phonebook
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7e2c7cb
commit 0b621c9
Showing
20 changed files
with
279 additions
and
140 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { useState } from 'react'; | ||
import { useDispatch } from 'react-redux'; | ||
import { deleteContact } from 'redux/contacts/operations'; | ||
import { LoadingDelete } from '../ContactsList/LoadingDelete'; | ||
import css from './ContactItem.module.css'; | ||
|
||
export const ContactItem = ({ contact }) => { | ||
const [isDelete, setIsDelete] = useState(false); | ||
const dispatch = useDispatch(); | ||
|
||
const handleDelete = id => { | ||
setIsDelete(true); | ||
dispatch(deleteContact(id)) | ||
.unwrap() | ||
.then(() => setIsDelete(false)); | ||
}; | ||
|
||
return ( | ||
<li> | ||
<span> | ||
{contact.name}: {contact.number || contact.phone} | ||
</span> | ||
<button | ||
onClick={() => handleDelete(contact.id)} | ||
className={css.buttonFilter} | ||
> | ||
{isDelete ? <LoadingDelete /> : '\u2716'} | ||
</button> | ||
</li> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.buttonFilter { | ||
border-radius: 50%; | ||
font-size: 18px; | ||
color: rgb(240, 27, 27); | ||
background-color: rgb(250, 181, 181); | ||
border: 1px red solid; | ||
width: 40px; | ||
height: 40px; | ||
box-shadow: 3px 3px 6px rgba(0, 0, 0, 0.2); | ||
cursor: pointer; | ||
transition: background-color 200ms ease-in-out, transform 200ms, | ||
box-shadow 200ms; | ||
margin-left: 10px; | ||
} | ||
.buttonFilter:hover, | ||
.buttonFilter:focus { | ||
transform: scale(1.1); | ||
background-color: rgb(246, 150, 150); | ||
box-shadow: 0 0 20px rgba(0, 0, 0, 0.3); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { RotatingLines } from "react-loader-spinner"; | ||
|
||
export const LoadingDelete = () => { | ||
return ( | ||
<RotatingLines | ||
strokeColor="red" | ||
strokeWidth="5" | ||
animationDuration="0.75" | ||
width="20px" | ||
visible={true} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import { Audio } from 'react-loader-spinner'; | ||
import { ColorRing } from 'react-loader-spinner'; | ||
|
||
export const Loading = () => { | ||
return ( | ||
<Audio | ||
height="100" | ||
width="100" | ||
color="#4fa94d" | ||
ariaLabel="audio-loading" | ||
wrapperStyle={{}} | ||
wrapperClass="wrapper-class" | ||
visible={true} | ||
/> | ||
<ColorRing | ||
visible={true} | ||
height="80" | ||
width="80" | ||
ariaLabel="blocks-loading" | ||
wrapperStyle={{}} | ||
wrapperClass="blocks-wrapper" | ||
colors={['#e15b64', '#f47e60', '#f8b26a', '#abbd81', '#849b87']} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Navigate } from 'react-router-dom'; | ||
import { useSelector } from 'react-redux'; | ||
import { selectIsLoggedIn, selectIsRefreshing } from 'redux/auth/selectors'; | ||
|
||
export const PrivateRoute = ({ component: Component, redirectTo = '/' }) => { | ||
const isLoggedIn = useSelector(selectIsLoggedIn) | ||
const isRefreshing = useSelector(selectIsRefreshing) | ||
const shouldRedirect = !isLoggedIn && !isRefreshing; | ||
|
||
return shouldRedirect ? <Navigate to={redirectTo} /> : Component; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Navigate } from 'react-router-dom'; | ||
import { useSelector } from 'react-redux'; | ||
import { selectIsLoggedIn } from 'redux/auth/selectors'; | ||
|
||
export const RestrictedRoute = ({ component: Component, redirectTo = '/' }) => { | ||
const isLoggedIn = useSelector(selectIsLoggedIn); | ||
|
||
return isLoggedIn ? <Navigate to={redirectTo} /> : Component; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Loading } from 'components/Loading'; | ||
import css from './Error.module.css'; | ||
import { useSelector } from 'react-redux'; | ||
import { selectError, selectLoading } from 'redux/contacts/selectors'; | ||
|
||
const Error = () => { | ||
const isLoading = useSelector(selectLoading); | ||
const error = useSelector(selectError); | ||
return ( | ||
<div className={css.div}> | ||
{isLoading && <Loading />} | ||
{error && 'something went wrong'} | ||
<h1 className={css.title}>THE PAGE NOT FOUND 404</h1> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Error; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.div { | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
} | ||
.title { | ||
font-size: 40px; | ||
color: red; | ||
} |
Oops, something went wrong.