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 admin button to homepage and hamburger-menu #440

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions client/src/features/home/HamburgerNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function HamburgerNav({ logo, logotext }) {
const { isAuthenticated, logout } = useAuthContext();

let Links = [
{ name: "ADMIN", link: "/adminDashboard", type: "button" },
{ name: "HOME", link: "/", type: "button" },
{ name: "CALENDAR", link: "calendar", type: "button" },
];
Expand Down
14 changes: 13 additions & 1 deletion client/src/features/home/NavButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useRoutingContext } from "contexts/RoutingContext";
import { useAuthContext } from "contexts/AuthContext";
import { useNavigate } from "react-router-dom";

const NavButtons = ({ HomeIcon, LoginIcon, CalendarIcon }) => {
const NavButtons = ({ AdminIcon, HomeIcon, LoginIcon, CalendarIcon }) => {
const routing = useRoutingContext();
const navigate = useNavigate();
const { isAuthenticated, logout } = useAuthContext();
Expand All @@ -14,6 +14,18 @@ const NavButtons = ({ HomeIcon, LoginIcon, CalendarIcon }) => {

return (
<div className="flex flex-row gap-2">
{/* Admin Button */}
<button
onClick={() => navigate("adminDashboard")}
className="bg-white border-2 border-black rounded-2xl flex flex-col justify-center items-center p-1 w-24 h-24 lg:w-28 lg:h-28 xl:w-32 xl:h-32 focus:ring-4 focus:ring-black"
>
<div className="flex justify-center">
<AdminIcon className="text-mainBlue w-7 h-7 lg:w-10 lg:h-10" />
</div>
<div className="text-mainBlue font-black text-lg lg:text-xl xl:text-2xl">
<span>Admin</span>
</div>
</button>
{/* Home Button */}
<button
onClick={() => routing.setCurrentPage("landingPage")}
Expand Down
2 changes: 2 additions & 0 deletions client/src/features/home/NavContainer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import LogoContainer from "./LogoContainer";
import NavButtons from "./NavButtons";
import {
FaUserShield,
FaHome,
FaChevronCircleLeft,
FaChevronCircleRight,
Expand All @@ -15,6 +16,7 @@ const NavContainer = () => {
<nav className="hidden md:flex justify-between w-full">
<LogoContainer logo={"./logoicon.png"} logotext={"./logotext.png"} />
<NavButtons
AdminIcon={FaUserShield}
HomeIcon={FaHome}
LoginIcon={
isAuthenticated() ? FaChevronCircleLeft : FaChevronCircleRight
Expand Down
6 changes: 6 additions & 0 deletions cypress/e2e/landing.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
import tgt from "../support/tgt";

describe("Landing", () => {
it("Admin links to adminDashboard", () => {
cy.visit("/");
tgt.nav.button.admin().click();
cy.url().should("eq", Cypress.config().baseUrl + "/adminDashboard");
});

it("Home links to home", () => {
cy.visit("/");
tgt.nav.button.home().click();
Expand Down
2 changes: 2 additions & 0 deletions cypress/support/tgt.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export default {
},
landing: {
button: {
admin: () => cy.contains("button", "Admin"),
calendar: () => cy.contains("button", "Calendar"),
},
},
Expand All @@ -85,6 +86,7 @@ export default {
},
nav: {
button: {
admin: () => cy.contains("button", "Admin"),
home: () => cy.contains("button", "Home"),
calendar: () => cy.contains("button", "Calendar"),
},
Expand Down