{{ __('Admin') }} {{ __('Devices') }}
@php $pctOf = fn($n) => $counts['all'] > 0 ? round($n / $counts['all'] * 100, 1) . '%' : '0%'; @endphp @if (session('status'))
{{ session('status') }}
@endif @if ($errors->any())
{{ $errors->first() }}
@endif
{{ __('Admin · Platform devices') }}

{{ __('All') }} {{ __('devices') }}

{{ __('Every paired WhatsApp number across the platform. Force re-pair, disconnect, or transfer ownership without leaving the admin console.') }}

{{ number_format($counts['connected']) }} {{ __('connected') }} {{-- Bulk re-sync: pulls live status for every device from the bridge. data-confirm is handled by lib/ui-modal (app.js). --}}
@csrf
{{-- Export honours the current status + search filters. --}} {{ __('Export CSV') }}
{{ __('Total devices') }}{{ $newThisWeek > 0 ? '+' . number_format($newThisWeek) : '0' }} {{ __('this week') }}
{{ number_format($counts['all']) }}{{ __('across :n wks', ['n' => number_format($workspacesWithDevices)]) }}
{{ __('Connected') }}{{ $pctOf($counts['connected']) }}
{{ number_format($counts['connected']) }}{{ __('healthy') }}
{{ __('Needs re-pair') }}{{ __('action req') }}
{{ number_format($counts['needs_pair']) }}{{ __('expired QR') }}
{{ __('Disconnected') }}{{ __('offline') }}
{{ number_format($counts['disconnected']) }}{{ __('offline') }}
{{ __('Sent (24h)') }}{{ __('live') }}
{{ number_format($sent24hTotal) }}{{ __('across all') }}
@foreach (['all' => __('All'), 'connected' => __('Connected'), 'needs_pair' => __('Needs re-pair'), 'disconnected' => __('Disconnected')] as $k => $label) @php $tone = $k === 'needs_pair' ? 'text-accent-amber' : ($k === 'disconnected' ? 'text-accent-coral' : 'opacity-80'); @endphp {{ $label }} {{ $k === 'all' ? '(' . number_format($counts['all']) . ')' : number_format($counts[$k]) }} @endforeach
@if ($q !== '') {{ __('Clear') }} @endif
@forelse ($devices as $d) @php $phone = trim((string) $d->country_code . ' ' . (string) $d->phone_number); $ownerNm = (string) optional($d->user)->name; $initials = collect(preg_split('/\s+/', trim($ownerNm))) ->filter() ->take(2) ->map(fn($p) => mb_strtoupper(mb_substr($p, 0, 1))) ->implode('') ?: '—'; $pill = match ($d->status) { 'connected' => ['bg-wa-mint text-wa-deep', 'bg-wa-green', __('Connected')], 'needs_pair' => ['bg-accent-amber/15 text-accent-amber', 'bg-accent-amber', __('Re-pair')], 'failed' => ['bg-accent-coral/10 text-accent-coral', 'bg-accent-coral', __('Failed')], default => ['bg-paper-100 text-ink-700', 'bg-paper-300', __('Disconnected')], }; @endphp @empty @endforelse
{{ __('Device & number') }} {{ __('Workspace') }} {{ __('Owner') }} {{ __('Last sync') }} {{ __('Sent 24h') }} {{ __('Status') }}
{{ $d->device_name ?: __('Device #:id', ['id' => $d->id]) }}
{{ $phone !== '' ? mask_phone($phone) : '—' }}{{ $d->region ? ' · ' . $d->region : '' }}
{{ optional($d->workspace)->name ?: '—' }}
{{ optional($d->workspace)->plan ?: '—' }}
{{ $ownerNm !== '' ? $ownerNm : '—' }}
{{ $d->last_seen_at ? $d->last_seen_at->diffForHumans(null, true) : '—' }} {{ number_format((int) $d->sent_24h) }} {{ $pill[2] }}
{{ $q !== '' || $status !== 'all' ? __('No devices match this filter.') : __('No devices have been paired on the platform yet.') }}
{{ __('Showing') }} {{ $devices->firstItem() ?? 0 }}–{{ $devices->lastItem() ?? 0 }} {{ __('of') }} {{ number_format($devices->total()) }} {{ __('devices') }}
{{ $devices->onEachSide(1)->links() }}