<?php

declare(strict_types=1);

namespace App\Providers;

use App\Composers\LatestSuggestedInformationComposer;
use App\Http\Livewire\Components\Informacia\Components\Form as HodnoteniaBackendComponentForm;
use App\Http\Livewire\Components\Informacia\Components\HodnotiaceTlacidla;
use App\Http\Livewire\Components\Informacia\Components\Zoznam as InformaciaBackendComponentZoznam;
use App\Http\Livewire\Components\Informacia\Hodnotenie\Components\Zoznam as HodnoteniaBackendComponentZoznam;
use App\Http\Livewire\Components\Informacia\Hodnotenie\Pages\Index as HodnoteniaBackendPageIndex;
use App\Http\Livewire\Components\Informacia\Pages\Index as InformaciaBackendPageIndex;
use App\Http\Livewire\Components\Informacia\Pages\Upravit as InformaciaBackendPageUpravit;
use App\Http\Livewire\Components\Informacia\Pages\Vytvorit as InformaciaBackendPageVytvorit;
use App\Http\Livewire\Frontend\Informacia\Components\Zoznam as InformaciaFrontendComponentZoznam;
use App\Http\Livewire\Frontend\Informacia\Pages\Index as InformaciaFrontendPageIndex;
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', InformaciaBackendPageVytvorit::class);
        Livewire::component('pages.sprava.informacie.livewire.edit', InformaciaBackendPageUpravit::class);
        Livewire::component('pages.sprava.informacie.livewire.list', InformaciaBackendPageIndex::class);
        Livewire::component('pages.sprava.informacie.hodnotenia.livewire.list', HodnoteniaBackendPageIndex::class);
        Livewire::component('pages.frontend.informacia.livewire.index', InformaciaFrontendPageIndex::class);

        // COMPONENTS
        Livewire::component('pages.sprava.informacie.livewire.components.form', HodnoteniaBackendComponentForm::class);
        Livewire::component(
            'pages.sprava.informacie.livewire.components.zoznam',
            InformaciaBackendComponentZoznam::class,
        );
        Livewire::component(
            'pages.sprava.informacie.hodnotenia.livewire.components.zoznam',
            HodnoteniaBackendComponentZoznam::class,
        );
        Livewire::component('frontend.informacie.zoznam', InformaciaFrontendComponentZoznam::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);
    }
}
