<div class="accordion" id="notification-imports">
    <div class="card">
        <div class="card-header" id="heading-imports" data-toggle="collapse" data-target="#collapse-imports"
                aria-expanded="false" aria-controls="collapse-imports">
            <div class="row align-items-center">
                <div class="col-12">
                    <h3 class="mb-0">
                        {{ trans('import.import') }}

                        @if ($notifications->total())
                        <button type="button" class="btn btn-outline-success rounded-circle btn-icon-only btn-sm mr-2 d-none"
                                data-toggle="tooltip"
                                data-placement="right"
                                title="{{ trans('notifications.mark_read_all') }}"
                                wire:click="markReadAll()"
                            >
                                <span class="btn-inner--icon"><i class="fas fa-check-double"></i></span>
                            </button>
                        @endif
                    </h3>
                </div>
            </div>
        </div>

        <div id="collapse-imports" class="collapse" aria-labelledby="heading-imports" data-parent="#notification-imports">
            @if ($notifications->total())
                <div class="table-responsive">
                    <table class="table table-flush table-hover" id="tbl-import">
                        <tbody>
                            @foreach ($notifications as $notification)
                                <tr class="row align-items-center border-top-1">
                                    <td class="col-xs-8 col-sm-10 col-md-10 col-lg-11 col-xl-11 text-left text-wrap">
                                        @if (empty($notification->errors))
                                            {!! trans('notifications.messages.import', [
                                                'type' => $notification->translation,
                                                'count' => $notification->total_rows
                                            ]) !!}
                                        @else
                                            @foreach ($notification->errors as $error)
                                                {!! $error !!}
                                            @endforeach
                                        @endif
                                    </td>

                                    <td class="col-xs-4 col-sm-2 col-md-2 col-lg-1 col-xl-1 text-center">
                                        <button type="button" class="btn btn-outline-success rounded-circle btn-icon-only btn-sm"
                                            data-toggle="tooltip"
                                            data-placement="right"
                                            title="{{ trans('notifications.mark_read') }}"
                                            wire:click="markRead('{{ $notification->notification_id }}')"
                                        >
                                            <span class="btn-inner--icon"><i class="fa fa-check"></i></span>
                                        </button>
                                    </td>
                                </tr>
                            @endforeach
                        </tbody>
                    </table>
                </div>

                @if ($notifications->total() > 5)
                    <div class="card-footer table-action">
                        <div class="row">
                            @if ($notifications->count())
                                <div class="col-xs-12 col-sm-5 d-flex align-items-center">
                                    {!! Form::select('limit', ['5' => '5'], request('limit', 5), ['class' => 'disabled form-control form-control-sm d-inline-block w-auto d-none d-md-block', 'disabled' => 'disabled']) !!}
                                    <span class="table-text d-none d-lg-block ml-2">
                                        {{ trans('pagination.page') }}
                                        {{ trans('pagination.showing', ['first' => $notifications->firstItem(), 'last' => $notifications->lastItem(), 'total' => $notifications->total()]) }}
                                    </span>
                                </div>

                                <div class="col-xs-12 col-sm-7 pagination-xs">
                                    <nav class="float-right">
                                        {!! $notifications->withPath(request()->url())->withQueryString()->links() !!}
                                    </nav>
                                </div>
                            @else
                                <div class="col-xs-12 col-sm-12" id="datatable-basic_info" role="status" aria-live="polite">
                                    <small>{{ trans('general.no_records') }}</small>
                                </div>
                            @endif
                        </div>
                    </div>
                @endif
            @else
                <div class="col-xs-12 col-sm-12 mt-4 mb-4 text-center">
                    <small>{{ trans('general.no_records') }}</small>
                </div>
            @endif
        </div>
    </div>
</div>

@push('body_js')
    <script type="text/javascript">
        window.addEventListener('mark-read', event => {
            if (event.detail.type == 'import') {
                $.notify(event.detail.message, {
                    type: 'success',
                });
            }
        });

        window.addEventListener('mark-read-all', event => {
            if (event.detail.type == 'import') {
                $.notify(event.detail.message, {
                    type: 'success',
                });
            }
        });
    </script>
@endpush
