Skip to content

Commit

Permalink
feat: hide usermenu content when not authenticated
Browse files Browse the repository at this point in the history
  • Loading branch information
thraizz committed Dec 14, 2023
1 parent ca77b1c commit 8a23887
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/UserMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
import { useContext } from "react";
import { UploadModal } from "./UploadModal";
import { UserContext } from "./UserProvider";
import { auth } from "./firebaseConfig";

export const UserMenu = () => {
const { user } = useContext(UserContext);
const isAuthenticated = user?.uid;
return (
<div className="flex flex-row gap-4 items-center">
<UploadModal />
<button
onClick={() => auth.signOut()}
className="border-2 border-gray-300 px-4 py-2 rounded-md bg-sky-200"
>
Logout
</button>
{isAuthenticated && (
<>
<UploadModal />
<button
onClick={() => auth.signOut()}
className="border-2 border-gray-300 px-4 py-2 rounded-md bg-sky-200"
>
Logout
</button>
</>
)}
</div>
);
};

0 comments on commit 8a23887

Please sign in to comment.