Skip to content

Commit

Permalink
Merge pull request #17 from Saulul/elliot-homepage
Browse files Browse the repository at this point in the history
Added toast on signout.
  • Loading branch information
Elliot-Potts authored Mar 31, 2024
2 parents 6957a65 + 52c90ca commit 2ebd373
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/components/EventsPage.jsx

This file was deleted.

26 changes: 26 additions & 0 deletions src/components/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ import { Link, useNavigate } from "react-router-dom";
import FavoriteIcon from "@mui/icons-material/Favorite";
import ConfirmationNumberIcon from "@mui/icons-material/ConfirmationNumber";
import AccountCircleIcon from "@mui/icons-material/AccountCircle";
import { Snackbar } from "@mui/material";
import Alert from "@mui/material/Alert";

const API_URL = "https://eventhive.creeknet.xyz/api";

const Header = () => {
const navigate = useNavigate();
const [anchorEl, setAnchorEl] = useState(null);
const [userFirstName, setUserFirstName] = useState("");
const [openSnackbar, setOpenSnackbar] = useState(false);
const open = Boolean(anchorEl);

const isLoggedIn = () => {
Expand All @@ -30,6 +33,7 @@ const Header = () => {
localStorage.removeItem("jwt");
setUserFirstName("");
navigate("/");
setOpenSnackbar(true); // Show the Snackbar
};

const handleClick = (event) => {
Expand All @@ -40,6 +44,14 @@ const Header = () => {
setAnchorEl(null);
};

const handleCloseSnackbar = (event, reason) => {
if (reason === "clickaway") {
return;
}

setOpenSnackbar(false);
};

useEffect(() => {
const fetchUserData = async () => {
const jwt = localStorage.getItem("jwt");
Expand Down Expand Up @@ -144,6 +156,20 @@ const Header = () => {
</>
)}
</div>
<Snackbar
open={openSnackbar}
autoHideDuration={6000}
onClose={handleCloseSnackbar}
anchorOrigin={{ vertical: "bottom", horizontal: "right" }}
>
<Alert
onClose={handleCloseSnackbar}
severity="success"
sx={{ width: "100%" }}
>
You have been logged out successfully
</Alert>
</Snackbar>
</div>
);
};
Expand Down

0 comments on commit 2ebd373

Please sign in to comment.