Skip to content

Connect, collaborate, and grow with a community of TypeScript developers

Make profile sections sub routes (#895)

Amanuel Odicho42bb58a1545d
diff --git a/apps/web/src/app/[locale]/[username]/_components/dashboard/bookmarks-tab.tsx b/apps/web/src/app/[locale]/[username]/_components/dashboard/bookmarks-tab.tsx
index 244bde3e..cd323bae 100644
--- a/apps/web/src/app/[locale]/[username]/_components/dashboard/bookmarks-tab.tsx
+++ b/apps/web/src/app/[locale]/[username]/_components/dashboard/bookmarks-tab.tsx
@@ -12,13 +12,14 @@ import {
import { getRelativeTime } from '~/utils/relativeTime';
import { withUnstableCache } from '~/utils/withUnstableCache';
+import { createCacheKeyForBookmarksTab } from '~/app/[locale]/challenge/_components/bookmark.action';
export async function BookmarksTab({ userId }: { userId: string }) {
const bookmarks = await withUnstableCache({
fn: getBookmarkedChallenges,
args: [userId],
- keys: ['bookmarked-challenges'],
- tags: ['challenges'],
+ keys: [`bookmarked-challenges`],
+ tags: [createCacheKeyForBookmarksTab(userId)],
});
return (
diff --git a/apps/web/src/app/[locale]/[username]/_components/dashboard/in-progress-tab.tsx b/apps/web/src/app/[locale]/[username]/_components/dashboard/in-progress-tab.tsx
index 2a61a25f..96e537e8 100644
--- a/apps/web/src/app/[locale]/[username]/_components/dashboard/in-progress-tab.tsx
+++ b/apps/web/src/app/[locale]/[username]/_components/dashboard/in-progress-tab.tsx
@@ -8,6 +8,7 @@ import {
TableRow,
} from '@repo/ui/components/table';
import Link from 'next/link';
+import { createInProgressSubmissionCacheKey } from '~/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/save-submission.action';
import { getRelativeTime } from '~/utils/relativeTime';
import { withUnstableCache } from '~/utils/withUnstableCache';
@@ -15,8 +16,8 @@ export async function InProgressTab({ userId }: { userId: string }) {
const challenges = await withUnstableCache({
fn: getInProgressChallenges,
args: [userId],
- keys: ['in-progress-challenges'],
- tags: ['challenges'],
+ keys: [`in-progress-challenges`],
+ tags: [createInProgressSubmissionCacheKey(userId)],
});
return (
diff --git a/apps/web/src/app/[locale]/[username]/_components/dashboard/index.tsx b/apps/web/src/app/[locale]/[username]/_components/dashboard/index.tsx
index 2b569345..cbe4bdf7 100644
--- a/apps/web/src/app/[locale]/[username]/_components/dashboard/index.tsx
+++ b/apps/web/src/app/[locale]/[username]/_components/dashboard/index.tsx
@@ -1,14 +1,7 @@
+'use client';
import Link from 'next/link';
-import { getServerAuthSession } from '@repo/auth/server';
import type { User } from '@repo/db/types';
-import {
- Card,
- CardContent,
- CardHeader,
- CardTitle,
- CardDescription,
-} from '@repo/ui/components/card';
import { MagicIcon } from '@repo/ui/components/magic-icon';
import {
Tabs,
@@ -21,31 +14,49 @@ import { Bookmark, ChevronRightSquare, Play, Settings, Text } from '@repo/ui/ico
import { getRelativeTime } from '~/utils/relativeTime';
import { stripProtocolAndWWW } from '~/utils/stringUtils';
-import { BookmarksTab } from './bookmarks-tab';
-import { InProgressTab } from './in-progress-tab';
-import { OverviewTab } from './overview-tab';
-import { SharedSolutionsTab } from './shared-solutions-tab';
import UserHeader from './user-header';
+import { useMemo } from 'react';
+import { usePathname, useRouter } from 'next/navigation';
interface Props {
// TODO: how do do this union type with just letting prisma halp
user: Pick<User, 'bio' | 'createdAt' | 'id' | 'image' | 'name'> & {
userLinks: { id: string | null; url: string }[];
};
+ isOwnProfile: boolean;
+ children: React.ReactNode;
}
+type Tab = 'bookmarks' | 'in-progress' | 'overview' | 'shared-solutions';
-export async function Dashboard({ user }: Props) {
- const session = await getServerAuthSession();
-
- const isOwnProfile = session?.user.id === user.id;
+export function Dashboard({ user, isOwnProfile, children }: Props) {
+ const router = useRouter();
const filteredProfileLinks =
user.userLinks.length > 0 ? user.userLinks.filter((item) => item.url !== '') : [];
+ const pathname = usePathname();
+ const selectedTab: Tab = useMemo(() => {
+ const splitPath = pathname.split('/');
+
+ if (splitPath.includes('in-progress')) {
+ return 'in-progress';
+ }
+
+ if (splitPath.includes('shared-solutions')) {
+ return 'shared-solutions';
+ }
+
+ if (splitPath.includes('bookmarks')) {
+ return 'bookmarks';
+ }
+
+ return 'overview';
+ }, [pathname]);
+
return (
<div className="container">
{/* // TODO: GFI: make each page a subroute, put settings & profile into same layout */}
- <Tabs className="flex flex-col gap-8 py-8 md:flex-row" defaultValue="overview">
+ <Tabs className="flex flex-col gap-8 py-8 md:flex-row" value={selectedTab}>
<VerticalTabsList>
<div className="flex flex-col items-center gap-10 md:items-start">
<div
@@ -80,24 +91,33 @@ export async function Dashboard({ user }: Props) {
)}
<div className="flex gap-4 md:w-full md:flex-col">
<VerticalTabsTrigger
- className="flex items-center justify-center gap-3 px-2 md:justify-normal md:px-3"
+ className="flex items-center justify-center gap-3 px-2 hover:bg-neutral-200/50 dark:hover:bg-neutral-700/50 md:justify-normal md:px-3"
value="overview"
+ onClick={() => {
+ router.push(`/@${user.name}`);
+ }}
>
<Text className="h-4 w-4" />
<span className="hidden md:block">Overview</span>
</VerticalTabsTrigger>
{Boolean(isOwnProfile) && (
<VerticalTabsTrigger
- className="flex items-center justify-center gap-3 px-2 md:justify-normal md:px-3"
+ className="flex items-center justify-center gap-3 px-2 hover:bg-neutral-200/50 dark:hover:bg-neutral-700/50 md:justify-normal md:px-3"
value="in-progress"
+ onClick={() => {
+ router.push(`/@${user.name}/in-progress`);
+ }}
>
<Play className="h-4 w-4" />
<span className="hidden md:block">In-Progress</span>
</VerticalTabsTrigger>
)}
<VerticalTabsTrigger
- className="flex items-center justify-center gap-3 px-2 md:justify-normal md:px-3"
+ className="flex items-center justify-center gap-3 px-2 hover:bg-neutral-200/50 dark:hover:bg-neutral-700/50 md:justify-normal md:px-3"
value="shared-solutions"
+ onClick={() => {
+ router.push(`/@${user.name}/shared-solutions`);
+ }}
>
<ChevronRightSquare className="h-4 w-4" />
<span className="hidden md:block">Shared Solutions</span>
@@ -105,15 +125,18 @@ export async function Dashboard({ user }: Props) {
{Boolean(isOwnProfile) && (
<>
<VerticalTabsTrigger
- className="flex items-center justify-center gap-3 px-2 md:justify-normal md:px-3"
+ className="flex items-center justify-center gap-3 px-2 hover:bg-neutral-200/50 dark:hover:bg-neutral-700/50 md:justify-normal md:px-3"
value="bookmarks"
+ onClick={() => {
+ router.push(`/@${user.name}/bookmarks`);
+ }}
>
<Bookmark className="h-4 w-4" />
<span className="hidden md:block">Bookmarks</span>
</VerticalTabsTrigger>
<Link
href="/settings"
- className="border-border dark:border-ring data-[state=active]:bg-border ring-offset-background focus-visible:ring-ring data-[state=active]:text-foreground flex items-center justify-center gap-3 whitespace-nowrap rounded-xl border px-1.5 py-1.5 text-sm font-medium transition-all duration-300 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm md:justify-normal md:px-3"
+ className="border-border dark:border-ring data-[state=active]:bg-border ring-offset-background focus-visible:ring-ring data-[state=active]:text-foreground flex items-center justify-center gap-3 whitespace-nowrap rounded-xl border px-1.5 py-1.5 text-sm font-medium transition-all duration-300 hover:bg-neutral-200/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm dark:hover:bg-neutral-700/50 md:justify-normal md:px-3"
>
<Settings className="h-4 w-4" />
<span className="hidden md:block">Settings</span>
@@ -123,54 +146,8 @@ export async function Dashboard({ user }: Props) {
</div>
</div>
</VerticalTabsList>
- <VerticalTabsContent className="shrink grow space-y-4" value="overview">
- <Card className="col-span-4 md:min-h-[calc(100vh_-_56px_-_6rem)]">
- <CardHeader>
- <CardTitle>Overview</CardTitle>
- </CardHeader>
- <CardContent>
- <OverviewTab user={user} />
- </CardContent>
- </Card>
- </VerticalTabsContent>
- <VerticalTabsContent className="shrink grow space-y-4" value="in-progress">
- <Card className="col-span-4 md:min-h-[calc(100vh_-_56px_-_6rem)]">
- <CardHeader>
- <CardTitle>In-Progress</CardTitle>
- <CardDescription className="text-muted-foreground mb-4 text-sm">
- Your in-progress challenges.
- </CardDescription>
- </CardHeader>
- <CardContent>
- <InProgressTab userId={user.id} />
- </CardContent>
- </Card>
- </VerticalTabsContent>
- <VerticalTabsContent className="shrink grow space-y-4" value="shared-solutions">
- <Card className="col-span-4 md:min-h-[calc(100vh_-_56px_-_6rem)]">
- <CardHeader>
- <CardTitle>Shared Solutions</CardTitle>
- <CardDescription className="text-muted-foreground mb-4 text-sm">
- {isOwnProfile ? 'Your' : `${user.name}'s`} shared challenge solutions.
- </CardDescription>
- </CardHeader>
- <CardContent>
- <SharedSolutionsTab userId={user.id} />
- </CardContent>
- </Card>
- </VerticalTabsContent>
- <VerticalTabsContent className="shrink grow space-y-4" value="bookmarks">
- <Card className="col-span-4 md:min-h-[calc(100vh_-_56px_-_6rem)]">
- <CardHeader>
- <CardTitle>Bookmarks</CardTitle>
- <CardDescription className="text-muted-foreground mb-4 text-sm">
- Your bookmarked challenges.
- </CardDescription>
- </CardHeader>
- <CardContent>
- <BookmarksTab userId={user.id} />
- </CardContent>
- </Card>
+ <VerticalTabsContent className="shrink grow space-y-4" value={selectedTab}>
+ {children}
</VerticalTabsContent>
</Tabs>
</div>
diff --git a/apps/web/src/app/[locale]/[username]/_components/dashboard/overview-tab.tsx b/apps/web/src/app/[locale]/[username]/_components/dashboard/overview-tab.tsx
index f98f8013..ba5e49ac 100644
--- a/apps/web/src/app/[locale]/[username]/_components/dashboard/overview-tab.tsx
+++ b/apps/web/src/app/[locale]/[username]/_components/dashboard/overview-tab.tsx
@@ -1,6 +1,7 @@
import { ReactMarkdown } from 'react-markdown/lib/react-markdown';
import type { User } from '@repo/db/types';
+import { Card, CardContent, CardHeader, CardTitle } from '@repo/ui/components/card';
interface Props {
// TODO: how do do this union type with just letting prisma halp
@@ -13,11 +14,18 @@ export async function OverviewTab({ user }: Props) {
const hasBio = Boolean(user.bio) && user.bio.trim().length > 0;
return (
- <div className="w-full text-sm md:w-64 md:text-start">
- {Boolean(hasBio) && <ReactMarkdown>{user.bio}</ReactMarkdown>}
- {Boolean(!hasBio) && (
- <p className="text-muted-foreground">{user.name} does not have a bio.</p>
- )}
- </div>
+ <Card className="col-span-4 md:min-h-[calc(100vh_-_56px_-_6rem)]">
+ <CardHeader>
+ <CardTitle>Overview</CardTitle>
+ </CardHeader>
+ <CardContent>
+ <div className="w-full text-sm md:w-64 md:text-start">
+ {Boolean(hasBio) && <ReactMarkdown>{user.bio}</ReactMarkdown>}
+ {Boolean(!hasBio) && (
+ <p className="text-muted-foreground">{user.name} does not have a bio.</p>
+ )}
+ </div>
+ </CardContent>
+ </Card>
);
}
diff --git a/apps/web/src/app/[locale]/[username]/_components/dashboard/shared-solutions-tab.tsx b/apps/web/src/app/[locale]/[username]/_components/dashboard/shared-solutions-tab.tsx
index 020bbaa3..f142d987 100644
--- a/apps/web/src/app/[locale]/[username]/_components/dashboard/shared-solutions-tab.tsx
+++ b/apps/web/src/app/[locale]/[username]/_components/dashboard/shared-solutions-tab.tsx
@@ -13,13 +13,14 @@ import {
import { getRelativeTime } from '~/utils/relativeTime';
import { withUnstableCache } from '~/utils/withUnstableCache';
+import { createCacheKeyForSharedSolutionsTab } from '~/app/[locale]/challenge/[slug]/solutions/_components/_actions';
export async function SharedSolutionsTab({ userId }: { userId: string }) {
const solutions = await withUnstableCache({
fn: getSharedSolutions,
args: [userId],
- keys: ['shared-solutions'],
- tags: ['submissions'],
+ keys: [`shared-solutions`],
+ tags: [createCacheKeyForSharedSolutionsTab(userId)],
});
return (
diff --git a/apps/web/src/app/[locale]/[username]/_components/profile.tsx b/apps/web/src/app/[locale]/[username]/_components/profile.tsx
index d5759d26..75ed1e46 100644
--- a/apps/web/src/app/[locale]/[username]/_components/profile.tsx
+++ b/apps/web/src/app/[locale]/[username]/_components/profile.tsx
@@ -2,9 +2,11 @@ import { prisma } from '@repo/db';
import type { Metadata } from 'next';
import { notFound } from 'next/navigation';
import { Dashboard } from './dashboard';
+import { getServerAuthSession } from '@repo/auth/server';
interface Props {
username: string;
+ children: React.ReactNode;
}
export const metadata: Metadata = {
@@ -12,9 +14,8 @@ export const metadata: Metadata = {
description: 'View this profile on TypeHero.',
};
-export async function Profile({ username: usernameFromQuery }: Props) {
+export async function Profile({ username: usernameFromQuery, children }: Props) {
const [, username] = decodeURIComponent(usernameFromQuery).split('@');
-
if (!username) return notFound();
const user = await prisma.user.findFirst({
@@ -35,5 +36,12 @@ export async function Profile({ username: usernameFromQuery }: Props) {
if (!user) return notFound();
- return <Dashboard user={user} />;
+ const session = await getServerAuthSession();
+ const isOwnProfile = session?.user.id === user.id;
+
+ return (
+ <Dashboard user={user} isOwnProfile={isOwnProfile}>
+ {children}
+ </Dashboard>
+ );
}
diff --git a/apps/web/src/app/[locale]/[username]/bookmarks/page.tsx b/apps/web/src/app/[locale]/[username]/bookmarks/page.tsx
new file mode 100644
index 00000000..c66e2460
--- /dev/null
+++ b/apps/web/src/app/[locale]/[username]/bookmarks/page.tsx
@@ -0,0 +1,54 @@
+import {
+ Card,
+ CardContent,
+ CardDescription,
+ CardHeader,
+ CardTitle,
+} from '@repo/ui/components/card';
+import { prisma } from '@repo/db';
+import { BookmarksTab } from '../_components/dashboard/bookmarks-tab';
+import { notFound } from 'next/navigation';
+
+interface Props {
+ params: {
+ username: string;
+ };
+}
+
+export default async function BookmarksPage({ params: { username: usernameFromQuery } }: Props) {
+ const [, username] = decodeURIComponent(usernameFromQuery).split('@');
+
+ if (!username) return notFound();
+
+ const user = await prisma.user.findFirst({
+ where: {
+ name: {
+ equals: username,
+ },
+ },
+ select: {
+ id: true,
+ createdAt: true,
+ bio: true,
+ image: true,
+ name: true,
+ userLinks: true,
+ },
+ });
+
+ if (!user) return notFound();
+
+ return (
+ <Card className="col-span-4 md:min-h-[calc(100vh_-_56px_-_6rem)]">
+ <CardHeader>
+ <CardTitle>Bookmarks</CardTitle>
+ <CardDescription className="text-muted-foreground mb-4 text-sm">
+ Your bookmarked challenges.
+ </CardDescription>
+ </CardHeader>
+ <CardContent>
+ <BookmarksTab userId={user.id} />
+ </CardContent>
+ </Card>
+ );
+}
diff --git a/apps/web/src/app/[locale]/[username]/in-progress/page.tsx b/apps/web/src/app/[locale]/[username]/in-progress/page.tsx
new file mode 100644
index 00000000..b0fe4089
--- /dev/null
+++ b/apps/web/src/app/[locale]/[username]/in-progress/page.tsx
@@ -0,0 +1,54 @@
+import {
+ Card,
+ CardContent,
+ CardDescription,
+ CardHeader,
+ CardTitle,
+} from '@repo/ui/components/card';
+import { InProgressTab } from '../_components/dashboard/in-progress-tab';
+import { notFound } from 'next/navigation';
+import { prisma } from '@repo/db';
+
+interface Props {
+ params: {
+ username: string;
+ };
+}
+
+export default async function InProgressPage({ params: { username: usernameFromQuery } }: Props) {
+ const [, username] = decodeURIComponent(usernameFromQuery).split('@');
+
+ if (!username) return notFound();
+
+ const user = await prisma.user.findFirst({
+ where: {
+ name: {
+ equals: username,
+ },
+ },
+ select: {
+ id: true,
+ createdAt: true,
+ bio: true,
+ image: true,
+ name: true,
+ userLinks: true,
+ },
+ });
+
+ if (!user) return notFound();
+
+ return (
+ <Card className="col-span-4 md:min-h-[calc(100vh_-_56px_-_6rem)]">
+ <CardHeader>
+ <CardTitle>In-Progress</CardTitle>
+ <CardDescription className="text-muted-foreground mb-4 text-sm">
+ Your in-progress challenges.
+ </CardDescription>
+ </CardHeader>
+ <CardContent>
+ <InProgressTab userId={user.id} />
+ </CardContent>
+ </Card>
+ );
+}
diff --git a/apps/web/src/app/[locale]/[username]/layout.tsx b/apps/web/src/app/[locale]/[username]/layout.tsx
new file mode 100644
index 00000000..826df057
--- /dev/null
+++ b/apps/web/src/app/[locale]/[username]/layout.tsx
@@ -0,0 +1,11 @@
+import { Profile } from './_components/profile';
+
+export default async function LayoutProfile({
+ children,
+ params: { username },
+}: {
+ children: React.ReactNode;
+ params: { username: string };
+}) {
+ return <Profile username={username}>{children}</Profile>;
+}
diff --git a/apps/web/src/app/[locale]/[username]/page.tsx b/apps/web/src/app/[locale]/[username]/page.tsx
index 18a3bc43..b9d0f890 100644
--- a/apps/web/src/app/[locale]/[username]/page.tsx
+++ b/apps/web/src/app/[locale]/[username]/page.tsx
@@ -1,6 +1,7 @@
import { buildMetaForDefault, buildMetaForUser } from '~/app/metadata';
-import { Profile } from './_components/profile';
import { prisma } from '@repo/db';
+import { OverviewTab } from './_components/dashboard/overview-tab';
+import { notFound } from 'next/navigation';
interface Props {
params: {
@@ -8,8 +9,29 @@ interface Props {
};
}
-export default function Page({ params }: Props) {
- return <Profile username={params.username} />;
+export default async function Page({ params: { username: usernameFromQuery } }: Props) {
+ const [, username] = decodeURIComponent(usernameFromQuery).split('@');
+
+ if (!username) return notFound();
+
+ const user = await prisma.user.findFirst({
+ where: {
+ name: {
+ equals: username,
+ },
+ },
+ select: {
+ id: true,
+ createdAt: true,
+ bio: true,
+ image: true,
+ name: true,
+ userLinks: true,
+ },
+ });
+
+ if (!user) return notFound();
+ return <OverviewTab user={user} />;
}
export async function generateMetadata({ params: { username: usernameFromQuery } }: Props) {
diff --git a/apps/web/src/app/[locale]/[username]/shared-solutions/page.tsx b/apps/web/src/app/[locale]/[username]/shared-solutions/page.tsx
new file mode 100644
index 00000000..ecc1787f
--- /dev/null
+++ b/apps/web/src/app/[locale]/[username]/shared-solutions/page.tsx
@@ -0,0 +1,60 @@
+import {
+ Card,
+ CardContent,
+ CardDescription,
+ CardHeader,
+ CardTitle,
+} from '@repo/ui/components/card';
+import { SharedSolutionsTab } from '../_components/dashboard/shared-solutions-tab';
+import { notFound } from 'next/navigation';
+import { prisma } from '@repo/db';
+import { getServerAuthSession } from '@repo/auth/server';
+
+interface Props {
+ params: {
+ username: string;
+ };
+}
+
+export default async function SharedSolutionsPage({
+ params: { username: usernameFromQuery },
+}: Props) {
+ const [, username] = decodeURIComponent(usernameFromQuery).split('@');
+
+ if (!username) return notFound();
+
+ const user = await prisma.user.findFirst({
+ where: {
+ name: {
+ equals: username,
+ },
+ },
+ select: {
+ id: true,
+ createdAt: true,
+ bio: true,
+ image: true,
+ name: true,
+ userLinks: true,
+ },
+ });
+
+ if (!user) return notFound();
+
+ const session = await getServerAuthSession();
+ const isOwnProfile = session?.user.id === user.id;
+
+ return (
+ <Card className="col-span-4 md:min-h-[calc(100vh_-_56px_-_6rem)]">
+ <CardHeader>
+ <CardTitle>Shared Solutions</CardTitle>
+ <CardDescription className="text-muted-foreground mb-4 text-sm">
+ {isOwnProfile ? 'Your' : `${user.name}'s`} shared challenge solutions.
+ </CardDescription>
+ </CardHeader>
+ <CardContent>
+ <SharedSolutionsTab userId={user.id} />
+ </CardContent>
+ </Card>
+ );
+}
diff --git a/apps/web/src/app/[locale]/challenge/[slug]/solutions/_components/_actions.ts b/apps/web/src/app/[locale]/challenge/[slug]/solutions/_components/_actions.ts
index 16455ebb..d7e7a0d0 100644
--- a/apps/web/src/app/[locale]/challenge/[slug]/solutions/_components/_actions.ts
+++ b/apps/web/src/app/[locale]/challenge/[slug]/solutions/_components/_actions.ts
@@ -14,6 +14,7 @@ interface Args {
}
export const createCacheKeyForSolutions = (slug: string) => `challenge-${slug}-solutions`;
+export const createCacheKeyForSharedSolutionsTab = (userId: string) => `${userId}-shared-solutions`;
export async function postSolution({ challengeId, description, slug, title, userId }: Args) {
const session = await getServerAuthSession();
@@ -28,6 +29,7 @@ export async function postSolution({ challengeId, description, slug, title, user
},
});
revalidateTag(createCacheKeyForSolutions(slug));
+ revalidateTag(createCacheKeyForSharedSolutionsTab(userId));
}
export async function deleteSolution(solutionToDelete: ChallengeSolution) {
diff --git a/apps/web/src/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/save-submission.action.ts b/apps/web/src/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/save-submission.action.ts
index 5e7f40fa..ef687214 100644
--- a/apps/web/src/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/save-submission.action.ts
+++ b/apps/web/src/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/save-submission.action.ts
@@ -7,6 +7,11 @@ import { createCacheKeyForSolutions } from '../../solutions/_components/_actions
export const createChallengeSubmissionCacheKey = (slug: string) => {
return `${slug}-challenge-submissions`;
};
+
+export const createInProgressSubmissionCacheKey = (userId: string) => {
+ return `${userId}-in-progress-challenges`;
+};
+
interface Args {
challenge: ChallengeRouteData['challenge'];
userId: string;
@@ -24,4 +29,5 @@ export async function saveSubmission({ challenge, userId, code, isSuccessful }:
});
revalidateTag(createChallengeSubmissionCacheKey(challenge.slug));
revalidateTag(createCacheKeyForSolutions(challenge.slug));
+ revalidateTag(createInProgressSubmissionCacheKey(userId));
}
diff --git a/apps/web/src/app/[locale]/challenge/_components/bookmark.action.ts b/apps/web/src/app/[locale]/challenge/_components/bookmark.action.ts
index 31a4c2f3..8a6970e9 100644
--- a/apps/web/src/app/[locale]/challenge/_components/bookmark.action.ts
+++ b/apps/web/src/app/[locale]/challenge/_components/bookmark.action.ts
@@ -1,5 +1,8 @@
'use server';
import { prisma } from '@repo/db';
+import { revalidateTag } from 'next/cache';
+
+export const createCacheKeyForBookmarksTab = (userId: string) => `${userId}-bookmarked-challenges`;
export async function addOrRemoveBookmark(
challengeId: number,
@@ -27,4 +30,6 @@ export async function addOrRemoveBookmark(
},
});
}
+
+ revalidateTag(createCacheKeyForBookmarksTab(userId));
}
diff --git a/apps/web/src/app/[locale]/settings/_components/settings.tsx b/apps/web/src/app/[locale]/settings/_components/settings.tsx
index 7486bf3d..af413604 100644
--- a/apps/web/src/app/[locale]/settings/_components/settings.tsx
+++ b/apps/web/src/app/[locale]/settings/_components/settings.tsx
@@ -65,15 +65,15 @@ export const Settings = async ({ user }: Props) => {
)}
<div className="flex gap-4 md:w-full md:flex-col">
<VerticalTabsTrigger
- className="flex items-center justify-center gap-3 px-2 md:justify-normal md:px-3"
+ className="flex items-center justify-center gap-3 px-2 hover:bg-neutral-200/50 dark:hover:bg-neutral-700/50 md:justify-normal md:px-3 "
value="settings"
>
<Settings2 className="h-4 w-4" />
<span className="hidden md:block">Settings</span>
</VerticalTabsTrigger>
<Link
- href="/settings"
- className="border-border dark:border-ring data-[state=active]:bg-border ring-offset-background focus-visible:ring-ring data-[state=active]:text-foreground flex items-center justify-center gap-3 whitespace-nowrap rounded-xl border px-1.5 py-1.5 text-sm font-medium transition-all duration-300 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm md:justify-normal md:px-3"
+ href={`/@${user.name}`}
+ className="border-border dark:border-ring data-[state=active]:bg-border ring-offset-background focus-visible:ring-ring data-[state=active]:text-foreground flex items-center justify-center gap-3 whitespace-nowrap rounded-xl border px-1.5 py-1.5 text-sm font-medium transition-all duration-300 hover:bg-neutral-200/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm dark:hover:bg-neutral-700/50 md:justify-normal md:px-3"
>
<UserIcon className="h-4 w-4" />
<span className="hidden md:block">Back to Profile</span>