-
Notifications
You must be signed in to change notification settings - Fork 0
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
upload branch for auth #73
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
DOMAIN= | ||
CLIENTID= |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
"use client"; | ||
import React from "react"; | ||
import { useAuth0 } from "@auth0/auth0-react"; | ||
|
||
// Component to render small window for auth status | ||
const AuthStatus: React.FC = () => { | ||
const { isAuthenticated, loginWithRedirect, logout } = useAuth0(); | ||
|
||
return ( | ||
<div className="absolute left-0 top-0 m-4 rounded bg-[#20222C] p-2 text-white shadow"> | ||
{isAuthenticated ? ( | ||
<div | ||
className="flex flex-col items-start p-2 text-left" | ||
style={{ padding: "10px 35px 10px 15px" }} | ||
> | ||
<span>Logged in</span> | ||
<button | ||
onClick={() => | ||
logout({ logoutParams: { returnTo: window.location.origin } }) | ||
} | ||
className="mt-1 text-sm text-red-300 underline transition duration-300 ease-in-out hover:text-red-100" | ||
> | ||
Log out | ||
</button> | ||
</div> | ||
) : ( | ||
<div | ||
className="flex flex-col items-start p-2" | ||
style={{ padding: "10px 15px" }} | ||
> | ||
<span className="text-white">Not logged in</span> | ||
<button | ||
onClick={() => loginWithRedirect()} | ||
className="mt-1 text-sm text-green-400 underline transition duration-300 ease-in-out hover:text-green-200" | ||
> | ||
Log in | ||
</button> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default AuthStatus; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"use client"; | ||
|
||
import React from "react"; | ||
import { Auth0Provider } from "@auth0/auth0-react"; | ||
import dotenv from "dotenv"; | ||
|
||
dotenv.config(); | ||
|
||
// Props for AuthContext | ||
interface AuthContextProps { | ||
children: React.ReactNode; | ||
} | ||
|
||
// AuthContext to wrap the application around | ||
const AuthContext: React.FC<AuthContextProps> = ({ children }) => { | ||
return ( | ||
<Auth0Provider | ||
domain={process.env.NEXT_PUBLIC_DOMAIN || ""} | ||
clientId={process.env.NEXT_PUBLIC_CLIENTID || ""} | ||
Comment on lines
+18
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do these variables come from your I'm mostly curious cause when I'm working on CI/CD right now so its important I know all the env variables that we use. |
||
authorizationParams={{ | ||
redirect_uri: window.location.origin, | ||
}} | ||
> | ||
{children} | ||
</Auth0Provider> | ||
); | ||
}; | ||
|
||
export default AuthContext; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,12 +12,17 @@ import Button from "./components/button"; | |
import { useState } from "react"; | ||
import { PC } from "../interfaces/pc"; | ||
import Activity from "./lounge/activity"; | ||
import AuthStatus from "./components/authStatus"; | ||
import { useAuth0 } from "@auth0/auth0-react"; | ||
|
||
export default function Page() { | ||
const [isAddingNewGamer, setIsAddingNewGamer] = React.useState(true); | ||
const [selectedPC, setSelectedPC] = useState<PC | null>(null); | ||
const [isOccupied, setIsOccupied] = useState<boolean>(false); | ||
|
||
// Auth contexts | ||
const { isAuthenticated } = useAuth0(); | ||
|
||
const handleToggleForm = () => { | ||
setIsAddingNewGamer(!isAddingNewGamer); | ||
}; | ||
|
@@ -29,45 +34,54 @@ export default function Page() { | |
|
||
return ( | ||
<div className="min-h-screen bg-[#0D0D0E] p-1"> | ||
<div className="grid h-full grid-cols-9 gap-1"> | ||
{/* left buffer */} | ||
<div className="col-span-1"></div> | ||
{/* Live Lounge Map - Left Section */} | ||
<div className="relative col-span-3 flex flex-col gap-1"> | ||
<div className="col-span-3 h-full rounded-md bg-[#20222C] p-4"> | ||
<h1 className="p-4 text-2xl font-bold text-white">Lounge Map</h1> | ||
<Map onPCClick={handlePCClick} /> | ||
</div> | ||
{selectedPC ? ( | ||
<PCInfo pc={selectedPC} isOccupied={isOccupied} /> | ||
) : ( | ||
<AuthStatus /> | ||
{isAuthenticated ? ( | ||
<div className="grid h-full grid-cols-9 gap-1"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Getting to the point where this file is a bit bloated... we should consider factoring out the lounge home page as a component and the not logged in page as its own page (in case we ever decide to add more features to that page) and move them to separate files. This probably should've been done earlier but I think the more minimal page.tsx is the better I'll create a follow-up issue for this |
||
{/* left buffer */} | ||
<div className="col-span-1"></div> | ||
{/* Live Lounge Map - Left Section */} | ||
<div className="relative col-span-3 flex flex-col gap-1"> | ||
<div className="col-span-3 h-full rounded-md bg-[#20222C] p-4"> | ||
<PlaceholderImage /> | ||
<h1 className="p-4 text-2xl font-bold text-white">Lounge Map</h1> | ||
<Map onPCClick={handlePCClick} /> | ||
</div> | ||
)} | ||
</div> | ||
{/* Right Column - Check In, Student Info, and Records */} | ||
<div className="relative col-span-4 flex flex-col gap-1"> | ||
<div className="absolute right-0 top-0 m-4"> | ||
<Button | ||
onClick={handleToggleForm} | ||
label={isAddingNewGamer ? "Add New" : "Check In"} | ||
className="flex items-center text-green-400 hover:text-green-300" | ||
/> | ||
</div> | ||
<div className="max-h-[300px] flex-grow rounded-md bg-[#20222C] p-4"> | ||
{isAddingNewGamer ? <CheckIn /> : <AddUser />} | ||
</div> | ||
<div className="rounded-md bg-[#20222C] p-4"> | ||
<StudentInfo /> | ||
{selectedPC ? ( | ||
<PCInfo pc={selectedPC} isOccupied={isOccupied} /> | ||
) : ( | ||
<div className="col-span-3 h-full rounded-md bg-[#20222C] p-4"> | ||
<PlaceholderImage /> | ||
</div> | ||
)} | ||
</div> | ||
<div className="h-full rounded-md bg-[#20222C] p-4"> | ||
<Activity /> | ||
{/* Right Column - Check In, Student Info, and Records */} | ||
<div className="relative col-span-4 flex flex-col gap-1"> | ||
<div className="absolute right-0 top-0 m-4"> | ||
<Button | ||
onClick={handleToggleForm} | ||
label={isAddingNewGamer ? "Add New" : "Check In"} | ||
className="flex items-center text-green-400 hover:text-green-300" | ||
/> | ||
</div> | ||
<div className="max-h-[300px] flex-grow rounded-md bg-[#20222C] p-4"> | ||
{isAddingNewGamer ? <CheckIn /> : <AddUser />} | ||
</div> | ||
<div className="rounded-md bg-[#20222C] p-4"> | ||
<StudentInfo /> | ||
</div> | ||
<div className="h-full rounded-md bg-[#20222C] p-4"> | ||
<Activity /> | ||
</div> | ||
</div> | ||
{/* right */} | ||
<div className="col-span-1"></div> | ||
</div> | ||
) : ( | ||
<div className="flex h-screen items-center justify-center"> | ||
<p className="text-center text-lg text-white"> | ||
You not logged in boi! | ||
</p> | ||
</div> | ||
{/* right */} | ||
<div className="col-span-1"></div> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we turn this into a functional component just to match the rest of the repo 😄 ?