<?php

declare(strict_types=1);

namespace App\Livewire\Components\Notifications;

use Illuminate\Support\Collection;
use Livewire\Attributes\On;
use Livewire\Component;

/**
 * Class Simple
 */
abstract class Simple extends Component
{
    protected Collection $userNotifications;

    public function mount($userNotifications = null): void
    {
        if (is_null($userNotifications)) {
            $userNotifications = collect();
        }

        $this->userNotifications = $userNotifications;
    }

    #[On('userNotificationsReadChanged')]
    public function reloadState(): void
    {
        $this->userNotifications = auth()->user()->unreadNotifications;
    }
}
