Skip to content

Consolidate legacy routes into [locale], remove formar.tsx, run hardcoded-string check in CI - #1557

Merged
mftee merged 1 commit into
CodeGirlsInc:mainfrom
Diggardson270:main
Oct 22, 2026
Merged

mftee merged 1 commit into
CodeGirlsInc:mainfrom
Diggardson270:main

Conversation

@Diggardson270

Copy link
Copy Markdown
Contributor

Issues

Closes #1516
Closes #1517
Closes #1518


#1516 — Move the duplicate non-localised pages into the [locale] tree

Every page now lives under app/[locale]/. With localePrefix: "as-needed", English URLs stay the same and the [locale] page serves them.

Moved and translated

These pages were moved into app/[locale]/(protected)/ with git mv, so history is kept. All their copy is now translated:

Route Translation namespace
documents/[id] (+ not-found) documentDetail, notFound.*
documents/[id]/report documentReport
documents/[id]/verify documentVerify
map map
admin/activity adminActivity
admin/audit-logs adminAuditLogs
  • The new keys are added to en, fr and es (check:locales passes, 336 keys).
  • Dates now use the active locale through useDateFormatting (some were hard-coded to en-GB).
  • Links now use the locale-aware Link / useRouter from @/i18n/navigation.

API helpers

  • documents/[id], report and verify called ${API_BASE}/api/documents/... without the v1 prefix and read the token from localStorage by hand.
  • They now use request(apiUrl(...)) from lib/api-client, so they hit /api/v1/... and get refresh-on-401 like the other localised pages.
  • Error messages are now translated generic messages instead of raw status text.
  • map, activity and audit-logs already used apiUrl, so only their copy changed.

Deleted duplicates

  • app/(protected)/admin/users/page.tsx and its layout.tsx: superseded by the full [locale] admin users page.
  • app/document/[id]/page.tsx: a second detail page that didn't compile (missing ui/separator, @tanstack/react-query not installed).
  • app/register/page.tsx: a stub that only redirected to /en/register.
  • app/auth/oauth/callback/page.tsx: used a code exchange flow, but the backend (auth.controller.ts → redirectWithCookies) sends the token in the URL hash, which only the [locale] callback handles.

Redirects

  • /document/... is the only old URL whose path changed.
  • middleware.ts now 308-redirects /document/:id(/...) to /documents/:id(/...), keeping the locale prefix and query string.
  • The redirect runs before the auth check, and the target route is still protected.
  • Other moves can be added to LEGACY_ROUTE_REDIRECTS.

Tests

  • middleware.test.ts was already failing on main: the next-intl/middleware mock returned a response instead of a middleware function. Fixed the mock and added redirect tests (12/12 pass).
  • admin-audit-logs.test.tsx and not-found.test.tsx now import the moved files; the audit-logs test renders inside NextIntlClientProvider.
  • Added an e2e smoke test: /document/abc ends at /login?redirect=/documents/abc.

#1517 — Remove components/formar.tsx

  • formar.tsx was byte-identical to ErrorBanner.tsx (diff is empty), so there was nothing to merge.
  • Deleted it; nothing referenced it.

#1518 — Run check:hardcoded in CI and drop the duplicate typecheck

scripts/check-hardcoded-strings.mjs

  • Now compares against scripts/hardcoded-strings-baseline.json (18 existing violations) and exits 1 only on strings not in the baseline.
  • Entries are keyed by file and text, not line number, so unrelated edits don't break the baseline.
  • --update-baseline regenerates the file, and the script prints a reminder when baselined strings get translated.
  • Test files and test-utils/ are skipped, since fixtures aren't user-facing.
  • In GitHub Actions, new violations also show as annotations.

.github/workflows/ci.yml

  • New Check hardcoded strings step after the locale check, with continue-on-error: true while the regex heuristic beds in. Remove that line to make it blocking.
  • Removed the second Typecheck step after the build; the one before the build stays.

Docs

  • frontend/README.md gains a "Routing and i18n" section on the [locale]-only rule, legacy redirects and the baseline workflow.

Testing

  • npm run check:locales passes.
  • npm run check:hardcoded passes on the tree. A probe file with a new hardcoded string makes it exit 1.
  • npx jest: 15 failing suites vs 16 on main. middleware.test.ts now passes and nothing new fails. The remaining failures are the same ones as on main (missing @testing-library/user-event / @radix-ui/react-dialog installs, auth-session test drift).
  • tsc --noEmit: no new errors. The two MapPageContent errors moved with the file, and deleting app/document/[id] removes one error.
  • E2E smoke: not run locally because of a stale node_modules; needs a CI run or a local run after npm ci.

@vercel

vercel Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

@Diggardson270 is attempting to deploy a commit to the Mftee's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Oct 22, 2026

Copy link
Copy Markdown

@Diggardson270 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@mftee
mftee merged commit dea6f9d into CodeGirlsInc:main Oct 22, 2026
0 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants