From c1c720652555de786b3e3fa60803c45b7838bccf Mon Sep 17 00:00:00 2001 From: cte Date: Mon, 12 May 2025 00:17:15 -0700 Subject: [PATCH] Organize routes --- src/app/(auth)/(center)/layout.tsx | 18 ------ src/app/(auth)/dashboard/page.tsx | 56 ------------------- src/app/(auth)/layout.tsx | 26 --------- .../dashboard/layout.tsx | 0 .../[[...organization-profile]]/page.tsx | 6 +- src/app/(authenticated)/dashboard/page.tsx | 37 ++++++++++++ .../user-profile/[[...user-profile]]/page.tsx | 14 +---- src/app/(authenticated)/layout.tsx | 16 ++++++ .../organization-selection/page.tsx | 0 src/app/layout.tsx | 6 +- src/app/{(unauth) => }/page.tsx | 17 ++++-- .../sign-in/[[...sign-in]]/page.tsx | 10 +++- .../sign-up/[[...sign-up]]/page.tsx | 10 +++- src/components/dashboard/DashboardHeader.tsx | 4 ++ src/components/dashboard/MessageState.tsx | 23 -------- src/i18n/locales/en.json | 5 +- src/i18n/locales/fr.json | 5 +- 17 files changed, 94 insertions(+), 159 deletions(-) delete mode 100644 src/app/(auth)/(center)/layout.tsx delete mode 100644 src/app/(auth)/dashboard/page.tsx delete mode 100644 src/app/(auth)/layout.tsx rename src/app/{(auth) => (authenticated)}/dashboard/layout.tsx (100%) rename src/app/{(auth) => (authenticated)}/dashboard/organization-profile/[[...organization-profile]]/page.tsx (88%) create mode 100644 src/app/(authenticated)/dashboard/page.tsx rename src/app/{(auth) => (authenticated)}/dashboard/user-profile/[[...user-profile]]/page.tsx (67%) create mode 100644 src/app/(authenticated)/layout.tsx rename src/app/{(auth) => (authenticated)}/onboarding/organization-selection/page.tsx (100%) rename src/app/{(unauth) => }/page.tsx (70%) rename src/app/{(auth)/(center) => }/sign-in/[[...sign-in]]/page.tsx (68%) rename src/app/{(auth)/(center) => }/sign-up/[[...sign-up]]/page.tsx (68%) delete mode 100644 src/components/dashboard/MessageState.tsx diff --git a/src/app/(auth)/(center)/layout.tsx b/src/app/(auth)/(center)/layout.tsx deleted file mode 100644 index a0b4c0d8a1..0000000000 --- a/src/app/(auth)/(center)/layout.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import { auth } from '@clerk/nextjs/server'; -import { redirect } from 'next/navigation'; - -export default async function CenteredLayout(props: { - children: React.ReactNode; -}) { - const { userId } = await auth(); - - if (userId) { - redirect('/dashboard'); - } - - return ( -
- {props.children} -
- ); -} diff --git a/src/app/(auth)/dashboard/page.tsx b/src/app/(auth)/dashboard/page.tsx deleted file mode 100644 index 003ab79f0e..0000000000 --- a/src/app/(auth)/dashboard/page.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import { useTranslations } from 'next-intl'; - -import { MessageState } from '@/components/dashboard/MessageState'; -import { TitleBar } from '@/components/dashboard/TitleBar'; - -const DashboardIndexPage = () => { - const t = useTranslations('DashboardIndex'); - - return ( - <> - - - - - - - } - title={t('message_state_title')} - description={t.rich('message_state_description', { - code: (chunks) => ( - - {chunks} - - ), - })} - button={ -
- {t.rich('message_state_alternative', { - url: () => ( - - Next.js Boilerplate SaaS - - ), - })} -
- } - /> - - ); -}; - -export default DashboardIndexPage; diff --git a/src/app/(auth)/layout.tsx b/src/app/(auth)/layout.tsx deleted file mode 100644 index 2b4f153642..0000000000 --- a/src/app/(auth)/layout.tsx +++ /dev/null @@ -1,26 +0,0 @@ -'use client'; - -import { enUS, frFR } from '@clerk/localizations'; -import { ClerkProvider } from '@clerk/nextjs'; -import { useLocale } from 'next-intl'; - -export default function AuthLayout({ - children, -}: { - children: React.ReactNode; -}) { - const locale = useLocale(); - - return ( - - {children} - - ); -} diff --git a/src/app/(auth)/dashboard/layout.tsx b/src/app/(authenticated)/dashboard/layout.tsx similarity index 100% rename from src/app/(auth)/dashboard/layout.tsx rename to src/app/(authenticated)/dashboard/layout.tsx diff --git a/src/app/(auth)/dashboard/organization-profile/[[...organization-profile]]/page.tsx b/src/app/(authenticated)/dashboard/organization-profile/[[...organization-profile]]/page.tsx similarity index 88% rename from src/app/(auth)/dashboard/organization-profile/[[...organization-profile]]/page.tsx rename to src/app/(authenticated)/dashboard/organization-profile/[[...organization-profile]]/page.tsx index a6a582c118..b458d2e6f8 100644 --- a/src/app/(auth)/dashboard/organization-profile/[[...organization-profile]]/page.tsx +++ b/src/app/(authenticated)/dashboard/organization-profile/[[...organization-profile]]/page.tsx @@ -3,7 +3,7 @@ import { useTranslations } from 'next-intl'; import { TitleBar } from '@/components/dashboard/TitleBar'; -const OrganizationProfilePage = () => { +export default function Page() { const t = useTranslations('OrganizationProfile'); return ( @@ -26,6 +26,4 @@ const OrganizationProfilePage = () => { /> ); -}; - -export default OrganizationProfilePage; +} diff --git a/src/app/(authenticated)/dashboard/page.tsx b/src/app/(authenticated)/dashboard/page.tsx new file mode 100644 index 0000000000..7b2c42d5bd --- /dev/null +++ b/src/app/(authenticated)/dashboard/page.tsx @@ -0,0 +1,37 @@ +import { useTranslations } from 'next-intl'; + +import { TitleBar } from '@/components/dashboard/TitleBar'; + +const DashboardIndexPage = () => { + const t = useTranslations('DashboardIndex'); + + return ( + <> + +
+
+ + + + +
+
+
+ {t('message_state_title')} +
+
+
+ + ); +}; + +export default DashboardIndexPage; diff --git a/src/app/(auth)/dashboard/user-profile/[[...user-profile]]/page.tsx b/src/app/(authenticated)/dashboard/user-profile/[[...user-profile]]/page.tsx similarity index 67% rename from src/app/(auth)/dashboard/user-profile/[[...user-profile]]/page.tsx rename to src/app/(authenticated)/dashboard/user-profile/[[...user-profile]]/page.tsx index 981c618f43..e10967b15d 100644 --- a/src/app/(auth)/dashboard/user-profile/[[...user-profile]]/page.tsx +++ b/src/app/(authenticated)/dashboard/user-profile/[[...user-profile]]/page.tsx @@ -3,7 +3,7 @@ import { useTranslations } from 'next-intl'; import { TitleBar } from '@/components/dashboard/TitleBar'; -const UserProfilePage = () => { +export default function Page() { const t = useTranslations('UserProfile'); return ( @@ -12,19 +12,11 @@ const UserProfilePage = () => { title={t('title_bar')} description={t('title_bar_description')} /> - ); -}; - -export default UserProfilePage; +} diff --git a/src/app/(authenticated)/layout.tsx b/src/app/(authenticated)/layout.tsx new file mode 100644 index 0000000000..5abcbb091f --- /dev/null +++ b/src/app/(authenticated)/layout.tsx @@ -0,0 +1,16 @@ +import { redirect } from 'next/navigation'; +import { auth as clerkAuth } from '@clerk/nextjs/server'; + +export default async function CenteredLayout({ + children, +}: { + children: React.ReactNode; +}) { + const auth = await clerkAuth(); + + if (!auth.userId) { + redirect('/'); + } + + return children; +} diff --git a/src/app/(auth)/onboarding/organization-selection/page.tsx b/src/app/(authenticated)/onboarding/organization-selection/page.tsx similarity index 100% rename from src/app/(auth)/onboarding/organization-selection/page.tsx rename to src/app/(authenticated)/onboarding/organization-selection/page.tsx diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 904f5bde22..0f74245c78 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -3,6 +3,8 @@ import '@/styles/globals.css'; import type { Metadata } from 'next'; import { NextIntlClientProvider } from 'next-intl'; import { getLocale } from 'next-intl/server'; +import { enUS, frFR } from '@clerk/localizations'; +import { ClerkProvider } from '@clerk/nextjs'; import { ThemeProvider } from '@/components/ThemeProvider'; @@ -45,7 +47,9 @@ export default async function RootLayout({ enableSystem disableTransitionOnChange > - {children} + + {children} + diff --git a/src/app/(unauth)/page.tsx b/src/app/page.tsx similarity index 70% rename from src/app/(unauth)/page.tsx rename to src/app/page.tsx index 71c5fdb064..bc2affdd11 100644 --- a/src/app/(unauth)/page.tsx +++ b/src/app/page.tsx @@ -1,9 +1,11 @@ +import { auth as clerkAuth } from '@clerk/nextjs/server'; import { getLocale, getTranslations, setRequestLocale } from 'next-intl/server'; import { Features } from '@/components/templates/Features'; import { Footer } from '@/components/templates/Footer'; import { Hero } from '@/components/templates/Hero'; import { Navbar } from '@/components/templates/Navbar'; +import { redirect } from 'next/navigation'; export async function generateMetadata() { const locale = await getLocale(); @@ -15,9 +17,14 @@ export async function generateMetadata() { }; } -const IndexPage = async () => { - const locale = await getLocale(); - setRequestLocale(locale); +export default async function Page() { + const auth = await clerkAuth(); + + if (auth.userId) { + redirect('/dashboard'); + } + + setRequestLocale(await getLocale()); return ( <> @@ -27,6 +34,4 @@ const IndexPage = async () => {