libra/docs/stories/story-6.1-dashboard-overvie...

2.1 KiB

Story 6.1: Dashboard Overview & Statistics

Epic Reference

Epic 6: Admin Dashboard

User Story

As an admin, I want to see real-time metrics and key statistics at a glance, So that I can understand the current state of my practice.

Acceptance Criteria

User Metrics Card

  • Total active clients
  • Individual vs company breakdown
  • Deactivated clients count
  • New clients this month

Booking Metrics Card

  • Pending requests count (highlighted)
  • Today's consultations
  • This week's consultations
  • This month's consultations
  • Free vs paid breakdown
  • No-show rate percentage

Timeline Metrics Card

  • Active case timelines
  • Archived timelines
  • Updates added this week

Posts Metrics Card

  • Total published posts
  • Posts published this month

Design

  • Clean card-based layout
  • Color-coded status indicators
  • Responsive grid

Technical Notes

new class extends Component {
    public function with(): array
    {
        return [
            'userMetrics' => $this->getUserMetrics(),
            'bookingMetrics' => $this->getBookingMetrics(),
            'timelineMetrics' => $this->getTimelineMetrics(),
            'postMetrics' => $this->getPostMetrics(),
        ];
    }

    private function getUserMetrics(): array
    {
        return Cache::remember('admin.metrics.users', 300, fn() => [
            'total_active' => User::where('status', 'active')->whereIn('user_type', ['individual', 'company'])->count(),
            'individual' => User::where('user_type', 'individual')->where('status', 'active')->count(),
            'company' => User::where('user_type', 'company')->where('status', 'active')->count(),
            'deactivated' => User::where('status', 'deactivated')->count(),
            'new_this_month' => User::whereMonth('created_at', now()->month)->count(),
        ]);
    }
};

Definition of Done

  • All metric cards display correctly
  • Data is accurate and cached
  • Responsive layout
  • Tests pass

Estimation

Complexity: Medium | Effort: 4-5 hours