From 7580f4a56235fa6e41bfdf773e6adb529daa25bd Mon Sep 17 00:00:00 2001 From: Ahmed Elsakaan Date: Sun, 26 May 2024 01:37:12 +0100 Subject: [PATCH] feat: better auth routes organisation --- .../(auth)/sign-in/[[...sign-in]]/page.tsx | 0 .../(auth)/sign-up/[[...sign-in]]/page.tsx | 0 src/app/(dashboard)/layout.tsx | 20 ++++++++++++++ src/app/(marketing)/page.tsx | 11 +------- src/app/layout.tsx | 27 +++++++------------ src/middleware.ts | 8 ++++++ 6 files changed, 39 insertions(+), 27 deletions(-) rename src/app/{ => (dashboard)}/(auth)/sign-in/[[...sign-in]]/page.tsx (100%) rename src/app/{ => (dashboard)}/(auth)/sign-up/[[...sign-in]]/page.tsx (100%) create mode 100644 src/app/(dashboard)/layout.tsx diff --git a/src/app/(auth)/sign-in/[[...sign-in]]/page.tsx b/src/app/(dashboard)/(auth)/sign-in/[[...sign-in]]/page.tsx similarity index 100% rename from src/app/(auth)/sign-in/[[...sign-in]]/page.tsx rename to src/app/(dashboard)/(auth)/sign-in/[[...sign-in]]/page.tsx diff --git a/src/app/(auth)/sign-up/[[...sign-in]]/page.tsx b/src/app/(dashboard)/(auth)/sign-up/[[...sign-in]]/page.tsx similarity index 100% rename from src/app/(auth)/sign-up/[[...sign-in]]/page.tsx rename to src/app/(dashboard)/(auth)/sign-up/[[...sign-in]]/page.tsx diff --git a/src/app/(dashboard)/layout.tsx b/src/app/(dashboard)/layout.tsx new file mode 100644 index 00000000..5a0d04da --- /dev/null +++ b/src/app/(dashboard)/layout.tsx @@ -0,0 +1,20 @@ +import { TRPCReactProvider } from '@/lib/trpc/react'; +import { ClerkProvider } from '@clerk/nextjs'; +import { dark } from '@clerk/themes'; +import type { PropsWithChildren } from 'react'; + +/** + * The layout of the dashboard routes, this supplies the clerk & trpc providers mainly. + * @param props The props of the layout. + * @param props.children The children of the layout, which are all the routes under this route group. + * @returns A react component. + */ +export default function DashboardLayout({ children }: PropsWithChildren) { + return ( + + {children} + + ); +} diff --git a/src/app/(marketing)/page.tsx b/src/app/(marketing)/page.tsx index 61d99014..a2d1f764 100644 --- a/src/app/(marketing)/page.tsx +++ b/src/app/(marketing)/page.tsx @@ -1,7 +1,4 @@ import Link from 'next/link'; -import { redirect } from 'next/navigation'; - -import { currentUser } from '@clerk/nextjs/server'; import { ChevronRightIcon, StarIcon } from 'lucide-react'; import { constants } from '@/constants'; @@ -13,13 +10,7 @@ import { HomePreview } from './_components/home-preview'; * The marketing home page. * @returns A react component representing the marketing home page. */ -export default async function Home() { - const session = await currentUser(); - - if (session) { - redirect('/app'); - } - +export default function Home() { return (