From 2405f9cab2722c431a95cd395c5d8ed17705dd8b Mon Sep 17 00:00:00 2001 From: ramvignesh-b Date: Mon, 13 Apr 2026 01:05:03 +0530 Subject: [PATCH] refactor: migrate route definitions to path builders --- frontend/src/App.tsx | 2 +- frontend/src/components/ui/LetterItem.tsx | 6 +++--- frontend/src/config/routes.ts | 12 ++++++++++-- frontend/src/pages/Drawer.tsx | 4 ++-- frontend/src/pages/Editor.tsx | 4 ++-- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 743df02..da0c788 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -72,7 +72,7 @@ export default function App() { } /> diff --git a/frontend/src/components/ui/LetterItem.tsx b/frontend/src/components/ui/LetterItem.tsx index de11df0..a512193 100644 --- a/frontend/src/components/ui/LetterItem.tsx +++ b/frontend/src/components/ui/LetterItem.tsx @@ -1,5 +1,5 @@ import { useNavigate } from "react-router-dom"; -import { ROUTES } from "../../config/routes"; +import { PATHS } from "../../config/routes"; export function LetterItem({ preview, @@ -15,9 +15,9 @@ export function LetterItem({ const navigate = useNavigate(); function handleNavigate(): void { if (status === "SEALED") { - navigate(ROUTES.READ(id)); + navigate(PATHS.read(id)); } else { - navigate(ROUTES.WRITE(id)); + navigate(PATHS.write(id)); } } diff --git a/frontend/src/config/routes.ts b/frontend/src/config/routes.ts index c0d52ac..1aa1b61 100644 --- a/frontend/src/config/routes.ts +++ b/frontend/src/config/routes.ts @@ -1,3 +1,4 @@ +// Route PATTERNS export const ROUTES = { HOME: "/", ONBOARD: "/onboard", @@ -5,6 +6,13 @@ export const ROUTES = { ACTIVATE: "/activate/:uidb64/:token", LOGIN: "/login", DRAWER: "/drawer", - WRITE: (public_id?: string) => `/quill/${public_id ? public_id : ""}`, - READ: (public_id?: string) => `/read/${public_id ? public_id : ""}`, + WRITE: "/quill/:public_id?", // ← static pattern + READ: "/read/:public_id", +}; + +// Path BUILDERS +export const PATHS = { + write: (public_id?: string) => `/quill/${public_id ?? ""}`, + read: (public_id: string) => `/read/${public_id}`, + activate: (uidb64: string, token: string) => `/activate/${uidb64}/${token}`, }; diff --git a/frontend/src/pages/Drawer.tsx b/frontend/src/pages/Drawer.tsx index cb6949f..a72262c 100644 --- a/frontend/src/pages/Drawer.tsx +++ b/frontend/src/pages/Drawer.tsx @@ -4,7 +4,7 @@ import { useNavigate } from "react-router-dom"; import Logo from "../components/Logo"; import { DrawerSection } from "../components/ui/Drawer"; import { LetterItem } from "../components/ui/LetterItem"; -import { ROUTES } from "../config/routes"; +import { PATHS } from "../config/routes"; import { useAuth } from "../hooks/useAuth"; import { useLetters } from "../hooks/useLetters"; @@ -127,7 +127,7 @@ export default function Drawer() {