Skip to content

feat: add analytics dashboard#35

Merged
arhamkhnz merged 7 commits intomainfrom
feat/analytics-dashboard
Mar 7, 2026
Merged

feat: add analytics dashboard#35
arhamkhnz merged 7 commits intomainfrom
feat/analytics-dashboard

Conversation

@arhamkhnz
Copy link
Copy Markdown
Owner

@arhamkhnz arhamkhnz commented Jan 8, 2026

Greptile Overview

Greptile Summary

This PR successfully adds a new analytics dashboard page with comprehensive filtering and visualization controls. The implementation includes a reusable date range picker component, risk view selector with visual indicators, and a filter system with real-time feedback.

Key additions:

  • New /dashboard/analytics route with full dashboard UI
  • DateRangePicker component with 30-day default range and dual-month calendar view
  • RiskViewSelect dropdown with visual status indicators for different risk views
  • FiltersPopover with checkbox-based filtering and active filter display
  • Revenue chart with mock data and risk summary cards

Minor notes:

  • Export button is non-functional (no onClick handler) - appears to be intentional scaffolding

Confidence Score: 4/5

  • This PR is safe to merge with minimal risk
  • The implementation is clean and well-structured, following existing patterns in the codebase. The only issue is the non-functional export button, which appears to be intentional scaffolding for future functionality. All components are properly implemented with good state management.
  • No files require special attention - the export button in analytics-overview.tsx is non-functional but this appears intentional

Important Files Changed

File Analysis

Filename Score Overview
src/app/(main)/dashboard/analytics/_components/analytics-overview.tsx 4/5 Analytics dashboard component with risk view selector, filters, and date picker - export button non-functional but otherwise well-implemented
src/app/(main)/dashboard/analytics/page.tsx 5/5 Simple page wrapper for AnalyticsOverview - clean implementation with no issues
src/components/date-range-picker.tsx 5/5 Reusable date range picker with 30-day default - well-implemented with proper state management
src/navigation/sidebar/sidebar-items.ts 5/5 Enabled analytics route by removing comingSoon flag - clean and correct change

Sequence Diagram

sequenceDiagram
    actor User
    participant Page as Analytics Page
    participant Overview as AnalyticsOverview
    participant RiskView as RiskViewSelect
    participant Filters as FiltersPopover
    participant DatePicker as DateRangePicker
    
    User->>Page: Navigate to /dashboard/analytics
    Page->>Overview: Render component
    Overview->>RiskView: Initialize (default: "risk-view")
    Overview->>Filters: Initialize (empty filters)
    Overview->>DatePicker: Initialize (last 30 days)
    
    User->>RiskView: Click to open dropdown
    RiskView->>RiskView: setOpen(true)
    User->>RiskView: Select view option
    RiskView->>RiskView: setValue(currentValue)
    RiskView->>RiskView: setOpen(false)
    
    User->>Filters: Click to open popover
    Filters->>Filters: setOpen(true)
    User->>Filters: Check/uncheck filter
    Filters->>Filters: handleFilterChange(filterId, checked)
    Filters->>Filters: Update selectedFilters state
    Filters->>Filters: Display active filters
    
    User->>DatePicker: Click to open calendar
    DatePicker->>DatePicker: setOpen(true)
    User->>DatePicker: Select date range
    DatePicker->>DatePicker: setDateRange(newRange)
    DatePicker->>DatePicker: Update button label
    
    User->>Overview: Click Export button
    Note over Overview: Export functionality not implemented
Loading

Greptile Summary

This PR introduces the /dashboard/analytics route and its full set of sub-components: an AnalyticsOverview toolbar, a revenue sparkline with dynamic date-range support, a Forecast vs Target chart, a Coverage Triage card, a Manager Action Queue, and a sortable Revenue Risk Ledger table. The navigation item is activated by removing the comingSoon flag.

Compared to the previous review, several issues have been fixed:

  • handleFilterToggle now correctly uses a functional updater with a uniqueness guard, eliminating the stale-state duplicate-filter bug.
  • buildRevenueChartData now properly accepts both from and to, so the chart window matches the selected range.
  • The risk-summary comparatorLabel has been changed from the hardcoded date string to the generic "vs previous period".

Issues from previous reviews that remain unresolved in the current code:

  • RiskViewSelect still passes currentValue directly to setValue on select — re-selecting the active option emits an empty string (cmdk toggle behaviour), clearing the button label.
  • last:sm:pr-0 first:sm:pl-0 variant ordering in LedgerStat (analytics-actions-risk-ledger.tsx:323) is still reversed; Tailwind JIT may not emit the correct CSS, leaving the border-adjacent columns with wrong padding at the sm breakpoint.
  • The primary YAxis in analytics-drivers-forecast-target.tsx still declares domain={[0, "auto"]} with ticks={[0, 50, 100, 150, 200]}; the auto ceiling (~115) means both the 150 and 200 ticks fall outside the domain and will be silently dropped by Recharts.
  • The "Open top 5 deals" button in analytics-drivers-coverage-triage.tsx and the Export button in analytics-overview.tsx have no onClick handlers.
  • The hard-coded id="date" on the DateRangePicker trigger will produce duplicate DOM IDs if the component is ever used more than once on a page.

