@extends('layouts.app') @section('title', 'Dashboard') @php $sentimentSlices = $stats['sentiment']; $sentimentTotal = array_sum(array_column($sentimentSlices, 'total')); $categorySlices = array_values(array_filter($stats['categories'], fn($slice) => $slice['total'] > 0)); $categoryTotal = array_sum(array_column($categorySlices, 'total')); $leadTotal = $stats['leads']['total'] ?? 0; $leadSlices = array_values(array_filter($stats['leads']['slices'] ?? [], fn($slice) => $slice['total'] > 0)); $leadPriorities = $stats['leads']['priorities'] ?? []; $prioritySlices = array_values(array_filter($leadPriorities, fn($band) => $band['total'] > 0)); $highBand = collect($leadPriorities)->firstWhere('key', \App\Models\LeadType::PRIORITY_HIGH); $canManage = (Auth::check() && Auth::user()->auth_id == 0) || Auth::user()->user_level != 0; $turnaround = $stats['turnaround']; $volumeSum = array_sum(array_column($stats['volume'], 'total')); $humaniseGap = function (?int $minutes) { if ($minutes === null) { return '—'; } if ($minutes < 60) { return $minutes . ' min'; } if ($minutes < 1440) { $hours = intdiv($minutes, 60); $rest = $minutes % 60; return $hours . ' h' . ($rest > 0 ? ' ' . $rest . ' m' : ''); } $days = intdiv($minutes, 1440); $hours = intdiv($minutes % 1440, 60); return $days . ($days === 1 ? ' day' : ' days') . ($hours > 0 ? ' ' . $hours . ' h' : ''); }; $toChart = fn(array $rows) => array_map( fn($row) => [ 'label' => $row['label'], 'colour' => $row['colour'], 'total' => $row['total'], 'url' => route('mails.filter', [$row['filter']]), ], $rows, ); $sentimentChartData = $toChart($sentimentSlices); $priorityChartData = $toChart($prioritySlices); $leadChartData = $toChart($leadSlices); $categoryChartData = $toChart($categorySlices); $senderChartData = $stats['topSenders'] ->map(fn($sender) => [ 'label' => $sender->sender_email, 'colour' => '#3355d1', 'total' => (int) $sender->total, 'url' => null, ]) ->values() ->all(); $replyChartData = [ [ 'label' => 'Replied', 'colour' => '#067647', 'total' => $stats['replied'], 'url' => route('mails.filter', ['replied_mail']), ], [ 'label' => 'Awaiting', 'colour' => '#b54708', 'total' => $stats['awaiting'], 'url' => route('mails.filter', ['send-mail']), ], ]; $barHeight = fn(int $rows) => max(140, $rows * 32 + 30); @endphp @section('content') @if ($is_app_pwd == 0)
Adjust the confidence floor per type on the Lead Types screen.
Median {{ $humaniseGap($turnaround['medianMinutes']) }} across {{ number_format($turnaround['total']) }} answered {{ $turnaround['total'] === 1 ? 'mail' : 'mails' }}.