Skip to content

Commit 9fd6a3d

Browse files
committed
fix: fixed the mobile nav after sign in
1 parent 801b2f6 commit 9fd6a3d

File tree

5 files changed

+23
-8
lines changed

5 files changed

+23
-8
lines changed

src/app/race/no-snippet.tsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,18 @@ interface NoSnippetProps {
99
}
1010

1111
export default function NoSnippet({ message, language }: NoSnippetProps) {
12-
const formattedLanguage = snippetLanguages.find(snippet => snippet.value === language)?.label ?? language;
12+
const formattedLanguage =
13+
snippetLanguages.find((snippet) => snippet.value === language)?.label ??
14+
language;
1315
return (
1416
<div className="flex flex-col gap-4 justify-start">
15-
<Heading title={`No ${formattedLanguage} snippet found`} description={message}/>
17+
<Heading
18+
title={`No ${formattedLanguage} snippet found`}
19+
description={message}
20+
/>
1621
<Link href={"/add-snippet"}>
1722
<Button>Create New Snippet</Button>
1823
</Link>
1924
</div>
20-
)
25+
);
2126
}

src/app/race/practice/page.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ async function getSearchParamSnippet(snippetId: string | string[]) {
3838

3939
export default async function PracticeRacePage({
4040
searchParams,
41-
}: { searchParams: RacePageSearchParams }) {
41+
}: {
42+
searchParams: RacePageSearchParams;
43+
}) {
4244
const user = await getCurrentUser();
4345
const snippet =
4446
(await getSearchParamSnippet(searchParams.snippetId)) ??

src/components/header.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export async function Header() {
1414
<div className="flex-1">
1515
<MainNav items={siteConfig.getHeaderLinks(!!user)} />
1616
</div>
17-
<MobileNav />
17+
<MobileNav user={user} />
1818
<nav className="items-center hidden space-x-4 md:flex">
1919
<UserDropdown user={user} />
2020
<ModeToggle />

src/components/mobile-nav.tsx

+10-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,16 @@ import Link, { LinkProps } from "next/link";
1212
import { ModeToggle } from "./mode-toggle";
1313
import { useRouter } from "next/navigation";
1414
import { useSession } from "next-auth/react";
15+
import type { User } from "next-auth";
16+
import { UserRole } from "@prisma/client";
1517

16-
export function MobileNav() {
18+
interface MobileNavProps {
19+
user?: User & {
20+
role: UserRole;
21+
};
22+
}
23+
24+
export function MobileNav({ user }: MobileNavProps) {
1725
const [open, setOpen] = useState(false);
1826
const isLoggedIn = !!useSession().data;
1927

@@ -32,7 +40,7 @@ export function MobileNav() {
3240
<SheetContent side="right" className="w-[300px] sm:w-[540px]">
3341
<ScrollArea className="my-4 h-[calc(100vh-9rem)] pb-10">
3442
<div className="flex flex-col items-center justify-center gap-10 py-2">
35-
<UserDropdown />
43+
<UserDropdown user={user} />
3644
<nav className="flex flex-col items-center justify-center flex-1 space-y-4">
3745
{siteConfig.getHeaderLinks(isLoggedIn).map((item) => (
3846
<MobileLink

src/components/user-dropdown.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22

3-
import { signOut, useSession } from "next-auth/react";
3+
import { signOut } from "next-auth/react";
44
import Image from "next/image";
55
import Link from "next/link";
66
import { Icons } from "./icons";

0 commit comments

Comments
 (0)