@php
$messages = $getState() ?? collect();
@endphp
@if($messages->isEmpty())
No messages on this order yet. Use the Send Message button above to compose one.
@else
@foreach($messages as $message)
@php
$isPrivate = $message->is_private_note;
$isSystem = !$message->sender_user_id;
$channels = $message->channels ?? [];
$channelLabels = [
'email' => 'Email',
'sms' => 'SMS',
'whatsapp' => 'WhatsApp',
'push' => 'Push',
];
@endphp
{{-- Header --}}
{{ $message->sender?->name ?? 'System' }}
{{ $message->created_at?->format('d M Y, H:i') ?? '' }}
@if($isPrivate)
Private Note
@else
@if(!$message->is_visible_to_customer)
Internal
@else
Visible to Customer
@endif
@foreach($channels as $ch)
@php
$sent = ($ch === 'email' && $message->sent_via_email)
|| ($ch === 'sms' && $message->sent_via_sms)
|| ($ch === 'whatsapp' && $message->sent_via_whatsapp)
|| ($ch === 'push' && $message->sent_via_push);
@endphp
{{ $channelLabels[$ch] ?? strtoupper($ch) }}{{ $sent ? ' (sent)' : '' }}
@endforeach
@endif
{{-- Subject --}}
{{ $message->subject }}
{{-- Body --}}
{!! $message->body !!}
@endforeach
@endif