Director dashboard - #5
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 3 — Dashboard Section Components & Rendering Fix
What was built
Completed the Director Dashboard view with a full set of data-driven section components wired to a mock data layer via React Query. The dashboard now renders correctly at /dashboard?view=director with the shell, sidebar, and all metric cards visible.
New section components:
HealthScoreCard — pipeline health score metric
TotalSpendCard — total cloud spend over a date range
SavingsCard — identified savings opportunities
RiskAlertCard — active anomaly/risk count
InsightsSummaryCard — summary of top insights
CostVsForecastCard — actual vs forecast spend chart
CostAllocation — spend breakdown by provider/team
TopServiceIncreases — top services by cost increase
New primitive components:
MetricCard — reusable metric display with glow, trend direction, loading and error states
PageErrorBoundary — class-based error boundary catching render failures gracefully
Skeleton — loading placeholder primitive
New data layer:
mockData.ts — typed mock responses for all endpoints
useSavingsOpportunities, useForecast, usePipelineHealth, useSpendByService, useSpendByTeam — React Query hooks with NEXT_PUBLIC_USE_MOCK_DATA flag pattern, ready to swap to real API endpoints in Phase 4
Issues encountered and fixes
The Providers component (ClerkProvider + QueryClientProvider) was correctly built but never imported into layout.tsx. The root layout had a standalone ClerkProvider directly, meaning QueryClientProvider was never present in the tree. All useQuery calls threw No QueryClient set immediately.
Fix: replaced the standalone ClerkProvider in layout.tsx with , which supplies both Clerk and React Query contexts to the entire app.
Even after fixing the provider, Next.js 15 was SSR-ing the section components server-side before the client context was hydrated. This caused useQuery hooks to execute in a context where QueryClientProvider didn't exist yet, throwing the same error during the server render pass.
Fix: converted all section component imports in dashboard/page.tsx to use next/dynamic with ssr: false, ensuring they only render client-side where the QueryClient context is available.
ViewGate uses useSearchParams() to read the ?view= param. In Next.js 15, components using useSearchParams must be wrapped in a Suspense boundary or they cause rendering issues during the SSR pass.
Fix: wrapped both instances in a single in dashboard/page.tsx.
NEXT_PUBLIC_USE_MOCK_DATA=true was set but the file was accidentally named .env.locale instead of .env.local. Next.js only reads .env.local, so the flag was never picked up — all hooks were falling through to real API calls against endpoints that don't exist yet, producing cascading 404s.
Fix: renamed .env.locale to .env.local.
Consistent with the known monorepo Webpack issue identified in Phase 2 — all new components use const Component = () => {} + export default Component pattern. The export default function syntax was avoided throughout to prevent Webpack returning empty objects for component imports.
Known state going into Phase 4
All section components render with mock data when NEXT_PUBLIC_USE_MOCK_DATA=true
Hooks are structured to swap mock for real API calls by flipping the env flag
orgId from useOrganization() is undefined in dev (no Clerk org set up locally) — this is expected and harmless while on mock data
Engineer view is a placeholder — full implementation is Phase 4
useAnomalies hook not yet built — RiskAlertCard will need it in Phase 4