Skip to content

Commit

Permalink
React toast for notification added
Browse files Browse the repository at this point in the history
  • Loading branch information
skbhagat0502 committed Oct 15, 2023
1 parent b6555d8 commit 1d19c2b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"react-select": "^5.7.0",
"react-social-login-buttons": "^3.4.0",
"react-syntax-highlighter": "^15.4.3",
"react-toastify": "^9.1.3",
"redux": "^4.0.5",
"redux-auth-wrapper": "^3.0.0",
"redux-firestore": "^0.15.0",
Expand Down
28 changes: 19 additions & 9 deletions src/components/Tutorials/subComps/EditControls.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { useDispatch } from "react-redux";
import RemoveStepModal from "./RemoveStepModal";
import ColorPickerModal from "./ColorPickerModal";
import { Box, Stack } from "@mui/system";
import { toast} from 'react-toastify';

const EditControls = ({
isPublished,
Expand Down Expand Up @@ -104,15 +105,24 @@ const EditControls = ({
);
};

const handlePublishTutorial = async () => {
setPublishLoad(true);
await publishUnpublishTutorial(owner, tutorial_id, isPublished)(
firebase,
firestore,
dispatch
);
setPublishLoad(false);
};
const handlePublishTutorial = async () => {
setPublishLoad(true);
try {
await publishUnpublishTutorial(owner, tutorial_id, isPublished)(
firebase,
firestore,
dispatch
);
if(!isPublished)
toast.success('🚀 Tutorial published successfully!')
else
toast.success('Tutorial unpublished!')
} catch (error) {
toast.error('An error occurred!');
} finally {
setPublishLoad(false);
}
};

return (
<>
Expand Down
4 changes: 4 additions & 0 deletions src/components/ui-helpers/ToastContainer.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { ToastContainer} from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';

export default ToastContainer;
2 changes: 2 additions & 0 deletions src/routes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import MainNavbar from "./components/NavBar/new/MainNavbar";
import UserDashboard from "./components/UserDashboard";
import TutorialPage from "./components/TutorialPage";
import Notification from "./components/Notification";
import ToastContainer from "./components/ui-helpers/ToastContainer";

const AuthIsLoaded = ({ children }) => {
const profile = useSelector(({ firebase: { profile } }) => profile);
Expand Down Expand Up @@ -88,6 +89,7 @@ const Routes = () => {
<Router>
<AuthIsLoaded>
<CodeLabzAppBar />
<ToastContainer/>
{/* <Navbar /> */}
<Switch>
<Route exact path={"/"} component={HomePage} />
Expand Down

0 comments on commit 1d19c2b

Please sign in to comment.