@extends('business::layouts.app') @section('title', 'Conversation — ' . $session->phone_number . ' — BizWap') @push('styles') @endpush @section('content') @if(session('success')) @endif @if(session('error')) @endif
{{-- Header --}}
{{ $session->phone_number }}
{{ $session->flow_name }}  ·  @php $badge = match($session->status) { 'active' => 'success', 'completed' => 'secondary', 'expired' => 'warning', default => 'secondary', }; @endphp {{ $session->status }}
{{ $messages->count() }} messages
Since {{ $session->created_at->format('d M Y') }}
{{-- Messages --}}
@if($messages->isEmpty())
No messages yet
@else @php $lastDate = null; @endphp @foreach($messages as $msg) @php $msgDate = $msg->created_at->toDateString(); $isOutbound = $msg->direction === 'outbound'; @endphp {{-- Day divider --}} @if($msgDate !== $lastDate)
@if($msg->created_at->isToday()) Today @elseif($msg->created_at->isYesterday()) Yesterday @else {{ $msg->created_at->format('d M Y') }} @endif
@php $lastDate = $msgDate; @endphp @endif
{{-- Content --}} @if($isOutbound && $msg->message_type === 'template') @php $decoded = json_decode($msg->content, true); $tplName = $decoded['template_name'] ?? $msg->content; @endphp {{ $tplName }} @else {{ $msg->content }} @endif {{-- Meta: time + status --}}
{{ $msg->created_at->format('H:i') }} @if($isOutbound) @if($msg->status === 'pending') @elseif($msg->status === 'sent') @elseif($msg->status === 'delivered') @elseif($msg->status === 'read') @elseif($msg->status === 'failed') @endif @endif
@endforeach @endif
{{-- Reply input / expired banner --}} @php $windowOpen = $session->window_expires_at && $session->window_expires_at->isFuture(); @endphp @if($windowOpen) @else
24-hour messaging window has expired. Start a new conversation using a template.
@endif
@endsection @push('scripts') @endpush