Skip to content

Commit

Permalink
Created sidebar, links hidden when user is signed out (#149)
Browse files Browse the repository at this point in the history
* Created sidebar, links hidden when user is signed out
>
>
Co-authored by: Hannah McGowan <[email protected]

* added links to student and para tables, settings page under construction

* redirect to students page upon login

* updated table title

* ran prettier on navbar styles

* added type to Navbar props

* resolved all issues except 401 error, fixed linting

* removed React.FC, updated prop type

* Pascal Casing

* updated component exports

* Fixed export casing
  • Loading branch information
KotovSyndrome authored Jul 27, 2023
1 parent 86d086f commit fd38806
Show file tree
Hide file tree
Showing 10 changed files with 224 additions and 61 deletions.
93 changes: 51 additions & 42 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@fontsource/roboto": "^5.0.3",
"@mui/icons-material": "^5.11.16",
"@mui/material": "^5.13.6",
"@mui/icons-material": "^5.14.1",
"@mui/material": "^5.14.2",
"@next/font": "13.1.6",
"@tanstack/react-query": "^4.24.10",
"@trpc/client": "^10.16.0",
Expand Down
72 changes: 72 additions & 0 deletions src/components/NavBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import React from "react";
import styles from "../styles/Navbar.module.css";
import Link from "next/link";
import Image from "next/image";
import {
PeopleOutline,
CoPresent,
Settings,
Logout,
} from "@mui/icons-material";
import { signOut } from "next-auth/react";
import { trpc } from "@/client/lib/trpc";

interface NavBarProps {
children: React.ReactNode;
}

const NavBar = ({ children }: NavBarProps) => {
const { data: me } = trpc.user.getMe.useQuery();

return (
<React.Fragment>
<div className={styles.container}>
<div className={styles.sidebar}>
<Link href="/">
<Image
src="/img/compass-logo.svg"
alt="logo"
className={styles.logo}
width={64}
height={64}
priority
/>
</Link>
<br />

{me && (
<div className={styles.linkContainer}>
<Link href="/students" className={styles.link}>
<PeopleOutline className={styles.icon} />
<p className={styles.linkTitle}>Students</p>
</Link>
<br />
<Link href="/staff" className={styles.link}>
<CoPresent className={styles.icon} />
<p className={styles.linkTitle}>Staff</p>
</Link>
<br />
<Link href="/settings" className={styles.link}>
<Settings className={styles.icon} />
<p className={styles.linkTitle}>Settings</p>
</Link>
<br />
<Link href="" className={styles.link}>
<Logout className={styles.icon} />
<p
className={styles.linkTitle}
onClick={() => signOut({ callbackUrl: "/" })}
>
Logout
</p>
</Link>
</div>
)}
</div>
<div className={styles.body}>{children}</div>
</div>
</React.Fragment>
);
};

export default NavBar;
5 changes: 4 additions & 1 deletion src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { QueryCache } from "@tanstack/react-query";
import toast, { Toaster } from "react-hot-toast";
import Head from "next/head";
import superjson from "superjson";
import NavBar from "@/components/NavBar";

interface CustomPageProps {
session: Session;
Expand Down Expand Up @@ -79,7 +80,9 @@ export default function App({
<trpc.Provider client={trpcClient} queryClient={queryClient}>
<QueryClientProvider client={queryClient}>
<SessionProvider session={pageProps.session}>
<Component {...pageProps} showErrorToast={toast.error} />
<NavBar>
<Component {...pageProps} showErrorToast={toast.error} />
</NavBar>
<Toaster position="bottom-right" />
</SessionProvider>
</QueryClientProvider>
Expand Down
8 changes: 6 additions & 2 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const Home: NextPage = () => {
Welcome {me?.first_name} {me?.last_name}
</h1>
{JSON.stringify(me)}
<Link href="/cmDashboard">
<Link href="/students">
<p>CM Dashboard</p>
</Link>
<button className={styles.signOut} onClick={() => signOut()}>
Expand All @@ -46,7 +46,11 @@ const Home: NextPage = () => {
<div>Log in with your Google account to continue</div>
<button
className={`${styles.signIn} ${styles.bold}`}
onClick={() => signIn("google")}
onClick={() =>
signIn("google", {
callbackUrl: "/students",
})
}
>
Sign in with Google
</button>
Expand Down
11 changes: 11 additions & 0 deletions src/pages/settings.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from "react";

const Settings = () => {
return (
<div>
<p>🚧 Under Construction! 🚧</p>
</div>
);
};

export default Settings;
File renamed without changes.
26 changes: 26 additions & 0 deletions src/pages/staff/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from "react";
import styles from "../../styles/Dashboard.module.css";
import MyParas from "@/components/case_manager/MyParas";

function Staff() {
return (
<div className={styles.cmContainer}>
<nav style={{ padding: "2%" }}></nav>
<main>
<div style={{ padding: "20px", textAlign: "center" }}>
<div
style={{
display: "flex",
alignContent: "center",
justifyContent: "center",
}}
>
<MyParas />
</div>
</div>
</main>
</div>
);
}

export default Staff;
19 changes: 5 additions & 14 deletions src/pages/cmDashboard.tsx → src/pages/students/index.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
import React from "react";
import MyStudents from "../components/case_manager/MyStudents";
import styles from "../styles/Dashboard.module.css";
import Image from "next/image";
import MyStudents from "../../components/case_manager/MyStudents";
import styles from "../../styles/Dashboard.module.css";

function cmDashboard() {
function Students() {
return (
<div className={styles.cmContainer}>
<nav style={{ padding: "2%" }}>
<Image
src="/img/compass-logo.svg"
alt="logo"
width={50}
height={50}
priority
/>
</nav>
<nav style={{ padding: "2%" }}></nav>
<main>
<div style={{ padding: "20px", textAlign: "center" }}>
<div
Expand All @@ -32,4 +23,4 @@ function cmDashboard() {
);
}

export default cmDashboard;
export default Students;
Loading

0 comments on commit fd38806

Please sign in to comment.