<?php

declare(strict_types=1);

namespace Seka\Portal\Modul\Terminy\Http\Controllers\Backend\Udalosti\Livewire\Pages;

use Livewire\Component;
use Illuminate\Contracts\View\View;
use Seka\Portal\Modul\Terminy\Entities\Udalost\Udalost;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Seka\Portal\Modul\Terminy\Entities\Udalost\StavUpozornenia;

/**
 * Class Nova
 *
 * @package Seka\Portal\Modul\Terminy\Http\Controllers\Backend\Udalosti\Livewire\Pages
 */
final class Nova extends Component
{
    use AuthorizesRequests;

    /**
     * @var Udalost
     */
    public $udalost;

    /**
     * @param \Seka\Portal\Modul\Terminy\Entities\Udalost\Udalost $udalost
     */
    public function mount(Udalost $udalost): void
    {
        $this->udalost = $udalost;
        $this->udalost->upozornenie = StavUpozornenia::NEPOVOLENE();
    }

    /**
     * @return \Illuminate\Contracts\View\View
     * @throws \Illuminate\Auth\Access\AuthorizationException
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
     */
    public function render(): View
    {
        $this->authorize('terminy.udalosti.vytvorit');

        return view('Terminy::pages.udalosti.backend.livewire.nova');
    }
}
