@extends('layouts.admin.theme')
@section("title", env("APP_NAME") . " :: Lista de Banners")
@section('content')
    <div class="card shadow-sm">
        
        @php $headLine = "<i class='fa-regular fa-image'></i> Lista de Banners"; @endphp
        @include('components.buttons._headLineButtonsBackAdd', [
            'headLine' => __($headLine),
//            'routeBack' => 'admin.turismoNautico.index',
//            'routeBackParams' => [], 
//            'nameBack' => __("Voltar"),
            'routeAdd' => 'admin.banners.create',
            'routeAddParams' => [], 
            'nameAdd' => __('Novo banner'),
            "permission" => "GERENCIADOR_DE_BANNERS",
        ])
        
        <div class="card-body">
            
            @include("errors.messageFlash")
            
            <x-tables._table :thead="['#', 'Data de Publicação', 'Título', 'Link', 'Ordem', 'Seção', 'Status', 'Ações']" :pagination="$banners->links()">
                <x-slot name="body">
                    @php $index = 0; @endphp
                        @foreach($banners as $banner)
                            <tr>
                                <td>
                                    @include('components.tables._openPhoto', [
                                        'asset' => $banner->photo,
                                        'alt' => $banner->title,
                                        'title' => $banner->title,
                                        'text' => 'Visualizar foto',
                                        'style' => 'width: 200px',
                                        'index' => $index,
                                    ])
                                </td>
                                <td> {{ date("d/m/Y H:m:s", strtotime($banner->created_at)) }} </td>
                                <td>{{ $banner->title }}</td>
                                <td>
                                    <div class="d-flex gap-2 justify-content-center">
                                        @include('components.buttons._navButton', [
                                            "link" => $banner->url,
                                            "target" => "_blank",
                                            "fontawesome" => '<i class="fa-solid fa-link"></i>',
                                            "title" => "Acessar página",
                                        ])
                                    </div>
                                </td>
                                <td> {{ $banner->order }} </td>
                                <td>
                                    @foreach(App\Enums\StatusSectionBanner::cases() as $section)
                                        @if($section->name == $banner->section)
                                            {{ $section->value }}
                                        @endif
                                    @endforeach
                                </td>
                                <td>
                                    @include('components/buttons/_status', [
                                        "index" => $index,
                                        "route" => "admin.banners.status",
                                        "id" => [$banner->id],
                                        "status" => $banner->status,
                                        "permission" => "GERENCIADOR_DE_BANNERS",
                                    ])

                                </td>
                                <td>
                                    <div class="d-flex gap-2 justify-content-center">

                                        @include('components/buttons/_editButton', [
                                                "route" => "admin.banners.edit",
                                                "id" => [$banner->id],
                                                "fontawesome" => null,
                                                "title" => "Editar",
                                                "permission" => "GERENCIADOR_DE_BANNERS",
                                            ])

                                        @include('components/buttons/_deleteButton', [
                                                "message" => __("* Este banner será excluído e esta ação não poderá ser desfeita, deseja continuar?"),
                                                "route" => "admin.banners.destroy",
                                                "id" => [$banner->id],
                                                "fontawesome" => null,
                                                "title" => "Excluir",
                                                "permission" => "GERENCIADOR_DE_BANNERS",
                                            ])
                                    </div>
                                </td>
                            </tr>
                            @php $index++; @endphp
                        @endforeach
                </x-slot>
            </x-tables._table>
        </div>
    </div>
@endsection