Skip to content

Commit

Permalink
removed auth completely
Browse files Browse the repository at this point in the history
  • Loading branch information
Alucard2169 committed Aug 5, 2023
1 parent e1f34ee commit 11b7c0d
Show file tree
Hide file tree
Showing 20 changed files with 35 additions and 843 deletions.
223 changes: 0 additions & 223 deletions components/Auth.jsx

This file was deleted.

8 changes: 3 additions & 5 deletions components/Layout.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { useState } from "react";
import Auth from "./Auth";
import Navbar from "./Navbar";

const Layout = ({ children }) => {
const [authFormState,setAuthFormState] = useState(false)

return (
<div>
<Navbar data={{ authFormState, setAuthFormState }} />
<Auth data={{ authFormState, setAuthFormState }} />
<Navbar/>

{children}
</div>
);
Expand Down
53 changes: 6 additions & 47 deletions components/Navbar.jsx
Original file line number Diff line number Diff line change
@@ -1,70 +1,29 @@
import { userContext } from "@/context/userContext";
import Image from "next/image";
import Link from "next/link";
import { useRouter } from "next/router";
import { useContext, useState } from "react";
import { useState } from "react";
import profilePic from "../assets/pfp.webp";
import userPfp from "../assets/userPFP.webp";
import navbarStyle from "../styles/Navbar.module.css";
import SearchBar from "./SearchBar";
import UserMenu from "./UserMenu";

const Navbar = ({ data }) => {
const Navbar = ( ) => {

const { authFormState, setAuthFormState } = data;

const router = useRouter();
const { user, setUser } = useContext(userContext);

const [displayState, setDisplayState] = useState(false);

const handleSignUpBtn = () => {
setAuthFormState(true)
};

const handleUserMenu = () => {
setDisplayState(displayState ? false : true);
};

const handleLogoutBtn = async () => {
try {
const response = await fetch(`${window.location.origin}/api/logout`);
const data = await response.json();
if (response.ok) {
setUser(null);
router.push("/");
}
} catch (error) {
console.log(error);
}
};


return (
<nav className={navbarStyle.navbar}>
<Link href="/" className={navbarStyle.pfpContainer}>
<Image src={profilePic} alt="profile Pic" />
</Link>
<SearchBar />
{user === null ? (
<button className={navbarStyle.authButton} onClick={handleSignUpBtn}>
SignUp
</button>
) : (
<div className={navbarStyle.right}>
<div className={user.images}>
<div className={navbarStyle.userPfp} onClick={handleUserMenu}>
<Image src={userPfp} alt="user profile pic" />
</div>
</div>
<button className={navbarStyle.authButton} onClick={handleLogoutBtn}>
Logout
</button>

<UserMenu
state={displayState}
stateHandle={setDisplayState}
logoutFnc={handleLogoutBtn}
/>
</div>
)}

</nav>
);
};
Expand Down
26 changes: 0 additions & 26 deletions components/UserMenu.jsx

This file was deleted.

33 changes: 0 additions & 33 deletions context/userContext.jsx

This file was deleted.

17 changes: 0 additions & 17 deletions libs/database.js

This file was deleted.

Loading

0 comments on commit 11b7c0d

Please sign in to comment.