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

💖 add Logout functionality anddashboardd boilerplate #20

Merged
merged 9 commits into from
Dec 24, 2023
Prev Previous commit
Next Next commit
✨ feat: add dynamic header content
amir-kedis committed Dec 24, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 795ec1b4124e816febb4e14ff03ee8fafab237aa
20 changes: 16 additions & 4 deletions client/src/components/common/nav.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Link } from "react-router-dom";
import PropTypes from "prop-types";
import { useSelector } from "react-redux";
import { useEffect, useState } from "react";

// icons
import { UserCircleIcon } from "@heroicons/react/24/outline";
@@ -9,8 +11,18 @@ import logo from "../../assets/images/logo.svg";
// styles
import "../../assets/styles/components/Nav.scss";

export default function Nav(props) {
const { showIcons } = props;
export default function Nav() {
const [show, setShow] = useState(false);

const { userInfo } = useSelector((state) => state.auth);

useEffect(() => {
if (userInfo) {
setShow(true);
} else {
setShow(false);
}
}, [userInfo]);

return (
<nav className="Nav">
@@ -21,7 +33,7 @@ export default function Nav(props) {
<h2 className="logo-text">كشافة</h2>
</Link>
</div>
{showIcons && (
{show && (
<div className="Nav__icons">
{/* TODO: add route later */}
<Link to="/">
@@ -39,5 +51,5 @@ export default function Nav(props) {
}

Nav.propTypes = {
showIcons: PropTypes.bool.isRequired,
showIcons: PropTypes.bool,
};
2 changes: 1 addition & 1 deletion client/src/components/layout/PublicLayout.jsx
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import Footer from "../common/Footer";
export default function PublicLayout() {
return (
<div className="public_layout">
<Nav showIcons={false} />
<Nav />
<Outlet />
<Footer />
</div>