From 8abc470297fa7a0c2531f14234540e952a1c2adb Mon Sep 17 00:00:00 2001 From: kapitulin24 Date: Wed, 29 Apr 2026 22:53:30 +0300 Subject: [PATCH] refactor: move team pages to protected routes and update navigation paths --- app/{team => (protected)}/layout.tsx | 0 app/{team => (protected)}/page.tsx | 0 app/{team => (protected)}/profile/page.tsx | 0 app/{team => (protected)}/projects/page.tsx | 0 app/{team => (protected)}/tasks/page.tsx | 0 proxy.ts | 4 ++-- src/pages/signin/ui/SigninPage.tsx | 2 +- src/pages/signup/ui/SignupPage.tsx | 2 +- src/shared/config/routes.ts | 9 +++------ src/widgets/app-sidebar/ui/AppSidebar.tsx | 6 +++--- src/widgets/app-sidebar/ui/NavUser.tsx | 2 +- 11 files changed, 11 insertions(+), 14 deletions(-) rename app/{team => (protected)}/layout.tsx (100%) rename app/{team => (protected)}/page.tsx (100%) rename app/{team => (protected)}/profile/page.tsx (100%) rename app/{team => (protected)}/projects/page.tsx (100%) rename app/{team => (protected)}/tasks/page.tsx (100%) diff --git a/app/team/layout.tsx b/app/(protected)/layout.tsx similarity index 100% rename from app/team/layout.tsx rename to app/(protected)/layout.tsx diff --git a/app/team/page.tsx b/app/(protected)/page.tsx similarity index 100% rename from app/team/page.tsx rename to app/(protected)/page.tsx diff --git a/app/team/profile/page.tsx b/app/(protected)/profile/page.tsx similarity index 100% rename from app/team/profile/page.tsx rename to app/(protected)/profile/page.tsx diff --git a/app/team/projects/page.tsx b/app/(protected)/projects/page.tsx similarity index 100% rename from app/team/projects/page.tsx rename to app/(protected)/projects/page.tsx diff --git a/app/team/tasks/page.tsx b/app/(protected)/tasks/page.tsx similarity index 100% rename from app/team/tasks/page.tsx rename to app/(protected)/tasks/page.tsx diff --git a/proxy.ts b/proxy.ts index 3c4ae27..eefe91b 100644 --- a/proxy.ts +++ b/proxy.ts @@ -5,7 +5,7 @@ import type { Route } from 'next'; const REFRESH_COOKIE = 'refresh'; -const PROTECTED_PREFIXES = [routes.team.root()]; +const PROTECTED_PREFIXES = [routes.profile(), routes.projects(), routes.tasks()]; const PUBLIC_ONLY_ROUTES = [routes.auth.signin(), routes.auth.signup()]; function startsWithOneOf(pathname: string, prefixes: string[]) { @@ -25,7 +25,7 @@ export function proxy(req: NextRequest) { } if (isPublicOnly && hasRefreshCookie) { - return NextResponse.redirect(new URL(routes.team.root(), req.url)); + return NextResponse.redirect(new URL(routes.profile(), req.url)); } return NextResponse.next(); diff --git a/src/pages/signin/ui/SigninPage.tsx b/src/pages/signin/ui/SigninPage.tsx index 46160cb..6be7340 100644 --- a/src/pages/signin/ui/SigninPage.tsx +++ b/src/pages/signin/ui/SigninPage.tsx @@ -21,7 +21,7 @@ function SigninPage() { onSuccess={(_, res) => { if (res.success) { AccessToken.token = res.token; - router.replace(routes.team.profile()); + router.replace(routes.profile()); if (res.message) { toast.success(res.message); } diff --git a/src/pages/signup/ui/SignupPage.tsx b/src/pages/signup/ui/SignupPage.tsx index a85c79e..d1a5771 100644 --- a/src/pages/signup/ui/SignupPage.tsx +++ b/src/pages/signup/ui/SignupPage.tsx @@ -60,7 +60,7 @@ function SignupPage() { if (res.success) { clearDraft(); AccessToken.token = res.token; - router.replace(routes.team.profile()); + router.replace(routes.profile()); if (res.message) { toast.success(res.message); } diff --git a/src/shared/config/routes.ts b/src/shared/config/routes.ts index 7090c8c..73b00d7 100644 --- a/src/shared/config/routes.ts +++ b/src/shared/config/routes.ts @@ -2,15 +2,12 @@ import type { Route } from 'next'; export const routes = { home: (): Route => '/', + profile: (): Route => '/profile', + projects: (): Route => '/projects', + tasks: (): Route => '/tasks', auth: { signin: (): Route => '/signin', signup: (): Route => '/signup', forgotPassword: (): Route => '/forgot-password', }, - team: { - root: (): Route => '/team', - projects: (): Route => '/team/projects', - profile: (): Route => '/team/profile', - tasks: (): Route => '/team/tasks', - }, } as const; diff --git a/src/widgets/app-sidebar/ui/AppSidebar.tsx b/src/widgets/app-sidebar/ui/AppSidebar.tsx index 87b7fa2..193eee4 100644 --- a/src/widgets/app-sidebar/ui/AppSidebar.tsx +++ b/src/widgets/app-sidebar/ui/AppSidebar.tsx @@ -60,7 +60,7 @@ export function AppSidebar({ ...props }: React.ComponentProps) { - + Мой профиль @@ -68,7 +68,7 @@ export function AppSidebar({ ...props }: React.ComponentProps) { - + Мои задачи @@ -76,7 +76,7 @@ export function AppSidebar({ ...props }: React.ComponentProps) { - + Мои Проекты diff --git a/src/widgets/app-sidebar/ui/NavUser.tsx b/src/widgets/app-sidebar/ui/NavUser.tsx index b5fda9f..347d9c7 100644 --- a/src/widgets/app-sidebar/ui/NavUser.tsx +++ b/src/widgets/app-sidebar/ui/NavUser.tsx @@ -74,7 +74,7 @@ export function NavUser({ - Account + Account