Skip to content

Commit 46b8db3

Browse files
committed
chore: add links to account dropdown
1 parent d84d476 commit 46b8db3

File tree

18 files changed

+206
-158
lines changed

18 files changed

+206
-158
lines changed

src/app/api/auth/[...nextauth]/route.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { PrismaAdapter } from "@next-auth/prisma-adapter";
22
import NextAuth, { AuthOptions, DefaultSession } from "next-auth";
33
import GithubProvider from "next-auth/providers/github";
4-
54
import { prisma } from "@/lib/prisma";
65

76
declare module "next-auth" {

src/app/dashboard/page.tsx

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

3-
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
3+
import {
4+
Card,
5+
CardDescription,
6+
CardHeader,
7+
CardTitle,
8+
} from "@/components/ui/card";
49
import {
510
Table,
611
TableBody,

src/app/profile/_components/profile-image-button.tsx

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ import Link from "next/link";
22

33
export default function ProfileImageButton({
44
children,
5-
photoURL
5+
photoURL,
66
}: {
7-
children: React.ReactNode,
7+
children: React.ReactNode;
88
photoURL?: string | null;
99
}) {
10-
1110
return (
1211
<Link
1312
title="View Profile Picture"
@@ -18,4 +17,4 @@ export default function ProfileImageButton({
1817
{children}
1918
</Link>
2019
);
21-
};
20+
}
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,28 @@
11
"use client";
22
import { Button } from "@/components/ui/button";
3-
import {
4-
User2,
5-
History
6-
} from "lucide-react";
7-
import {
8-
usePathname,
9-
useRouter
10-
} from "next/navigation";
3+
import { User2, History } from "lucide-react";
4+
import { usePathname, useRouter } from "next/navigation";
115

126
const profileNavigationLinks = [
137
{
148
text: "User Profile",
159
id: "user-profile-navigation",
1610
title: "Navigate to User Profile",
1711
href: "/profile",
18-
icon: User2
12+
icon: User2,
1913
},
2014
{
2115
text: "Race History",
2216
id: "user-race-history-navigation",
2317
title: "View Race History",
2418
href: "/profile/race-history",
25-
icon: History
26-
}
27-
19+
icon: History,
20+
},
2821
];
2922

3023
const styles = {
3124
ul: "flex md:flex-col gap-x-2 gap-y-4",
32-
listText: "hidden xl:inline-block flex-[0.8]"
25+
listText: "hidden xl:inline-block flex-[0.8]",
3326
};
3427

3528
export default function ProfileNavigation() {
@@ -38,36 +31,29 @@ export default function ProfileNavigation() {
3831

3932
return (
4033
<ul className={styles.ul}>
41-
{
42-
profileNavigationLinks.map(link => {
43-
const isLinkActive = pathname === link.href;
44-
return (
45-
<li key={link.id}>
46-
<Button
47-
type="button"
48-
title={link.title}
49-
id={link.id}
50-
name="profile-navigation-buttons"
51-
variant={"ghost"}
52-
className={`w-full gap-2${isLinkActive ? " bg-accent" : ""}`}
53-
aria-current={isLinkActive ? "page" : undefined}
54-
onMouseEnter={() => router.prefetch(link.href)}
55-
onClick={() => router.replace(link.href)}
56-
>
57-
<span>
58-
<link.icon
59-
width={28}
60-
height={28}
61-
/>
62-
</span>
63-
<span className={styles.listText}>
64-
{link.text}
65-
</span>
66-
</Button>
67-
</li>
68-
);
69-
})
70-
}
34+
{profileNavigationLinks.map((link) => {
35+
const isLinkActive = pathname === link.href;
36+
return (
37+
<li key={link.id}>
38+
<Button
39+
type="button"
40+
title={link.title}
41+
id={link.id}
42+
name="profile-navigation-buttons"
43+
variant={"ghost"}
44+
className={`w-full gap-2${isLinkActive ? " bg-accent" : ""}`}
45+
aria-current={isLinkActive ? "page" : undefined}
46+
onMouseEnter={() => router.prefetch(link.href)}
47+
onClick={() => router.replace(link.href)}
48+
>
49+
<span>
50+
<link.icon width={28} height={28} />
51+
</span>
52+
<span className={styles.listText}>{link.text}</span>
53+
</Button>
54+
</li>
55+
);
56+
})}
7157
</ul>
7258
);
73-
};
59+
}

src/app/profile/_components/search-param-pfp.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ export default function SearchParamProfilePicture() {
77

88
if (!searchParam) {
99
return (
10-
<h1 className="text-center">Please provide an image link to view it on full screen!</h1>
10+
<h1 className="text-center">
11+
Please provide an image link to view it on full screen!
12+
</h1>
1113
);
1214
}
1315
return (
@@ -22,4 +24,4 @@ export default function SearchParamProfilePicture() {
2224
loading="eager"
2325
/>
2426
);
25-
};
27+
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
11
"use client";
22
import { Button } from "@/components/ui/button";
3-
import { useState } from "react";
3+
import { useEffect, useRef, useState } from "react";
44
import ChangeNameForm from "./change-name-form";
55

66
export default function ToggleChangeName() {
77
const [edit, setEdit] = useState(false);
8+
9+
const ref = useRef<HTMLDivElement>(null);
10+
11+
useEffect(() => {
12+
const onClickModalBackground = () => {
13+
console.log("here");
14+
setEdit(false);
15+
};
16+
const el = ref.current;
17+
if (!el) return;
18+
el.addEventListener("click", onClickModalBackground);
19+
return () => {
20+
el.removeEventListener("click", onClickModalBackground);
21+
};
22+
}, [ref, edit]);
23+
824
return (
925
<>
1026
<Button
@@ -15,17 +31,15 @@ export default function ToggleChangeName() {
1531
>
1632
Edit username
1733
</Button>
18-
{
19-
edit ? (
34+
{edit ? (
35+
<div className="fixed inset-0 bg-monochrome-low-opacity w-full h-full z-20 grid place-items-center">
2036
<div
21-
className="fixed inset-0 bg-monochrome-low-opacity w-full h-full z-20 grid place-items-center"
22-
>
23-
<div className="z-0 overflow-auto w-full h-full absolute inset-0" onClick={() => setEdit(false)} />
24-
<ChangeNameForm />
25-
</div>
26-
27-
) : null
28-
}
37+
ref={ref}
38+
className="z-0 overflow-auto w-full h-full absolute inset-0"
39+
/>
40+
<ChangeNameForm />
41+
</div>
42+
) : null}
2943
</>
3044
);
31-
};
45+
}

src/app/profile/loading.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
export const metadata = {
22
title: {
3-
absolute: "Loading Profile Page"
4-
}
3+
absolute: "Loading Profile Page",
4+
},
55
};
66

77
export default function Loading() {
8-
return <h1 className="text-center">Loading Page...</h1>
9-
};
8+
return <h1 className="text-center">Loading Page...</h1>;
9+
}
+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
export const metadata = {
22
title: {
3-
absolute: "Loading Race History"
4-
}
3+
absolute: "Loading Race History",
4+
},
55
};
66

