<?php

declare(strict_types=1);

namespace App\Providers;

use App\Composers\LatestSuggestedInformationComposer;
use App\Http\Livewire\Components\Informacia\Components\Form;
use App\Http\Livewire\Components\Informacia\Components\HodnotiaceTlacidla;
use App\Http\Livewire\Components\Informacia\Components\Zoznam as BackendZoznam;
use App\Http\Livewire\Components\Informacia\Pages\Index as BackendIndex;
use App\Http\Livewire\Components\Informacia\Pages\Upravit;
use App\Http\Livewire\Components\Informacia\Pages\Vytvorit;
use App\Http\Livewire\Frontend\Informacia\Components\Zoznam as FrontendZoznam;
use App\Http\Livewire\Frontend\Informacia\Pages\Index as FrontendIndex;
use App\Http\View\Composers\UserNotificationComposer;
use App\View\Components\Badge;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
use Livewire\Livewire;

/**
 * Class ViewServiceProvider
 *
 * @package App\Providers
 */
final class ViewServiceProvider extends ServiceProvider
{
    /**
     * @return void
     */
    public function boot(): void
    {
        Blade::component(Badge::class, 'badge');
        $this->loadLivewireComponents();
    }

    /**
     * @return void
     */
    private function loadLivewireComponents(): void
    {
        // PAGES
        Livewire::component('pages.sprava.informacie.livewire.create', Vytvorit::class);
        Livewire::component('pages.sprava.informacie.livewire.edit', Upravit::class);
        Livewire::component('pages.sprava.informacie.livewire.list', BackendIndex::class);
        Livewire::component('pages.frontend.informacia.livewire.index', FrontendIndex::class);

        // COMPONENTS
        Livewire::component('pages.sprava.informacie.livewire.components.form', Form::class);
        Livewire::component('pages.sprava.informacie.livewire.components.zoznam', BackendZoznam::class);
        Livewire::component('frontend.informacie.zoznam', FrontendZoznam::class);
        Livewire::component('components.hodnotenie.hodnotiace-tlacidla', HodnotiaceTlacidla::class);
    }

    /**
     * @return void
     */
    public function register(): void
    {
        $this->registerComposers();
    }

    /**
     * @return void
     */
    public function registerComposers(): void
    {
        View::composer([
            'partials.navbar',
        ],
            UserNotificationComposer::class,
        );

        View::composer([
            'pages.plocha',
        ],
            LatestSuggestedInformationComposer::class,
        );
    }
}
