Skip to content

feat(dashboard): unified role-based dashboard shell, guard, and quick actions (closes #42)#57

Merged
Obiajulu-gif merged 4 commits into
Chainmove:mainfrom
pope-h:feat/role-based-dashboard-shell
Jun 21, 2026
Merged

feat(dashboard): unified role-based dashboard shell, guard, and quick actions (closes #42)#57
Obiajulu-gif merged 4 commits into
Chainmove:mainfrom
pope-h:feat/role-based-dashboard-shell

Conversation

@pope-h

@pope-h pope-h commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #42.

Builds a unified, reusable role-based dashboard shell so contributors can add new dashboard modules without duplicating layout or authorization logic. ChainMove already had a role-aware Sidebar, Header, and DashboardShell, but route guarding, loading/unauthorized states, and quick actions were re-implemented inline in each role's layout/page with no shared role config. This PR consolidates that into one system.

New reusable primitives

  • lib/dashboard/roles.ts — single source of truth for dashboard roles: labels, home paths, and per-role quick action slots. Exposes isDashboardRole, getDashboardRoleConfig, resolveAllowedRoles, and getDashboardHomePath.
  • DashboardGuard (components/dashboard/dashboard-guard.tsx) — client route guard for role-protected sections. Renders a graceful loading state, redirects unauthenticated visitors to sign in, and shows a recoverable unauthorized view for the wrong role. Layers on top of the existing edge authentication in proxy.ts (which handles authentication for /dashboard/*).
  • DashboardUnauthorized — shared, recoverable access-denied view (offers a link back to the user's own dashboard).
  • DashboardQuickActions — renders per-role quick action slots in dashboard headers.
  • requireDashboardSession (lib/auth/dashboard-guard.ts) — server-side counterpart for server components/route handlers.

Wired existing sections to the unified system (no behavior/route changes)

  • Admin layout now wraps content in DashboardGuard (replaces bespoke inline guard).
  • Driver page (server component) uses requireDashboardSession("driver").
  • Investor page renders the shared DashboardUnauthorized state.
  • Shared Header surfaces per-role quick action slots.

Acceptance criteria

  • Reusable role-based dashboard shell exists
  • Navigation changes based on user role (existing sidebar, now backed by shared role config)
  • Unauthorized users cannot access protected dashboard sections (client DashboardGuard + server requireDashboardSession, plus existing edge proxy.ts)
  • Layout works on desktop and mobile (quick actions degrade gracefully on small screens)
  • Loading and empty/unauthorized states handled
  • Existing dashboard routes are not broken
  • npm run lint and npm run build pass

Area changed

  • Frontend / UI
  • Auth / Privy
  • Tests
  • Security

Contributor safety checklist

  • I did not commit .env.local or real secrets.
  • I did not expose server-only variables in client-side code.
  • I used mock mode or my own sandbox/test credentials.
  • I did not add deployment steps for contributor PRs.
  • I did not add maintainer-only credentials.

Testing

npm run lint    # 0 errors (2 pre-existing warnings in untouched files)
npm run build   # exits 0
npm run test    # new dashboard-guard suite: 8/8 pass
  • Added components/dashboard/__tests__/dashboard-guard.test.tsx covering the role config helpers and guard states (loading, redirect, wrong-role, authorized).
  • npx tsc --noEmit introduces no new errors from these changes (pre-existing repo type errors are unrelated and the build sets typescript.ignoreBuildErrors).

Notes for maintainers

  • The guard is intentionally additive on top of proxy.ts: edge middleware enforces authentication for /dashboard/*, while DashboardGuard / requireDashboardSession enforce role authorization and provide the graceful UI states.
  • Quick action targets in lib/dashboard/roles.ts point at existing routes; adjust there to add/replace per-role actions in one place.

pope-h added 3 commits June 21, 2026 11:50
…ion primitives

Introduce a single source of truth for dashboard roles (lib/dashboard/roles)
that drives navigation, badges, quick actions, and authorization, plus:

- DashboardGuard: client route guard with graceful loading and unauthorized
  states, layered on top of the existing edge authentication in proxy.ts
- DashboardUnauthorized: shared, recoverable access-denied view
- DashboardQuickActions: per-role quick action slots for dashboard headers
- requireDashboardSession: server-side role guard for server components

These let contributors add dashboard modules for a role without duplicating
layout or authorization logic.
Replace per-role inline auth/loading/unauthorized logic with the shared
primitives so all roles behave consistently:

- admin layout now wraps content in DashboardGuard
- driver page uses the server-side requireDashboardSession guard
- investor page renders the shared DashboardUnauthorized state
- shared Header surfaces per-role quick action slots

No change to existing routes or redirect behavior.
Verify role config helpers and that the guard renders loading, redirects
unauthenticated users, blocks the wrong role, and admits authorized roles.
@Obiajulu-gif

Copy link
Copy Markdown
Collaborator

@pope-h lint is failing fix it

@pope-h

pope-h commented Jun 21, 2026

Copy link
Copy Markdown
Contributor Author

@pope-h lint is failing fix it

Please check now. Lint fail sorted

@Obiajulu-gif Obiajulu-gif merged commit c6cad12 into Chainmove:main Jun 21, 2026
1 check passed
@Obiajulu-gif

Copy link
Copy Markdown
Collaborator

@pope-h great work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[HARD][DASHBOARD] Build unified role-based dashboard shell and navigation system

2 participants