<?php

namespace App\Http\Livewire\Calls;

use Livewire\Component;

class SendMessageButton extends Component
{
    public $callable;
    public $call;

    public function mount($callable, $call)
    {
        $this->callable = $callable;
        $this->call = $call;
    }

    public function createConversation()
    {
        if (!$this->callable || $this->callable->isRemoved()) {
            return;
        }

        $conversation = getActiveProfile()->createConversationWith($this->callable);

        return redirect()->route('chat', ['conversation' => $conversation->id]);
    }

    public function render()
    {
        return view('livewire.calls.send-message-button');
    }
}