Confidence Score: 3/5

  • Safe to merge as scaffolding, but several issues flagged in previous rounds remain unaddressed.
  • Several improvements were made since the last review (functional updater for filters, correct chart range, generic comparator label). However, five issues from previous review rounds are still present in the code: the cmdk empty-string toggle on RiskViewSelect, Tailwind variant-ordering bug in LedgerStat, YAxis ticks beyond the auto domain in the forecast chart, two non-functional buttons, and the duplicate id="date" in DateRangePicker. None are data-corrupting or security-relevant, but they represent known UX/rendering bugs that have been explicitly pointed out and not yet resolved.
  • Pay attention to analytics-drivers-forecast-target.tsx (YAxis ticks/domain mismatch) and analytics-actions-risk-ledger.tsx (Tailwind variant ordering in LedgerStat).

Important Files Changed

Filename Overview
src/app/(main)/dashboard/analytics/_components/analytics-overview.tsx Core dashboard controller. Several previously-flagged issues have been fixed in this revision (functional updater for filters, correct buildRevenueChartData(from, to), generic "vs previous period" comparator label). The RiskViewSelect empty-string toggle edge case and the no-op Export button remain unresolved.
src/app/(main)/dashboard/analytics/_components/analytics-actions-risk-ledger.tsx Revenue risk ledger with TanStack Table sorting. Contains the previously-flagged Tailwind variant ordering issue (last:sm:pr-0 first:sm:pl-0) on the LedgerStat wrapper that will produce incorrect padding at the sm breakpoint.
src/app/(main)/dashboard/analytics/_components/analytics-drivers-forecast-target.tsx Forecast vs target chart. The primary YAxis uses domain={[0, "auto"]} (auto ceiling ≈ 115) but ticks={[0, 50, 100, 150, 200]} — both the 150 and 200 tick values lie outside the computed domain and will be silently dropped by Recharts, leaving the Y-axis visually incomplete. This was flagged in a previous review and remains unresolved.
src/app/(main)/dashboard/analytics/_components/analytics-drivers-coverage-triage.tsx Static coverage triage card. The "Open top 5 deals" button still has no onClick handler (previously flagged). No other logic issues.
src/components/date-range-picker.tsx Reusable date range picker. Correctly supports both controlled and uncontrolled usage. Previously-flagged hard-coded id="date" on the trigger button is still present, which will cause duplicate DOM IDs if the component is used more than once on a page.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User navigates to /dashboard/analytics] --> B[page.tsx]
    B --> C[AnalyticsOverview]
    B --> D[DriversForecastTarget]
    B --> E[DriversCoverageTriage]
    B --> F[ActionsManagerQueue]
    B --> G[ActionsRiskLedger]

    C --> C1[RiskViewSelect\ninternal state only]
    C --> C2[FiltersPopover\nselectedFilters state]
    C --> C3[DateRangePicker\ncontrolled via dateRange state]
    C --> C4[buildRevenueChartData\nfrom + to → random walk series]
    C --> C5[SummaryRow\nrevenue sparkline + risk metrics]

    C2 -->|onToggle| C2a[handleFilterToggle\nfunctional updater]
    C3 -->|onChange| C3a[handleDateRangeChange\nguards from+to both present]

    G --> G1[useReactTable\nSortingState: riskScore desc]
    G1 --> G2[ledgerColumns\n7 column defs]
Loading

Last reviewed commit: 079e8d9

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment thread src/app/(main)/dashboard/analytics/_components/analytics-overview.tsx Outdated
Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +83 to +85
onSelect={(currentValue) => {
setValue(currentValue);
setOpen(false);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clicking the currently selected option will set currentValue to empty string (cmdk toggle behavior), causing the button label to display undefined

Suggested change
onSelect={(currentValue) => {
setValue(currentValue);
setOpen(false);
onSelect={(currentValue) => {
setValue(currentValue === value ? value : currentValue);
setOpen(false);
}}

Comment thread src/app/(main)/dashboard/analytics/_components/analytics-overview.tsx Outdated
Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

Comment thread src/app/(main)/dashboard/analytics/_components/analytics-overview.tsx Outdated
Comment thread src/app/(main)/dashboard/analytics/_components/analytics-overview.tsx Outdated
Comment thread src/components/date-range-picker.tsx
Comment thread src/app/(main)/dashboard/analytics/_components/analytics-overview.tsx Outdated
Comment thread src/app/(main)/dashboard/analytics/_components/analytics.data.ts Outdated
@arhamkhnz arhamkhnz removed the On Hold label Mar 7, 2026
@arhamkhnz arhamkhnz merged commit 8d65324 into main Mar 7, 2026
1 check 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

Development

Successfully merging this pull request may close these issues.

1 participant