77
export default function Loading() {
8-
return <h1>Loading History...</h1>
9-
};
8+
return <h1>Loading History...</h1>;
9+
}

src/app/profile/race-history/page.tsx

+54-39
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,36 @@ import { Metadata } from "next";
33
import { Suspense } from "react";
44

55
export const metadata: Metadata = {
6-
title: "Race History"
6+
title: "Race History",
77
};
88

99
async function RaceHistoryCard() {
1010
const historyMatches = [
1111
{
12+
id: "1",
1213
date: "March 20, 2023",
1314
averageSpeed: 2000,
1415
versus: "Xx_deadlyMamba_xX",
15-
status: "lost"
16-
}, {
16+
status: "lost",
17+
},
18+
{
19+
id: "2",
1720
date: "March 21, 2023",
1821
averageSpeed: 1000,
1922
versus: "funnyGuy123",
20-
status: "won"
21-
}, {
23+
status: "won",
24+
},
25+
{
26+
id: "3",
2227
date: "April 22, 2023",
2328
averageSpeed: 10000,
2429
versus: "masterOfAll",
25-
status: "draw"
26-
}
30+
status: "draw",
31+
},
2732
];
28-
{/** Dynamic data coming soon... */ }
33+
{
34+
/** Dynamic data coming soon... */
35+
}
2936
const descendingOrder = historyMatches.sort((a, b) => {
3037
if (new Date(a.date) > new Date(b.date)) {
3138
return -1;
@@ -40,40 +47,48 @@ async function RaceHistoryCard() {
4047

4148
return (
4249
<section className="grid grid-cols-[1fr] 2xl:grid-cols-[1fr,1fr] gap-x-8 gap-y-4">
43-
{
44-
descendingOrder.map(match => {
45-
let name = match.versus;
46-
/** If the name length > 11 chars, then cut it. This is to avoid overflows */
47-
if (match.versus.length > 11) {
48-
name = `${match.versus.slice(0, 11)}...`;
49-
}
50-
const statusColor = match.status === "won"
50+
{descendingOrder.map((match) => {
51+
let name = match.versus;
52+
/** If the name length > 11 chars, then cut it. This is to avoid overflows */
53+
if (match.versus.length > 11) {
54+
name = `${match.versus.slice(0, 11)}...`;
55+
}
56+
const statusColor =
57+
match.status === "won"
5158
? "text-green-400"
5259
: match.status === "lost"
53-
? "text-destructive"
54-
: "text-yellow-400"
55-
return (
56-
(
57-
/** This container can be a button or link which leads
58-
* to a page that'll give more information about the
59-
* match.
60-
*/
61-
<div className="text-center shadow-md shadow-monochrome-low-opacity flex gap-4 md:gap-8 justify-between items-center bg-secondary py-2 px-4 md:py-4 md:px-8 rounded-md">
62-
<div className="flex-[0.85] text-start">
63-
<h2 className="text-base md:text-lg font-medium">Battled vs. {name}</h2>
64-
<span className="text-xs md:text-sm">Last: <Time date={new Date(match.date)} /></span>
65-
</div>
66-
<span className={`${statusColor} flex-[0.125] font-bold text-sm md:text-lg inline-block`}>{match.status.toUpperCase()}</span>
67-
{/**Some kind of circle here to indicate how good the speed is */}
68-
<div className="flex-[0.125]">{match.averageSpeed / 1000}s</div>
69-
</div>
70-
)
71-
)
72-
})
73-
}
60+
? "text-destructive"
61+
: "text-yellow-400";
62+
return (
63+
/** This container can be a button or link which leads
64+
* to a page that'll give more information about the
65+
* match.
66+
*/
67+
<div
68+
key={match.id}
69+
className="text-center shadow-md shadow-monochrome-low-opacity flex gap-4 md:gap-8 justify-between items-center bg-secondary py-2 px-4 md:py-4 md:px-8 rounded-md"
70+
>
71+
<div className="flex-[0.85] text-start">
72+
<h2 className="text-base md:text-lg font-medium">
73+
Battled vs. {name}
74+
</h2>
75+
<span className="text-xs md:text-sm">
76+
Last: <Time date={new Date(match.date)} />
77+
</span>
78+
</div>
79+
<span
80+
className={`${statusColor} flex-[0.125] font-bold text-sm md:text-lg inline-block`}
81+
>
82+
{match.status.toUpperCase()}
83+
</span>
84+
{/**Some kind of circle here to indicate how good the speed is */}
85+
<div className="flex-[0.125]">{match.averageSpeed / 1000}s</div>
86+
</div>
87+
);
88+
})}
7489
</section>
7590
);
76-
};
91+
}
7792

7893
export default function RaceHistoryPage() {
7994
return (
@@ -84,4 +99,4 @@ export default function RaceHistoryPage() {
8499
</Suspense>
85100
</article>
86101
);
87-
};
102+
}

0 commit comments

Comments
 (0)