<?php

namespace App\Components\Solicitor;

use App\Models\Solicitor\Solicitor;
use Livewire\Component;

class View extends Component {
    public Solicitor $solicitor;

    public string $tab = 'overview';

    protected array $allowedTabs = [
        'overview',
        'documents',
        'addresses',
        'email-senders',
        'logo',
        'history',
    ];

    protected $queryString = [
        'tab' => ['except' => 'overview'],
    ];

    public function mount(Solicitor $solicitor): void {
        $this->authorize('solicitors.view');
        $this->solicitor = $solicitor;

        if (!in_array($this->tab, $this->allowedTabs, true)) {
            $this->tab = 'overview';
        }
    }

    public function setTab(string $tab): void {
        if (!in_array($tab, $this->allowedTabs, true)) {
            return;
        }

        $this->tab = $tab;
    }

    public function render() {
        return view('components.solicitor.view');
    }
}
