<?php

declare(strict_types=1);

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

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

/**
 * 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');
    }
}
