Skip to content

Commit

Permalink
added join/create clinic link to dropdown menu in header
Browse files Browse the repository at this point in the history
  • Loading branch information
AEst2002 committed Nov 8, 2023
1 parent 9b20710 commit 9728adb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/(components-navbar)/auth-status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ export default async function AuthStatus() {
return;
}

return <UserNav profile={profile} />;
return <UserNav session={session} profile={profile} />;
}
18 changes: 10 additions & 8 deletions app/(components-navbar)/user-nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ import {
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { type Database } from "@/lib/schema";
import { createClientComponentClient } from "@supabase/auth-helpers-nextjs";
import { LogOut, Settings, User } from "lucide-react";
import { createClientComponentClient, type Session } from "@supabase/auth-helpers-nextjs";
import { LogOut, User } from "lucide-react";
import Link from "next/link";
import { useRouter } from "next/navigation";

type Profile = Database["public"]["Tables"]["profiles"]["Row"];

export default function UserNav({ profile }: { profile: Profile }) {
export default function UserNav({ profile, session }: { profile: Profile; session: Session }) {
// Create Supabase client (for client components)
const supabaseClient = createClientComponentClient<Database>();
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const userType = session.user.user_metadata.type; // all user metadata is defined as an any type.

const router = useRouter();

Expand Down Expand Up @@ -51,15 +53,15 @@ export default function UserNav({ profile }: { profile: Profile }) {
<DropdownMenuGroup>
{/* Using Next Link: https://github.com/radix-ui/primitives/issues/1105 */}
<DropdownMenuItem asChild>
<Link href="/settings/profile">
<Link href={userType === "clinician" ? "/create-clinic" : "/join-clinic"}>
<User className="mr-2 h-4 w-4" />
<span>Profile</span>
<span>{userType === "clinician" ? "Create clinic" : "Join clinic"}</span>
</Link>
</DropdownMenuItem>
<DropdownMenuItem asChild>
<Link href="/settings/general">
<Settings className="mr-2 h-4 w-4" />
<span>Settings</span>
<Link href="/background">
<User className="mr-2 h-4 w-4" />
<span>Profile</span>
</Link>
</DropdownMenuItem>
</DropdownMenuGroup>
Expand Down

0 comments on commit 9728adb

Please sign in to comment.