Connect, collaborate, and grow with a community of TypeScript developers
chore: refactor profile (#1101)
bautistaaa5075ca66e1df
diff --git a/apps/web/src/app/[locale]/(profile)/[username]/_components/dashboard/_actions.ts b/apps/web/src/app/[locale]/(profile)/[username]/_components/dashboard/_actions.tsnew file mode 100644index 00000000..831efd69--- /dev/null+++ b/apps/web/src/app/[locale]/(profile)/[username]/_components/dashboard/_actions.ts@@ -0,0 +1,66 @@+'use server';++import { prisma } from '@repo/db';++export type HistoricalChallenge = Awaited<ReturnType<typeof getChallengeHistoryByCategory>>[0];++type HistoryType = 'completed' | 'in-progress';+const getPredicateByType = (type: HistoryType, userId: string) => {+ switch (type) {+ case 'in-progress':+ return {+ AND: [+ {+ submission: {+ none: {+ userId,+ isSuccessful: true,+ },+ },+ },+ // Make sure there is at least one submission+ { submission: { some: { userId, isSuccessful: false } } },+ ],+ };+ case 'completed':+ return {+ submission: {+ some: {+ userId,+ isSuccessful: true,+ },+ },+ };+ }+};++export async function getChallengeHistoryByCategory(type: HistoryType, userId: string) {+ const challenges = await prisma.challenge.findMany({+ where: getPredicateByType(type, userId),+ select: {+ id: true,+ slug: true,+ name: true,+ submission: {+ orderBy: {+ createdAt: 'desc',+ },+ take: 1,+ select: {+ createdAt: true,+ },+ },+ },+ });++ return challenges+ .map((challenge) => ({+ ...challenge,+ submissionDate: challenge.submission[0]?.createdAt,+ }))+ .sort(+ (challengeA, challengeB) =>+ new Date(challengeB.submissionDate!).getTime() -+ new Date(challengeA.submissionDate!).getTime(),+ );+}diff --git a/apps/web/src/app/[locale]/(profile)/[username]/_components/dashboard/challenge-history-columns.tsx b/apps/web/src/app/[locale]/(profile)/[username]/_components/dashboard/challenge-history-columns.tsxnew file mode 100644index 00000000..52cc5320--- /dev/null+++ b/apps/web/src/app/[locale]/(profile)/[username]/_components/dashboard/challenge-history-columns.tsx@@ -0,0 +1,23 @@+'use client';++import { type ColumnDef } from '@tanstack/react-table';+import Link from 'next/link';+import { getRelativeTime } from '~/utils/relativeTime';+import type { HistoricalChallenge } from './_actions';++export const columns: ColumnDef<HistoricalChallenge>[] = [+ {+ accessorKey: 'slug',+ header: 'Challenge',+ cell: ({ row }) => (+ <Link href={`/challenge/${row.original.slug}`} className="underline">+ {row.original.name}+ </Link>+ ),+ },+ {+ accessorKey: 'submissionDate',+ header: 'Last Submission',+ cell: ({ row }) => getRelativeTime(row.original.submissionDate!),+ },+];diff --git a/apps/web/src/app/[locale]/[username]/_components/dashboard/challenge-history.tsx b/apps/web/src/app/[locale]/(profile)/[username]/_components/dashboard/challenge-history.tsxsimilarity index 58%rename from apps/web/src/app/[locale]/[username]/_components/dashboard/challenge-history.tsxrename to apps/web/src/app/[locale]/(profile)/[username]/_components/dashboard/challenge-history.tsxindex 3a145148..b3e74bc3 100644--- a/apps/web/src/app/[locale]/[username]/_components/dashboard/challenge-history.tsx+++ b/apps/web/src/app/[locale]/(profile)/[username]/_components/dashboard/challenge-history.tsx@@ -1,8 +1,9 @@import { DataTable } from '@repo/ui/components/data-table';-import { columns, type Challenge } from './challenge-history-columns';+import { columns } from './challenge-history-columns';+import type { HistoricalChallenge } from './_actions';interface Props {- challenges: Challenge[];+ challenges: HistoricalChallenge[];}export default function ChallengeHistory({ challenges }: Props) {diff --git a/apps/web/src/app/[locale]/[username]/_components/dashboard/index.tsx b/apps/web/src/app/[locale]/(profile)/[username]/_components/dashboard/index.tsxsimilarity index 100%rename from apps/web/src/app/[locale]/[username]/_components/dashboard/index.tsxrename to apps/web/src/app/[locale]/(profile)/[username]/_components/dashboard/index.tsxdiff --git a/apps/web/src/app/[locale]/[username]/_components/dashboard/overview-tab.tsx b/apps/web/src/app/[locale]/(profile)/[username]/_components/dashboard/overview-tab.tsxsimilarity index 100%rename from apps/web/src/app/[locale]/[username]/_components/dashboard/overview-tab.tsxrename to apps/web/src/app/[locale]/(profile)/[username]/_components/dashboard/overview-tab.tsxdiff --git a/apps/web/src/app/[locale]/[username]/_components/dashboard/user-header.tsx b/apps/web/src/app/[locale]/(profile)/[username]/_components/dashboard/user-header.tsxsimilarity index 100%rename from apps/web/src/app/[locale]/[username]/_components/dashboard/user-header.tsxrename to apps/web/src/app/[locale]/(profile)/[username]/_components/dashboard/user-header.tsxdiff --git a/apps/web/src/app/[locale]/[username]/_components/profile.tsx b/apps/web/src/app/[locale]/(profile)/[username]/_components/profile.tsxsimilarity index 100%rename from apps/web/src/app/[locale]/[username]/_components/profile.tsxrename to apps/web/src/app/[locale]/(profile)/[username]/_components/profile.tsxdiff --git a/apps/web/src/app/[locale]/(profile)/[username]/bookmarks/_components/bookmarked-challenges-columns.tsx b/apps/web/src/app/[locale]/(profile)/[username]/bookmarks/_components/bookmarked-challenges-columns.tsxnew file mode 100644index 00000000..fd4652a3--- /dev/null+++ b/apps/web/src/app/[locale]/(profile)/[username]/bookmarks/_components/bookmarked-challenges-columns.tsx@@ -0,0 +1,23 @@+'use client';++import { type ColumnDef } from '@tanstack/react-table';+import { getRelativeTime } from '~/utils/relativeTime';+import Link from 'next/link';+import type { BookmarkedChallenge } from '../page';++export const bookmarkedChallengedColumns: ColumnDef<BookmarkedChallenge>[] = [+ {+ accessorFn: (bookmark) => bookmark.challenge?.name,+ header: 'Title',+ cell: ({ row }) => (+ <Link className="underline" href={`/challenge/${row.original.challenge?.slug}`}>+ {row.original.challenge?.name}+ </Link>+ ),+ },+ {+ accessorKey: 'createdAt',+ header: 'Date',+ cell: ({ row }) => getRelativeTime(row.original.createdAt!),+ },+];diff --git a/apps/web/src/app/[locale]/[username]/bookmarks/page.tsx b/apps/web/src/app/[locale]/(profile)/[username]/bookmarks/page.tsxsimilarity index 53%rename from apps/web/src/app/[locale]/[username]/bookmarks/page.tsxrename to apps/web/src/app/[locale]/(profile)/[username]/bookmarks/page.tsxindex a01bf0c6..4547dc6b 100644--- a/apps/web/src/app/[locale]/[username]/bookmarks/page.tsx+++ b/apps/web/src/app/[locale]/(profile)/[username]/bookmarks/page.tsx@@ -1,3 +1,5 @@+import { getServerAuthSession } from '@repo/auth/server';+import { prisma } from '@repo/db';import {Card,CardContent,@@ -5,10 +7,11 @@ import {CardHeader,CardTitle,} from '@repo/ui/components/card';-import { prisma } from '@repo/db';-import { BookmarksTab } from '../_components/dashboard/bookmarks-tab';import { notFound } from 'next/navigation';-import { getServerAuthSession } from '@repo/auth/server';+import { withUnstableCache } from '~/utils/withUnstableCache';+import { createCacheKeyForBookmarksTab } from '../../../challenge/_components/bookmark.action';+import { DataTable } from '@repo/ui/components/data-table';+import { bookmarkedChallengedColumns } from './_components/bookmarked-challenges-columns';interface Props {params: {@@ -30,16 +33,18 @@ export default async function BookmarksPage({ params: { username: usernameFromQu},select: {id: true,- createdAt: true,- bio: true,- image: true,- name: true,- userLinks: true,},});if (!user) return notFound();+ const bookmarks = await withUnstableCache({+ fn: getBookmarkedChallenges,+ args: [user.id],+ keys: [`bookmarked-challenges`],+ tags: [createCacheKeyForBookmarksTab(user.id)],+ });+return (<Card className="col-span-4 md:min-h-[calc(100vh_-_56px_-_6rem)]"><CardHeader>@@ -49,8 +54,27 @@ export default async function BookmarksPage({ params: { username: usernameFromQu</CardDescription></CardHeader><CardContent>- <BookmarksTab userId={user.id} />+ <DataTable data={bookmarks} columns={bookmarkedChallengedColumns} /></CardContent></Card>);}++export type BookmarkedChallenge = Awaited<ReturnType<typeof getBookmarkedChallenges>>[0];+async function getBookmarkedChallenges(userId: string) {+ return await prisma.bookmark.findMany({+ where: { userId },+ include: {+ challenge: {+ select: {+ id: true,+ slug: true,+ name: true,+ },+ },+ },+ orderBy: {+ createdAt: 'desc',+ },+ });+}diff --git a/apps/web/src/app/[locale]/[username]/completed/page.tsx b/apps/web/src/app/[locale]/(profile)/[username]/completed/page.tsxsimilarity index 64%rename from apps/web/src/app/[locale]/[username]/completed/page.tsxrename to apps/web/src/app/[locale]/(profile)/[username]/completed/page.tsxindex bf35d1bc..0d37c8c2 100644--- a/apps/web/src/app/[locale]/[username]/completed/page.tsx+++ b/apps/web/src/app/[locale]/(profile)/[username]/completed/page.tsx@@ -1,3 +1,5 @@+import { getServerAuthSession } from '@repo/auth/server';+import { prisma } from '@repo/db';import {Card,CardContent,@@ -5,10 +7,11 @@ import {CardHeader,CardTitle,} from '@repo/ui/components/card';-import { CompletedTab } from '../_components/dashboard/completed-tab';import { notFound } from 'next/navigation';-import { prisma } from '@repo/db';-import { getServerAuthSession } from '@repo/auth/server';+import { createCompletedSubmissionCacheKey } from '~/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/cache-keys';+import { withUnstableCache } from '~/utils/withUnstableCache';+import { getChallengeHistoryByCategory } from '../_components/dashboard/_actions';+import ChallengeHistory from '../_components/dashboard/challenge-history';interface Props {params: {@@ -30,16 +33,18 @@ export default async function CompletedPage({ params: { username: usernameFromQu},select: {id: true,- createdAt: true,- bio: true,- image: true,- name: true,- userLinks: true,},});if (!user) return notFound();+ const challenges = await withUnstableCache({+ fn: getChallengeHistoryByCategory,+ args: ['completed', user.id],+ keys: [`completed-challenges-${user.id}`],+ tags: [createCompletedSubmissionCacheKey(user.id)],+ });+return (<Card className="col-span-4 md:min-h-[calc(100vh_-_56px_-_6rem)]"><CardHeader>@@ -49,7 +54,7 @@ export default async function CompletedPage({ params: { username: usernameFromQu</CardDescription></CardHeader><CardContent>- <CompletedTab userId={user.id} />+ <ChallengeHistory challenges={challenges} /></CardContent></Card>);diff --git a/apps/web/src/app/[locale]/[username]/in-progress/page.tsx b/apps/web/src/app/[locale]/(profile)/[username]/in-progress/page.tsxsimilarity index 64%rename from apps/web/src/app/[locale]/[username]/in-progress/page.tsxrename to apps/web/src/app/[locale]/(profile)/[username]/in-progress/page.tsxindex aafc9a5d..da509aa2 100644--- a/apps/web/src/app/[locale]/[username]/in-progress/page.tsx+++ b/apps/web/src/app/[locale]/(profile)/[username]/in-progress/page.tsx@@ -1,3 +1,5 @@+import { getServerAuthSession } from '@repo/auth/server';+import { prisma } from '@repo/db';import {Card,CardContent,@@ -5,10 +7,11 @@ import {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';-import { getServerAuthSession } from '@repo/auth/server';+import { createInProgressSubmissionCacheKey } from '~/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/cache-keys';+import { withUnstableCache } from '~/utils/withUnstableCache';+import { getChallengeHistoryByCategory } from '../_components/dashboard/_actions';+import ChallengeHistory from '../_components/dashboard/challenge-history';interface Props {params: {@@ -30,16 +33,18 @@ export default async function InProgressPage({ params: { username: usernameFromQ},select: {id: true,- createdAt: true,- bio: true,- image: true,- name: true,- userLinks: true,},});if (!user) return notFound();+ const challenges = await withUnstableCache({+ fn: getChallengeHistoryByCategory,+ args: ['in-progress', user.id],+ keys: [`in-progress-challenges-${user.id}`],+ tags: [createInProgressSubmissionCacheKey(user.id)],+ });+return (<Card className="col-span-4 md:min-h-[calc(100vh_-_56px_-_6rem)]"><CardHeader>@@ -49,7 +54,7 @@ export default async function InProgressPage({ params: { username: usernameFromQ</CardDescription></CardHeader><CardContent>- <InProgressTab userId={user.id} />+ <ChallengeHistory challenges={challenges} /></CardContent></Card>);diff --git a/apps/web/src/app/[locale]/[username]/layout.tsx b/apps/web/src/app/[locale]/(profile)/[username]/layout.tsxsimilarity index 100%rename from apps/web/src/app/[locale]/[username]/layout.tsxrename to apps/web/src/app/[locale]/(profile)/[username]/layout.tsxdiff --git a/apps/web/src/app/[locale]/[username]/page.tsx b/apps/web/src/app/[locale]/(profile)/[username]/page.tsxsimilarity index 100%rename from apps/web/src/app/[locale]/[username]/page.tsxrename to apps/web/src/app/[locale]/(profile)/[username]/page.tsxdiff --git a/apps/web/src/app/[locale]/(profile)/[username]/shared-solutions/_components/shared-solutions-columns.tsx b/apps/web/src/app/[locale]/(profile)/[username]/shared-solutions/_components/shared-solutions-columns.tsxnew file mode 100644index 00000000..b498e19a--- /dev/null+++ b/apps/web/src/app/[locale]/(profile)/[username]/shared-solutions/_components/shared-solutions-columns.tsx@@ -0,0 +1,39 @@+'use client';++import { type ColumnDef } from '@tanstack/react-table';+import { getRelativeTime } from '~/utils/relativeTime';+import Link from 'next/link';+import type { SharedSolution } from '../page';++export const sharedSolutionsColumns: ColumnDef<SharedSolution>[] = [+ {+ accessorKey: 'title',+ header: 'Title',+ cell: ({ row }) => (+ <Link+ className="underline"+ href={`/challenge/${row.original.challenge?.slug}/solutions/${row.original.id}`}+ >+ {row.original.title}+ </Link>+ ),+ },+ {+ accessorFn: (solution) => solution.challenge?.name,+ header: 'Challenge',+ cell: ({ row }) => (+ <Link className="underline" href={`/challenge/${row.original.challenge?.slug}`}>+ {row.original.challenge?.name}+ </Link>+ ),+ },+ {+ accessorFn: (solution) => solution._count.vote,+ header: 'Votes',+ },+ {+ accessorKey: 'createdAt',+ header: 'Date',+ cell: ({ row }) => getRelativeTime(row.original.createdAt),+ },+];diff --git a/apps/web/src/app/[locale]/[username]/shared-solutions/page.tsx b/apps/web/src/app/[locale]/(profile)/[username]/shared-solutions/page.tsxsimilarity index 52%rename from apps/web/src/app/[locale]/[username]/shared-solutions/page.tsxrename to apps/web/src/app/[locale]/(profile)/[username]/shared-solutions/page.tsxindex ecc1787f..49917a37 100644--- a/apps/web/src/app/[locale]/[username]/shared-solutions/page.tsx+++ b/apps/web/src/app/[locale]/(profile)/[username]/shared-solutions/page.tsx@@ -1,3 +1,5 @@+import { getServerAuthSession } from '@repo/auth/server';+import { prisma } from '@repo/db';import {Card,CardContent,@@ -5,10 +7,11 @@ import {CardHeader,CardTitle,} from '@repo/ui/components/card';-import { SharedSolutionsTab } from '../_components/dashboard/shared-solutions-tab';+import { DataTable } from '@repo/ui/components/data-table';import { notFound } from 'next/navigation';-import { prisma } from '@repo/db';-import { getServerAuthSession } from '@repo/auth/server';+import { withUnstableCache } from '~/utils/withUnstableCache';+import { createCacheKeyForSharedSolutionsTab } from '../../../challenge/[slug]/solutions/_components/_actions';+import { sharedSolutionsColumns } from './_components/shared-solutions-columns';interface Props {params: {@@ -31,16 +34,19 @@ export default async function SharedSolutionsPage({},select: {id: true,- createdAt: true,- bio: true,- image: true,name: true,- userLinks: true,},});if (!user) return notFound();+ const solutions = await withUnstableCache({+ fn: getSharedSolutions,+ args: [user.id],+ keys: [`shared-solutions`],+ tags: [createCacheKeyForSharedSolutionsTab(user.id)],+ });+const session = await getServerAuthSession();const isOwnProfile = session?.user.id === user.id;@@ -53,8 +59,35 @@ export default async function SharedSolutionsPage({</CardDescription></CardHeader><CardContent>- <SharedSolutionsTab userId={user.id} />+ <DataTable data={solutions} columns={sharedSolutionsColumns} /></CardContent></Card>);}++export type SharedSolutions = Awaited<ReturnType<typeof getSharedSolutions>>;+export type SharedSolution = SharedSolutions[0];+async function getSharedSolutions(userId: string) {+ return await prisma.sharedSolution.findMany({+ where: {+ userId,+ },+ orderBy: {+ createdAt: 'desc',+ },+ include: {+ _count: {+ select: {+ vote: true,+ },+ },+ challenge: {+ select: {+ id: true,+ slug: true,+ name: true,+ },+ },+ },+ });+}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.tsxdeleted file mode 100644index cd323bae..00000000--- a/apps/web/src/app/[locale]/[username]/_components/dashboard/bookmarks-tab.tsx+++ /dev/null@@ -1,69 +0,0 @@-import Link from 'next/link';--import { prisma } from '@repo/db';-import {- Table,- TableBody,- TableCell,- TableHead,- TableHeader,- TableRow,-} from '@repo/ui/components/table';--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: [createCacheKeyForBookmarksTab(userId)],- });-- return (- <Table>- <TableHeader>- <TableRow>- <TableHead>Challenge</TableHead>- <TableHead>Bookmarked</TableHead>- </TableRow>- </TableHeader>- <TableBody>- {bookmarks.map((bookmark) => (- <TableRow key={bookmark.id}>- <TableCell className="font-medium underline">- {Boolean(bookmark.challenge) && (- <Link href={`/challenge/${bookmark.challenge?.slug}`}>- {bookmark.challenge?.name}- </Link>- )}- </TableCell>- <TableCell>- {Boolean(bookmark.createdAt) && getRelativeTime(bookmark.createdAt!)}- </TableCell>- </TableRow>- ))}- </TableBody>- </Table>- );-}--async function getBookmarkedChallenges(userId: string) {- return await prisma.bookmark.findMany({- where: { userId },- include: {- challenge: {- select: {- id: true,- slug: true,- name: true,- },- },- },- orderBy: {- createdAt: 'desc',- },- });-}diff --git a/apps/web/src/app/[locale]/[username]/_components/dashboard/challenge-history-columns.tsx b/apps/web/src/app/[locale]/[username]/_components/dashboard/challenge-history-columns.tsxdeleted file mode 100644index ed64264a..00000000--- a/apps/web/src/app/[locale]/[username]/_components/dashboard/challenge-history-columns.tsx+++ /dev/null@@ -1,27 +0,0 @@-'use client';--import { type ColumnDef } from '@tanstack/react-table';-import Link from 'next/link';-import { getRelativeTime } from '~/utils/relativeTime';--export interface Challenge {- id: number;- name: string;- slug: string;- submission: {- createdAt: Date;- }[];-}--export const columns: ColumnDef<Challenge>[] = [- {- accessorKey: 'challenge',- header: 'Challenge',- cell: ({ row }) => <Link href={`/challenge/${row.original.slug}`}>{row.original.name}</Link>,- },- {- accessorKey: 'lastSubmission',- header: 'Last Submission',- cell: ({ row }) => getRelativeTime(row.original.submission[0]!.createdAt),- },-];diff --git a/apps/web/src/app/[locale]/[username]/_components/dashboard/completed-tab.tsx b/apps/web/src/app/[locale]/[username]/_components/dashboard/completed-tab.tsxdeleted file mode 100644index 8d1d1d2d..00000000--- a/apps/web/src/app/[locale]/[username]/_components/dashboard/completed-tab.tsx+++ /dev/null@@ -1,48 +0,0 @@-import { prisma } from '@repo/db';-import { createCompletedSubmissionCacheKey } from '~/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/save-submission.action';-import { withUnstableCache } from '~/utils/withUnstableCache';-import ChallengeHistory from './challenge-history';--export async function CompletedTab({ userId }: { userId: string }) {- const challenges = await withUnstableCache({- fn: getCompletedChallenges,- args: [userId],- keys: [`completed-challenges`],- tags: [createCompletedSubmissionCacheKey(userId)],- });-- return <ChallengeHistory challenges={challenges} />;-}--async function getCompletedChallenges(userId: string) {- const challenges = await prisma.challenge.findMany({- where: {- submission: {- some: {- userId,- isSuccessful: true,- },- },- },- select: {- id: true,- slug: true,- name: true,- submission: {- orderBy: {- createdAt: 'desc',- },- take: 1,- select: {- createdAt: true,- },- },- },- });-- return challenges.sort(- (challengeA, challengeB) =>- new Date(challengeB.submission[0]!.createdAt).getTime() -- new Date(challengeA.submission[0]!.createdAt).getTime(),- );-}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.tsxdeleted file mode 100644index 40d0d837..00000000--- a/apps/web/src/app/[locale]/[username]/_components/dashboard/in-progress-tab.tsx+++ /dev/null@@ -1,54 +0,0 @@-import { prisma } from '@repo/db';-import { createInProgressSubmissionCacheKey } from '~/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/save-submission.action';-import { withUnstableCache } from '~/utils/withUnstableCache';-import ChallengeHistory from './challenge-history';--export async function InProgressTab({ userId }: { userId: string }) {- const challenges = await withUnstableCache({- fn: getInProgressChallenges,- args: [userId],- keys: [`in-progress-challenges`],- tags: [createInProgressSubmissionCacheKey(userId)],- });-- return <ChallengeHistory challenges={challenges} />;-}--async function getInProgressChallenges(userId: string) {- const challenges = await prisma.challenge.findMany({- where: {- AND: [- {- submission: {- none: {- userId,- isSuccessful: true,- },- },- },- // Make sure there is at least one submission- { submission: { some: { userId, isSuccessful: false } } },- ],- },- select: {- id: true,- slug: true,- name: true,- submission: {- orderBy: {- createdAt: 'desc',- },- take: 1,- select: {- createdAt: true,- },- },- },- });-- return challenges.sort(- (challengeA, challengeB) =>- new Date(challengeB.submission[0]!.createdAt).getTime() -- new Date(challengeA.submission[0]!.createdAt).getTime(),- );-}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.tsxdeleted file mode 100644index ad19b1a5..00000000--- a/apps/web/src/app/[locale]/[username]/_components/dashboard/shared-solutions-tab.tsx+++ /dev/null@@ -1,82 +0,0 @@-import Link from 'next/link';--import { prisma } from '@repo/db';-import {- Table,- TableBody,- TableCell,- TableHead,- TableHeader,- TableRow,-} from '@repo/ui/components/table';--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: [createCacheKeyForSharedSolutionsTab(userId)],- });-- return (- <Table>- <TableHeader>- <TableRow>- <TableHead>Title</TableHead>- <TableHead>Challenge</TableHead>- <TableHead>Votes</TableHead>- <TableHead>Date</TableHead>- </TableRow>- </TableHeader>- <TableBody>- {solutions.map((solution) => (- <TableRow key={solution.id}>- <TableCell className="font-medium underline">- <Link href={`/challenge/${solution.challenge?.slug}/solutions/${solution.id}`}>- {solution.title}- </Link>- </TableCell>- <TableCell className="font-medium underline">- <Link href={`/challenge/${solution.challenge?.slug}`}>- {solution.challenge?.name}- </Link>- </TableCell>- <TableCell>{solution._count.vote}</TableCell>- <TableCell className="font-medium">- {Boolean(solution.createdAt) && getRelativeTime(solution.createdAt)}- </TableCell>- </TableRow>- ))}- </TableBody>- </Table>- );-}--async function getSharedSolutions(userId: string) {- return await prisma.sharedSolution.findMany({- where: {- userId,- },- orderBy: {- createdAt: 'desc',- },- include: {- _count: {- select: {- vote: true,- },- },- challenge: {- select: {- id: true,- slug: true,- name: true,- },- },- },- });-}diff --git a/apps/web/src/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/cache-keys.ts b/apps/web/src/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/cache-keys.tsnew file mode 100644index 00000000..21e7248c--- /dev/null+++ b/apps/web/src/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/cache-keys.ts@@ -0,0 +1,11 @@+export const createChallengeSubmissionCacheKey = (slug: string) => {+ return `${slug}-challenge-submissions`;+};++export const createCompletedSubmissionCacheKey = (userId: string) => {+ return `${userId}-completed-challenges`;+};++export const createInProgressSubmissionCacheKey = (userId: string) => {+ return `${userId}-in-progress-challenges`;+};diff --git a/apps/web/src/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/page.tsx b/apps/web/src/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/page.tsxindex 4df1833c..dcc39bf1 100644--- a/apps/web/src/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/page.tsx+++ b/apps/web/src/app/[locale]/challenge/[slug]/submissions/[[...catchAll]]/page.tsx@@ -1,11 +1,11 @@-import { cache } from 'react';-import { prisma } from '@repo/db';import { getServerAuthSession } from '@repo/auth/server';+import { prisma } from '@repo/db';import { notFound, redirect } from 'next/navigation';-import { Submissions } from './_components';-import { withUnstableCache } from '~/utils/withUnstableCache';+import { cache } from 'react';import { isBetaUser } from '~/utils/server/is-beta-user';-import { createChallengeSubmissionCacheKey } from './save-submission.action';+import { withUnstableCache } from '~/utils/withUnstableCache';+import { Submissions } from './_components';+import { createChallengeSubmissionCacheKey } from './cache-keys';interface Props {params: {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.tsindex 76b6379b..73ecd185 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@@ -3,18 +3,11 @@ import { prisma } from '@repo/db';import { revalidateTag } from 'next/cache';import type { ChallengeRouteData } from '../../getChallengeRouteData';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`;-};--export const createCompletedSubmissionCacheKey = (userId: string) => {- return `${userId}-completed-challenges`;-};+import {+ createChallengeSubmissionCacheKey,+ createCompletedSubmissionCacheKey,+ createInProgressSubmissionCacheKey,+} from './cache-keys';interface Args {challenge: ChallengeRouteData['challenge'];diff --git a/apps/web/src/app/[locale]/challenge/_components/bookmark.action.ts b/apps/web/src/app/[locale]/challenge/_components/bookmark.action.tsindex 8a6970e9..c0b2927d 100644--- a/apps/web/src/app/[locale]/challenge/_components/bookmark.action.ts+++ b/apps/web/src/app/[locale]/challenge/_components/bookmark.action.ts@@ -1,4 +1,5 @@'use server';+import { prisma } from '@repo/db';import { revalidateTag } from 'next/cache';diff --git a/apps/web/src/app/[locale]/settings/_components/settings.tsx b/apps/web/src/app/[locale]/settings/_components/settings.tsxindex 772c9a9c..77a84b61 100644--- a/apps/web/src/app/[locale]/settings/_components/settings.tsx+++ b/apps/web/src/app/[locale]/settings/_components/settings.tsx@@ -3,6 +3,7 @@import Link from 'next/link';import type { User } from '@repo/db/types';+import { Card, CardContent, CardHeader, CardTitle } from '@repo/ui/components/card';import {Tabs,VerticalTabsContent,@@ -10,13 +11,8 @@ import {VerticalTabsTrigger,} from '@repo/ui/components/tabs';import { Settings2, User as UserIcon } from '@repo/ui/icons';-import { MagicIcon } from '@repo/ui/components/magic-icon';-import { Card, CardContent, CardHeader, CardTitle } from '@repo/ui/components/card';--import { getRelativeTime } from '~/utils/relativeTime';-import UserHeader from '~/app/[locale]/[username]/_components/dashboard/user-header';-import { stripProtocolAndWWW } from '~/utils/stringUtils';+import UserHeader from '../../(profile)/[username]/_components/dashboard/user-header';import { ProfileSettings } from './edit-profile-tab';interface Props {@@ -24,9 +20,6 @@ interface Props {}export const Settings = async ({ user }: Props) => {- const filteredProfileLinks =- user.userLinks.length > 0 ? user.userLinks.filter((item) => item.url !== '') : [];-return (<div className="container">{/* // TODO: GFI: make each page a subroute, put settings & profile into the same layout */}diff --git a/packages/ui/src/components/data-table.tsx b/packages/ui/src/components/data-table.tsxindex e8d2510f..febfaa4a 100644--- a/packages/ui/src/components/data-table.tsx+++ b/packages/ui/src/components/data-table.tsx@@ -62,14 +62,16 @@ export function DataTable<TData, TValue>({ columns, data }: DataTableProps<TData{headerGroup.headers.map((header) => {return (<TableHead key={header.id} onClick={header.column.getToggleSortingHandler()}>- <div className="flex items-center justify-between">+ <div className="relative">{header.isPlaceholder? null: flexRender(header.column.columnDef.header, header.getContext())}- {{- asc: <ChevronUp size={16} />,- desc: <ChevronDown size={16} />,- }[header.column.getIsSorted() as string] ?? null}+ <span className="absolute inset-y-0 right-0 flex items-center pr-2">+ {{+ asc: <ChevronUp size={16} />,+ desc: <ChevronDown size={16} />,+ }[header.column.getIsSorted() as string] ?? null}+ </span></div></TableHead>);