Skip to content

Commit

Permalink
toast notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
manikandanraji committed Jun 22, 2020
1 parent 3e29856 commit ea1ee53
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const App = () => {
return (
<StyledThemeProvider theme={theme}>
<GlobalStyle />
<ToastContainer autoClose={1000} closeButton={false}/>
<ToastContainer autoClose={2000} closeButton={false} />
{user ? <Routing /> : <Auth />}
</StyledThemeProvider>
);
Expand Down
2 changes: 2 additions & 0 deletions src/components/DeletePost.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useContext } from "react";
import { toast } from 'react-toastify';
import { useHistory } from 'react-router-dom';
import { FeedContext } from "../context/FeedContext";
import { deletePost } from "../services/api";
Expand All @@ -15,6 +16,7 @@ const DeletePost = ({ postId, closeModal, goToHome }) => {
}

setFeed(feed.filter(post => post._id !== postId));
toast.success('Your post has been deleted successfully');
deletePost({ postId });
};

Expand Down
1 change: 1 addition & 0 deletions src/components/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const Login = ({ signup }) => {

localStorage.setItem("user", JSON.stringify(userResponse.data.data));
setUser(userResponse.data.data);
toast.success('Login successful')

email.setValue("");
password.setValue("");
Expand Down
3 changes: 2 additions & 1 deletion src/components/NewPost.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const NewPost = () => {

const handleSubmitPost = () => {
if (!caption.value) {
return toast.error("You should leave the caption field empty");
return toast.error("Please write something");
}

setShowModal(false);
Expand Down Expand Up @@ -106,6 +106,7 @@ const NewPost = () => {
post.isMine = true;
setFeed([post, ...feed]);
window.scrollTo(0, 0);
toast.success('Your post has been submitted successfully');
});
};

Expand Down
6 changes: 6 additions & 0 deletions src/components/NoFeedSuggestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ const Wrapper = styled.div`
button {
font-size: 0.9rem;
position: relative;
top: -5px;
}
@media screen and (max-width: 660px) {
Expand All @@ -42,6 +44,10 @@ const Wrapper = styled.div`
@media screen and (max-width: 400px) {
width: 340px;
button {
font-size: 0.8rem;
}
}
`;

Expand Down
2 changes: 2 additions & 0 deletions src/components/ProfileHeader.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useContext, useEffect, useState } from "react";
import { toast } from 'react-toastify';
import styled from "styled-components";
import { useHistory } from "react-router-dom";
import Follow from "./Follow";
Expand Down Expand Up @@ -219,6 +220,7 @@ const ProfileHeader = ({ profile }) => {
const handleLogout = () => {
setUser(null);
localStorage.removeItem("user");
toast.success('You are logged out');
};

useEffect(() => setFollowers(profile?.followersCount), [profile]);
Expand Down
3 changes: 2 additions & 1 deletion src/components/Search.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from "react";
import { toast } from 'react-toastify';
import styled from "styled-components";
import useInput from "../hooks/useInput";

Expand All @@ -16,8 +17,8 @@ const Search = () => {

const handleSearch = e => {
if(e.keyCode === 13) {
console.log(searchterm.value)
searchterm.setValue('')
return toast.success("Sorry, the search feature isn't finished yet")
}
}

Expand Down
6 changes: 0 additions & 6 deletions src/styles/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ const Button = styled.button`
border: 1px solid #dbdbdb;
font-weight: 500;
`}
${props =>
props.sm &&
css`
padding: 0.4rem 0.6rem;
`}
`;

export default Button;

0 comments on commit ea1ee53

Please sign in to comment.