feat: route architecture — public/auth/dashboard groups with placehol…#246
Conversation
📝 WalkthroughWalkthroughThis pull request adds eleven "Coming Soon" placeholder page components across public, dashboard, and route groups, introduces a public layout component for wrapping shared structure, and includes a Node.js scaffolding script that auto-generates route directories and templates while removing previously existing route paths. Changes
Poem
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
scripts/scaffold-routes.js (1)
172-179: Consider guarding destructive cleanup behind an explicit CLI flag.Cleanup currently always runs after scaffolding. A
--cleanupopt-in would make scaffold-only runs safer for local/dev workflows.Suggested diff
-console.log("Cleaning up old routes..."); -for (const p of toDelete) { - const fullPath = path.join(APP_DIR, p); - if (fs.existsSync(fullPath)) { - fs.rmSync(fullPath, { recursive: true, force: true }); - console.log('Deleted old route: ' + fullPath); - } -} +const shouldCleanup = process.argv.includes('--cleanup'); +if (shouldCleanup) { + console.log("Cleaning up old routes..."); + for (const p of toDelete) { + const fullPath = path.join(APP_DIR, p); + if (fs.existsSync(fullPath)) { + fs.rmSync(fullPath, { recursive: true, force: true }); + console.log('Deleted old route: ' + fullPath); + } + } +} else { + console.log("Skipping cleanup (pass --cleanup to enable)."); +}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@scripts/scaffold-routes.js` around lines 172 - 179, The cleanup loop that removes paths from toDelete using fs.rmSync (inside scripts/scaffold-routes.js referencing APP_DIR and toDelete) should be gated behind an explicit CLI flag (e.g., --cleanup) rather than always running; detect the flag via process.argv.includes('--cleanup') or your CLI parser, and only execute the console.log("Cleaning up old routes...") / for (const p of toDelete) { ... fs.rmSync(...) } block when that flag is present, otherwise skip deletion and log that cleanup was skipped to make scaffold-only runs safe for local/dev workflows.apps/web/src/app/(public)/merchants/page.tsx (1)
1-5: Extract a sharedComingSoonPagecomponent for repeated placeholders.Lines 1–5 repeat the same structure used across many new routes. Consider moving this UI into a reusable component (e.g.,
ComingSoonPagewith atitleprop) to avoid copy/paste drift and simplify future updates.♻️ Proposed refactor
- export default function PageName() { - return ( - <div className="flex items-center justify-center min-h-screen"> - <h1 className="text-2xl font-semibold">Merchant Directory — Coming Soon</h1> - </div> - ); - } +import { ComingSoonPage } from "@/components/coming-soon-page"; + +export default function MerchantsPage() { + return <ComingSoonPage title="Merchant Directory" />; +}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/web/src/app/`(public)/merchants/page.tsx around lines 1 - 5, Extract the repeated placeholder UI into a reusable ComingSoonPage component that accepts a title prop: create a new component (e.g., ComingSoonPage) which renders the shared div and h1 structure, then update the existing PageName component to return <ComingSoonPage title="Merchant Directory — Coming Soon" /> (or equivalent) so PageName only delegates to ComingSoonPage; ensure the new component is exported and imported where needed and remove the duplicated JSX from PageName.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@scripts/scaffold-routes.js`:
- Around line 161-179: The script is deleting legacy routes listed in the
toDelete array inside scripts/scaffold-routes.js which are still referenced by
UI components (merchant-sidebar.tsx, buyer-sidebar.tsx, product-detail-view.tsx,
product-card.tsx), causing 404s; either remove those entries from the toDelete
array or update the components to stop referencing those paths, or add
server-side/client-side redirects for each path; locate the toDelete constant
and the for loop that calls fs.rmSync and then update the array or implement
redirects and update the referenced components (merchant-sidebar, buyer-sidebar,
product-detail-view, product-card) in the same PR so navigation remains valid.
- Line 83: The route segment '_at_[slug]' (pageTemplate('Merchant Store'))
currently generates URLs under '/_at_/:slug' but needs to be served at public
'/@:slug' URLs; fix by adding a rewrite in next.config.mjs that maps '/@:slug' →
'/_at_/:slug' (or alternatively implement a middleware that rewrites requests
from '/@:slug' to '/_at_/:slug' or rename the segment to escape '@' if
supported), and verify the rewrite covers dynamic slugs so the
pageTemplate('Merchant Store') route is reachable at '/@:slug'.
---
Nitpick comments:
In `@apps/web/src/app/`(public)/merchants/page.tsx:
- Around line 1-5: Extract the repeated placeholder UI into a reusable
ComingSoonPage component that accepts a title prop: create a new component
(e.g., ComingSoonPage) which renders the shared div and h1 structure, then
update the existing PageName component to return <ComingSoonPage title="Merchant
Directory — Coming Soon" /> (or equivalent) so PageName only delegates to
ComingSoonPage; ensure the new component is exported and imported where needed
and remove the duplicated JSX from PageName.
In `@scripts/scaffold-routes.js`:
- Around line 172-179: The cleanup loop that removes paths from toDelete using
fs.rmSync (inside scripts/scaffold-routes.js referencing APP_DIR and toDelete)
should be gated behind an explicit CLI flag (e.g., --cleanup) rather than always
running; detect the flag via process.argv.includes('--cleanup') or your CLI
parser, and only execute the console.log("Cleaning up old routes...") / for
(const p of toDelete) { ... fs.rmSync(...) } block when that flag is present,
otherwise skip deletion and log that cleanup was skipped to make scaffold-only
runs safe for local/dev workflows.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 7307846f-2f6f-4c92-ad17-356e1fdfe035
📒 Files selected for processing (13)
apps/web/src/app/(dashboard)/admin/dashboard/page.tsxapps/web/src/app/(public)/_at_[slug]/page.tsxapps/web/src/app/(public)/about/page.tsxapps/web/src/app/(public)/c/[category]/page.tsxapps/web/src/app/(public)/contact/page.tsxapps/web/src/app/(public)/explore/page.tsxapps/web/src/app/(public)/help/page.tsxapps/web/src/app/(public)/layout.tsxapps/web/src/app/(public)/merchants/page.tsxapps/web/src/app/(public)/p/[code]/page.tsxapps/web/src/app/(public)/privacy/page.tsxapps/web/src/app/(public)/terms/page.tsxscripts/scaffold-routes.js
| 'layout.tsx': publicLayout, | ||
| explore: { 'page.tsx': pageTemplate('Explore') }, | ||
| p: { '[code]': { 'page.tsx': pageTemplate('Product Detail') } }, | ||
| '_at_[slug]': { 'page.tsx': pageTemplate('Merchant Store') }, |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "1) Find route/rewrite config related to merchant slug paths"
fd -HI "next.config.*" | xargs -r rg -n "rewrites|redirects|_at_|@|merchant|slug"
echo "2) Find app links/usages targeting old/new merchant public paths"
rg -n "/@|/_at_|_at_\\[slug\\]|/m/|m/\\[slug\\]" apps/web/srcRepository: coded-devs/twizrr
Length of output: 441
🏁 Script executed:
cat -n scripts/scaffold-routes.js | head -100Repository: coded-devs/twizrr
Length of output: 3423
🏁 Script executed:
cat -n next.config.jsRepository: coded-devs/twizrr
Length of output: 107
🏁 Script executed:
rg -n "_at_" apps/web/src --type ts --type tsxRepository: coded-devs/twizrr
Length of output: 88
🏁 Script executed:
fd -HI "next.config" .Repository: coded-devs/twizrr
Length of output: 87
🏁 Script executed:
rg "_at_" apps/web/src --max-count 10Repository: coded-devs/twizrr
Length of output: 43
🏁 Script executed:
cat -n apps/web/src/middleware.ts 2>/dev/null || echo "No middleware.ts found"Repository: coded-devs/twizrr
Length of output: 83
🏁 Script executed:
cat -n apps/web/next.config.mjsRepository: coded-devs/twizrr
Length of output: 1111
🏁 Script executed:
rg "scaffold-routes" . --max-count 5Repository: coded-devs/twizrr
Length of output: 43
🏁 Script executed:
rg "@" apps/web/src/app --type-not min -A 2 -B 2 | grep -E "(/@|merchant|slug)" | head -20Repository: coded-devs/twizrr
Length of output: 88
🏁 Script executed:
cat apps/web/package.json | grep -A 10 "scripts"Repository: coded-devs/twizrr
Length of output: 352
🏁 Script executed:
find apps/web/src/app -name "_at_*" -o -name "@*"Repository: coded-devs/twizrr
Length of output: 97
🏁 Script executed:
ls -la apps/web/src/app/\(public\)/ 2>/dev/null | head -20Repository: coded-devs/twizrr
Length of output: 787
🏁 Script executed:
find apps/web -name "middleware*" -o -name "*rewrite*" -o -name "*redirect*" 2>/dev/nullRepository: coded-devs/twizrr
Length of output: 43
Fix route naming: _at_[slug] should use rewrites to serve at @[slug] public URLs.
The route segment _at_[slug] creates URLs at /_at_/slug, but marketing promises @yourname format. No rewrites or middleware currently exist to convert /_at_/ to @/, making intended public URLs unreachable. Either:
- Add rewrites in
next.config.mjsto map/@/:slug→/_at_/:slug, or - Use a middleware to handle the rewrite, or
- Rename the route segment if
@can be accommodated with proper escaping.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@scripts/scaffold-routes.js` at line 83, The route segment '_at_[slug]'
(pageTemplate('Merchant Store')) currently generates URLs under '/_at_/:slug'
but needs to be served at public '/@:slug' URLs; fix by adding a rewrite in
next.config.mjs that maps '/@:slug' → '/_at_/:slug' (or alternatively implement
a middleware that rewrites requests from '/@:slug' to '/_at_/:slug' or rename
the segment to escape '@' if supported), and verify the rewrite covers dynamic
slugs so the pageTemplate('Merchant Store') route is reachable at '/@:slug'.
| const toDelete = [ | ||
| 'buyer/catalogue', | ||
| 'buyer/products/[id]', | ||
| 'buyer/merchants/[id]', | ||
| 'buyer/merchants', | ||
| 'm/[slug]', | ||
| 'merchant/wholesale', | ||
| 'merchant/procurement', | ||
| 'merchant/trade-financing' | ||
| ]; | ||
|
|
||
| console.log("Cleaning up old routes..."); | ||
| for (const p of toDelete) { | ||
| const fullPath = path.join(APP_DIR, p); | ||
| if (fs.existsSync(fullPath)) { | ||
| fs.rmSync(fullPath, { recursive: true, force: true }); | ||
| console.log('Deleted old route: ' + fullPath); | ||
| } | ||
| } |
There was a problem hiding this comment.
Deleting legacy routes here will break existing in-app navigation.
Line 162–169 removes paths still referenced by links in apps/web/src/components/layout/merchant-sidebar.tsx:1-50, apps/web/src/components/layout/buyer-sidebar.tsx:1-50, apps/web/src/components/shared/product-detail-view.tsx:1-50, and apps/web/src/components/shared/product-card.tsx:1-50. That will create user-facing 404s. Please update those links or add redirects in the same PR.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@scripts/scaffold-routes.js` around lines 161 - 179, The script is deleting
legacy routes listed in the toDelete array inside scripts/scaffold-routes.js
which are still referenced by UI components (merchant-sidebar.tsx,
buyer-sidebar.tsx, product-detail-view.tsx, product-card.tsx), causing 404s;
either remove those entries from the toDelete array or update the components to
stop referencing those paths, or add server-side/client-side redirects for each
path; locate the toDelete constant and the for loop that calls fs.rmSync and
then update the array or implement redirects and update the referenced
components (merchant-sidebar, buyer-sidebar, product-detail-view, product-card)
in the same PR so navigation remains valid.
Summary by CodeRabbit
New Features
Chores