@if($activeChat)
@php
$participant = $activeChat->vendor ?? $activeChat->promoter ?? $activeChat->admin;
$participantType = $activeChat->vendor_id ? 'vendor' : ($activeChat->promoter_id ? 'promoter' : 'admin');
$initial = $participant ? substr($participant->name, 0, 1) : '?';
$avatarClass = $participantType === 'vendor' ? 'bg-emerald-50 text-emerald-600' : ($participantType === 'promoter' ? 'bg-purple-50 text-purple-600' : 'bg-red-50 text-red-600');
$badgeClass = 'badge-' . $participantType;
@endphp
{{ $initial }}
{{ $participant->name ?? 'Unknown' }}
{{ $participantType }}
@if($activeChat->product)
{{ $activeChat->product->name }}
@endif
@foreach($activeChat->messages()->with('sender')->orderBy('created_at')->get() as $message)
@if($message->sender_id !== auth()->id())
{{ $message->sender?->name }}
@endif
@if($message->message)
{{ $message->message }}
@endif
@if($message->attachments)@foreach(json_decode($message->attachments) as $image)
 }})
@endforeach @endif
{{ $message->created_at->format('h:i A') }}
@endforeach
@else
Select a conversation
Choose from the sidebar to start messaging
@endif