@extends('layouts.dashboard')
@section('content')
@php
use App\Models\Order;
/** @var array $kpis @var array $recent @var array|null $driver */
/** @var array $deliveriesChart @var array $earningsChart @var array $statusChart @var array $chartMeta */
/** @var array $kpiSparks */
$kpiSparks = $kpiSparks ?? [];
@endphp
@if (!$driver)
{{ t_raw('dashboard.driver_no_profile') }}
@else
{{ t_raw('dashboard.availability_heading') }}
@php $online = (int) ($driver['is_available'] ?? 0) === 1;
@endphp
{{ t_raw('dashboard.you_are_currently') }}
{!! $online ? t('dashboard.status_available') : t('dashboard.status_offline') !!}
{{ t_raw('dashboard.sec.snapshot') }}
@partial('kpi-card', ['variant' => 'panel', 'accent' => 'amber', 'icon' => 'fa-bolt', 'label' => t_raw('dashboard.kpi_active_deliveries'), 'value' => number_format((int) $kpis['active']), 'href' => route('driver.deliveries'), 'spark' => $kpiSparks['active'] ?? [], 'meta' => '' . t('dashboard.kpi_cap_in_progress') . ''])
@partial('kpi-card', ['variant' => 'panel', 'accent' => 'blue', 'icon' => 'fa-motorcycle', 'label' => t_raw('dashboard.kpi_delivered_today'), 'value' => number_format((int) $kpis['today']), 'href' => route('driver.deliveries'), 'spark' => $kpiSparks['today'] ?? [], 'meta' => '' . t('dashboard.kpi_cap_today') . ''])
@partial('kpi-card', ['variant' => 'panel', 'accent' => 'teal', 'icon' => 'fa-truck', 'label' => t_raw('dashboard.kpi_total_delivered'), 'value' => number_format((int) $kpis['delivered']), 'href' => route('driver.deliveries'), 'spark' => $kpiSparks['delivered'] ?? [], 'meta' => '' . t('dashboard.kpi_cap_all_time') . ''])
@partial('kpi-card', ['variant' => 'panel', 'accent' => 'green', 'icon' => 'fa-coins', 'label' => t_raw('dashboard.kpi_earnings'), 'value' => money($kpis['earnings']), 'href' => route('driver.deliveries'), 'spark' => $kpiSparks['earnings'] ?? [], 'meta' => '' . t('dashboard.kpi_cap_all_time') . ''])
@partial('kpi-card', ['variant' => 'panel', 'accent' => 'orange', 'icon' => 'fa-money-bill-wave', 'label' => t_raw('dashboard.cash_to_hand_in'), 'value' => money($kpis['cash_today']), 'href' => route('driver.deliveries'), 'meta' => '' . t('dashboard.cash_hint') . ''])
{{ t_raw('dashboard.sec.trends') }}
@partial('chart-card', ['heading' => t_raw('dashboard.chart_deliveries_per_day'), 'sub' => t_raw('dashboard.chart_deliveries_caption'), 'cfg' => $deliveriesChart, 'meta' => $chartMeta['deliveries'], 'icon' => 'fa-chart-line', 'accent' => 'blue'])
@partial('chart-card', ['heading' => t_raw('dashboard.chart_earnings_trend'), 'sub' => t_raw('dashboard.chart_earnings_caption'), 'cfg' => $earningsChart, 'meta' => $chartMeta['earnings'], 'icon' => 'fa-chart-area', 'accent' => 'green'])
{{ t_raw('dashboard.sec.breakdown') }}
@php /* Donut beside the table, exactly as the vendor dashboard pairs Orders by
status with its neighbours — a small ring alone in a full-width card
reads as a layout hole, not a breakdown. */
@endphp
@partial('chart-card', ['heading' => t_raw('dashboard.chart_status_mix'), 'sub' => t_raw('dashboard.chart_status_caption'), 'cfg' => $statusChart, 'meta' => $chartMeta['status'], 'icon' => 'fa-chart-pie', 'accent' => 'violet'])
@php /* Assigned carries no data-sort: it renders a date *and* a time, which the
sorter's Date.parse() cannot read, so offering the control would sort it wrongly. */
@endphp
| {{ t_raw('dashboard.col_order') }} | {{ t_raw('dashboard.col_restaurant') }} | {{ t_raw('dashboard.col_customer') }} | {{ t_raw('dashboard.col_fee') }} | {{ t_raw('dashboard.col_status') }} | {{ t_raw('dashboard.col_assigned') }} |
@if (count($recent))
@foreach ($recent as $o)
{{ $o['order_number'] }}
@if (!empty($o['first_item_name'])){{ $o['first_item_name'] }}@if (($o['item_count'] ?? 0) > 1) {{ t_raw('admin.dashboard.items_more_suffix', [':n' => (int) $o['item_count'] - 1]) }}@endif@endif
|
{!! restaurant_brandmark(['logo' => $o['restaurant_logo'] ?? '', 'name' => $o['restaurant_name'] ?? '', 'cuisine_slug' => $o['cuisine_slug'] ?? ''], 'md') !!}
{{ $o['restaurant_name'] }}
|
{!! brandmark_html($o['customer_avatar'] ?? null, (string) $o['customer_name'], 'md', 'qm-brandmark--round') !!}
{{ $o['customer_name'] }}
|
{{ money($o['delivery_fee']) }} |
{{ Order::statusLabel($o['status']) }} |
{!! fmt_datetime($o['assigned_at']) !!} |
@endforeach
@else
@partial('table-empty', ['colspan' => 6, 'icon' => 'fa-motorcycle', 'msg' => t_raw('dashboard.no_assignments'), 'cta' => ['href' => route('driver.deliveries'), 'label' => t_raw('dashboard.view_deliveries_cta')]])
@endif
@php /* /.col-xl-8 */
@endphp
@php /* /.row */
@endphp
@endif
@endsection