<div>
    @component('common.breadcrumb', ['addBtn' => false, 'permission_create' => 'notifications_index',
        'breadcrumb_show' => $breadcrumb_show])
        @slot('breadcrumb_title')
            <h3>{{ $componentName }} | {{ $pageTitle }}</h3>
        @endslot
        <li class="breadcrumb-item">{{ $componentName }}</li>
        <li class="breadcrumb-item active">Notificaciones </li>
    @endcomponent
    <div class="container-fluid">
        <div class="row layout-top-spacing">
            <div class="col-sm-12">
                <div class="card">
                    <div class="card-body">
                        <div class="card-header">
                            <h4>Notificaciones <b> | {{ $first_name }} {{ $last_name }}</b></h4>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="row justify-content-center">
            <div class="col-lg-4 col-md-4 col-sm-12">
                <div class="form-group">
                    <select class="form-select" wire:model="status_notifications">
                        <option value="all">Todas la notificaciones</option>
                        <option value="unread">Notificaciones sin leer</option>
                        <option value="read">Notificaciones leídas</option>
                    </select>
                </div>
            </div>

        </div><!-- row -->

        <div class="row justify-content-between file-content mb-2">
            <div class="col-lg-4 col-md-4 col-sm-12">
                <div class="form-inline">
                    <div class="form-group d-flex mb-0"><i class="fa fa-search"></i>
                        <input class="form-control-plaintext" type="text" wire:model="search" placeholder="Buscar...">
                    </div>
                </div>
            </div>
            @if (isset($count))
                <div class="col-lg-4 col-md-4 col-sm-12">
                    <p class="p-l-20">Total Notificaciones: {{ $count }}</p>
                </div>
            @endif

        </div>
    </div><!-- container-fluid -->
    <div class="container-fluid">
        <div class="row layout-top-spacing">
            <div class="col-sm-12">
                <div class="card">
                    <div class="table-responsive">
                        <table class="table">
                            @if ($count > 0)
                            <thead class="bg-primary">
                                <tr>
                                    <th scope="col">NOTIFICACIÓN</th>
                                    <th scope="col">ESTADO</th>
                                    <th scope="col">FECHA</th>
                                    <th scope="col" class="text-center">ACCIONES</th>
                                </tr>
                            </thead>
                            <tbody>

                                @foreach ($notifications as $item)
                                <tr>
                                    <td>{{ $item->data['message'] }}</td>
                                    <td>
                                        @if ($item->read_at == null)
                                            <span class="badge badge-pill badge-primary">Sin leer</span>
                                        @else
                                            <span class="badge badge-pill badge-success">Leído</span>
                                        @endif
                                    <td>{{ $item->created_at->format('d-m-Y H:i:s') }} -- <b> {{ $item->created_at->diffForHumans() }}</b></td>
                                    <td class="text-center">
                                        <a href="{{ $item->data['url'] }}" class="btn btn-primary btn-sm" wire:click="markNotificationAsRead('{{ $item->id }}')">
                                            <i class="fa fa-eye"></i>
                                        </a>
                                    </td>
                                </tr>
                                @endforeach
                            @else
                                <div class="card">
                                    <div class="card-header text-center">
                                        <h5 class="text-danger">No tiene Notificaciones</h5>
                                    </div>
                                </div>
                            @endif
                            </tbody>
                        </table>
                    </div>
                    {{ $notifications->links() }}
                </div>
            </div><!-- col -->
        </div><!-- row -->
    </div><!-- container-fluid -->

</div>

@include('common.scriptsCompStandar')
