Skip to content

feat(dashboard): Agent/Agency/Both view toggle#104

Merged
Systemsaholic merged 4 commits intomainfrom
feature/dashboard-view-toggle
Mar 26, 2026
Merged

feat(dashboard): Agent/Agency/Both view toggle#104
Systemsaholic merged 4 commits intomainfrom
feature/dashboard-view-toggle

Conversation

@Systemsaholic
Copy link
Copy Markdown
Owner

@Systemsaholic Systemsaholic commented Mar 26, 2026

Summary

  • Add segmented control (Agent/Agency/Both) for admin users to switch dashboard view
  • Agent view: personal trips only (KPIs, charts, widgets)
  • Agency view: all agency trips
  • Both: current behavior showing personal + agency rows
  • Selection persists to localStorage, defaults to Both
  • Non-admin users always see personal view only, toggle hidden

Test plan

  • Verified all 3 modes render correct KPI data
  • Verified charts update (Y-axis scale changes between views)
  • Verified leaderboard hidden in Agent view
  • Verified toggle not visible for non-admin users
  • TypeScript compilation passes

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added dashboard view toggle for admins to filter between Personal, Agency, or All data
    • Dashboard view preference now persists across browser sessions

Systemsaholic and others added 4 commits March 26, 2026 09:29
Comprehensive design spec for the consumer-facing OTA covering:
- Application architecture (Next.js 15.x on Vercel, existing NestJS API)
- AI Concierge with real API tools (Amadeus, Traveltek, Globus)
- Advisor micro-sites synced from TravelLeaders Network profiles
- Attribution system with 30-day referral cookies and CRM priority chain
- Deals system fed by existing VPS scraper via new API endpoint
- Search pages for flights, hotels, cars, cruises, tours, all-inclusives
- Data model (advisor_profiles, deals, ota_referrals, itinerary_templates additions)
- Auth strategy (public endpoints, service-to-service keys, rate limiting)
- Cross-cutting concerns (SEO, a11y, mobile, error handling)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Key corrections based on codebase audit:
- cruise-repository (already public) replaces FusionAPI for Phase 1 search
- Hotels are composite (Google Places + Amadeus + Booking.com), not Amadeus-only
- Template publishing uses separate ota_published_trips table with snapshot
  (itinerary_templates stores JSON blobs, not relational itinerary data)
- Flights/hotels need public facade endpoints (existing are JWT-gated)
- Airport lookup endpoint needed for flight search UX
- tour-repository and Globus live proxy both already public
- Updated API endpoints to reflect actual vs new capabilities

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- FusionAPI required for live cruise pricing (not just catalog)
- Remove Booking.com from hotel search — Amadeus only
- Defer car rentals to Phase 2 (no provider exists)
- Update all search, tool, and endpoint references accordingly

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Admins can now switch between Agent view (personal trips only), Agency
view (all agency trips), or Both (current behavior). The toggle scopes
KPI cards, charts, widgets, and leaderboard visibility. Selection
persists to localStorage. Non-admin users always see personal view only.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Systemsaholic Systemsaholic merged commit 47e77ea into main Mar 26, 2026
3 of 4 checks passed
@Systemsaholic Systemsaholic deleted the feature/dashboard-view-toggle branch March 26, 2026 16:07
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 26, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 23f9c023-2237-4a62-ae96-4f8bc6328a16

📥 Commits

Reviewing files that changed from the base of the PR and between e6d7b01 and 832d29b.

📒 Files selected for processing (6)
  • apps/admin/src/app/dashboard/page.tsx
  • apps/admin/src/hooks/use-dashboard.ts
  • apps/api/src/dashboard/dashboard.controller.ts
  • apps/api/src/dashboard/dashboard.service.ts
  • apps/api/src/dashboard/dto/dashboard-overview.dto.ts
  • docs/superpowers/specs/2026-03-26-ota-consumer-portal-design.md

📝 Walkthrough

Walkthrough

The PR introduces a dashboard view filtering feature that allows users to toggle between personal, agency, and all data views. Changes include: localStorage-persisted view state in the UI layer, a new DashboardView type definition, hook parameter updates to pass the view selection, API endpoint documentation, and service-layer logic that conditionally fetches data based on the selected view.

Changes

Cohort / File(s) Summary
Dashboard UI & State Management
apps/admin/src/app/dashboard/page.tsx
Added localStorage-persisted view state ('personal' | 'agency' | 'all'), admin-only UI toggle, and conditional rendering of KPI cards and leaderboards based on selected view.
Hook Layer
apps/admin/src/hooks/use-dashboard.ts
Introduced DashboardView type export, extended dashboardKeys.overview() query key factory to include view parameter, and updated useDashboardOverview hook to accept and pass view as a query parameter.
API Contract & DTO
apps/api/src/dashboard/dto/dashboard-overview.dto.ts, apps/api/src/dashboard/dashboard.controller.ts
Added optional view query parameter ('personal' | 'agency' | 'all') to DashboardOverviewQueryDto and documented it in the GET /dashboard/overview endpoint's Swagger specification.
Service Logic
apps/api/src/dashboard/dashboard.service.ts
Implemented conditional data fetching in getOverview: reads view parameter and uses it to control which KPI groups are executed and which trip scope is applied to widgets, with fallback logic for missing data.
Documentation
docs/superpowers/specs/2026-03-26-ota-consumer-portal-design.md
Added new OTA Consumer Portal MVP specification document detailing Next.js frontend structure, NestJS backend integration, AI Concierge architecture, deals system, advisor micro-sites, and Phase 2 roadmap.

Sequence Diagram

sequenceDiagram
    participant User as User (Admin)
    participant UI as Dashboard Page
    participant LocalStorage as localStorage
    participant Hook as useDashboardOverview Hook
    participant Controller as API Controller
    participant Service as Dashboard Service
    participant DB as Database

    User->>UI: Toggle view (personal/agency/all)
    UI->>UI: Update React state (view)
    UI->>LocalStorage: Save "dashboard-view" key
    UI->>Hook: Call useDashboardOverview({view})
    Hook->>Hook: Build query key with view parameter
    Hook->>Controller: GET /dashboard/overview?view=...
    Controller->>Service: getOverview(auth, {view, ...})
    Service->>Service: Determine needsPersonal & needsAgency<br/>based on view parameter
    alt view = 'personal'
        Service->>DB: Fetch personal KPIs & widgets
    else view = 'agency'
        Service->>DB: Fetch agency KPIs & widgets
    else view = 'all'
        Service->>DB: Fetch both personal & agency data
    end
    DB-->>Service: Return conditional data
    Service-->>Controller: Return filtered dashboard data
    Controller-->>Hook: Response with view-specific data
    Hook-->>UI: Update query data
    UI->>UI: Render KPIs & charts<br/>based on view selection
    UI-->>User: Display filtered dashboard
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 A rabbit hops through views so bright,
Dashboard filters shine with light—
Personal, agency, or all combined,
States persist, localStorage aligned! 🎨✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/dashboard-view-toggle

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tailfire-client Ready Ready Preview, Comment Mar 26, 2026 4:07pm
tailfire-ota Ready Ready Preview, Comment Mar 26, 2026 4:07pm

Request Review

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