Skip to content

Commit

Permalink
Merge pull request #49 from podcodar/nicolasbrandao/navbar-gets-user-…
Browse files Browse the repository at this point in the history
…from-context

Navbar now gets user from context instead of props
  • Loading branch information
nicolasbrandao authored Aug 16, 2023
2 parents f0a135f + 9b53da3 commit bdb7182
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
11 changes: 7 additions & 4 deletions src/app/admin/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { authOptions } from "@/shared/auth";
import Navbar from "@/components/Navbar";

import { fetchUserWithSession } from "@/shared/auth";
import { UserProvider } from "@/contexts/UserProvider";

export const metadata: Metadata = {
title: "PodCodar Admin",
Expand All @@ -19,10 +20,12 @@ export default async function RootLayout({ children }: PropsWithChildren) {
return (
<body>
<AuthProvider>
<div className="bg-white shadow">
<Navbar loggedUser={loggedUser} />
</div>
{children}
<UserProvider user={loggedUser}>
<div className="bg-white shadow">
<Navbar />
</div>
{children}
</UserProvider>
</AuthProvider>
</body>
);
Expand Down
2 changes: 1 addition & 1 deletion src/app/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default async function RootLayout({ children }: PropsWithChildren) {
<AuthProvider>
<UserProvider user={loggedUser}>
<div className="shadow-md">
<Navbar loggedUser={loggedUser} />
<Navbar />
</div>
{children}
</UserProvider>
Expand Down
9 changes: 3 additions & 6 deletions src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,15 @@ import { Bars3Icon, BellIcon, XMarkIcon } from "@heroicons/react/24/outline";
import { Logo } from "./Logo";
import { classes } from "@/shared/tw";
import Image from "next/image";
import { User } from "@prisma/client";
import Link from "next/link";
import { useUser } from "@/contexts/UserProvider";

const navigation = [{ name: "Home", href: "/app", current: true }];

const profileLinks = [{ name: "Sign out", onClick: () => signOut() }];

type Props = {
loggedUser: User;
};

export default function Navbar({ loggedUser }: Props) {
export default function Navbar() {
const loggedUser = useUser();
return (
<Disclosure as="nav" className="bg-gray-800">
{({ open }) => (
Expand Down

1 comment on commit bdb7182

@vercel
Copy link

@vercel vercel bot commented on bdb7182 Aug 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.