<?php

namespace App\Components\Contact;

use App\Models\Contact\Hub\ContactMessage;
use Livewire\Component;

class CommunicationEventViewer extends Component
{
    public int $messageId;

    public bool $expanded = false;

    public function toggle(): void
    {
        $this->expanded = !$this->expanded;
    }

    public function render()
    {
        $message = $this->expanded
            ? ContactMessage::with('events')->find($this->messageId)
            : null;

        return view('components.contact.communication-event-viewer', [
            'message' => $message,
        ]);
    }
}
