Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codelabz Button Functionality for unauthenticated users fixed. #902

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/components/Topbar/NewCodelabz/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { Grid, IconButton, Paper, Typography } from "@mui/material";
import { makeStyles } from "@mui/styles";
import React from "react";
import AddBoxRoundedIcon from "@mui/icons-material/AddBoxRounded";
import { useSelector } from "react-redux";
import { useHistory } from "react-router-dom";
import { toast} from 'react-toastify';

const useStyles = makeStyles(theme => ({
root: {
Expand Down Expand Up @@ -31,6 +34,16 @@ const useStyles = makeStyles(theme => ({

function NewCodelabz({ setVisibleModal }) {
const classes = useStyles();
const profileData = useSelector(({ firebase: { profile } }) => profile);
const history=useHistory()
const SetModalVisibility = () => {
if (profileData.isEmpty) {
toast.info('Login first to create a tutorial', {position: "top-center"});
history.push("/login")
} else {
setVisibleModal(true)
}
}

return (
<React.Fragment>
Expand All @@ -47,7 +60,7 @@ function NewCodelabz({ setVisibleModal }) {
justifyContent="center"
alignContent="center"
data-testId="NewCodelabzBtn"
onClick={() => setVisibleModal(true)}
onClick={SetModalVisibility}
>
<AddBoxRoundedIcon color="primary" fontSize="large" />
</Grid>
Expand Down
Loading