@extends('layouts.admin.theme')
@section("title", env("APP_NAME") . " :: Atualizar Banner")
@section('content')
    <form action="{{ route('admin.banners.update', $banner->id) }}" method="post" enctype="multipart/form-data">
        <div class="container mt-4">
            <div class="row">
                <div class="col-12">
                    <div class="card shadow">

                        @include('components.buttons._headLineButtonsBackAdd', [
                            'headLine' => __("Atualizar Banner"),
                            'routeBack' => 'admin.banners.index',
                            'routeBackParams' => [], 
                            'nameBack' => __("Voltar"),
                        ])

                        <div class="card-body">
                            <input type='hidden' name='id' value='{{ old('id', $banner->id) }}'>
                            <input type="hidden" name="page" value="{{ request()->input('page', 1) }}">
                            @csrf
                            @method('patch')

                            @include("errors.messageFlash")

                            <div class="mb-3">
                                    <input type="hidden" name="page" value="{{ request()->input('page', 1) }}">
                                    
                                    @include('components.inputs._inputType',[
                                        "for" => null,
                                        "label" => "Titulo ou nome da campanha",
                                        "name" => "title",
                                        "id" => null,
                                        "required" => true,
                                        "type" => "text",
                                        "old" => old('order', $banner->title),
                                        "oninput" => null,
                                        "readonly" => false,
                                        "small" => null,
                                    ])
                                    
                                </div>
                                <div class="mb-3">
                                    @include('components.inputs._inputType',[
                                        "for" => null,
                                        "label" => "Link",
                                        "name" => "url",
                                        "id" => null,
                                        "required" => true,
                                        "type" => "url",
                                        "old" => old('order', $banner->url),
                                        "oninput" => null,
                                        "readonly" => false,
                                        "small" => null,
                                    ])
                                </div>
                                <div class="mb-3">
                                    
                                    @include('components.inputs._selectType', [
                                        "for" => "target",
                                        "label" => "Tipo de link",
                                        "name" => "target",
                                        "required" => true,
                                        "readonly" => false,
                                        "options" => collect(App\Enums\StatusLinkEnum::cases())
                                            ->mapWithKeys(fn($status) => [$status->name => $status->value])
                                            ->toArray(),
                                        "selected" => old('section', $banner->target ?? ''),
                                        "placeholder" => "Selecione um tipo...",
                                        "small" => "Informe o tipo de link.",
                                        "onchange" => null
                                    ])
                                    
                                </div>
                                <div class="mb-3">

                                    @include('components.tables._openPhoto', [
                                        'asset' => $banner->photo ?? "pmar/assets/img/icons/photoLG-940x130px.png",
                                        'alt' => $banner->title,
                                        'title' => $banner->title,
                                        'text' => 'Visualizar foto',
                                        'style' => 'width: 900px',
                                        'index' => 1,
                                    ])

                                    <br>
                                    <!-- Campo Banner Large (940px x 130px) -->
                                    @include('components.inputs._inputType',[
                                        "for" => null,
                                        "label" => "Banner Large (940px x 130px)",
                                        "name" => "photo",
                                        "id" => null,
                                        "required" => true,
                                        "type" => 'file',
                                        "old" => null,
                                        "oninput" => null,
                                        "readonly" => true,
                                        "small" => null,
                                        "accept" => 'image/jpeg,image/jpg,image/png,image/gif',
                                    ])
                                </div>
                                <div class="mb-3">
                                    @include('components.tables._openPhoto', [
                                        'asset' => $banner->photoMD ?? "pmar/assets/img/icons/photoMD-1024x600px.png",
                                        'alt' => $banner->title,
                                        'title' => $banner->title,
                                        'text' => 'Visualizar foto',
                                        'style' => 'width: 500px',
                                        'index' => 2,
                                    ])

                                    <br>
                            <!-- Campo Banner Médio (1024px x 600px) -->
                                    @include('components.inputs._inputType',[
                                        "for" => null,
                                        "label" => "Banner Médio (1024px x 600px)",
                                        "name" => "photoMD",
                                        "id" => null,
                                        "required" => false,
                                        "type" => 'file',
                                        "old" => null,
                                        "oninput" => null,
                                        "readonly" => true,
                                        "small" => null,
                                        "accept" => 'image/jpeg,image/jpg,image/png,image/gif',
                                    ])
                                </div>
                                <div class="mb-3">

                                    @include('components.tables._openPhoto', [
                                        'asset' => $banner->photoSM ?? "pmar/assets/img/icons/photoSM-1080x1350px.png",
                                        'alt' => $banner->title,
                                        'title' => $banner->title,
                                        'text' => 'Visualizar foto',
                                        'style' => 'width: 300px',
                                        'index' => 3,
                                    ])

                                    <br>
                            <!-- Campo Banner Small (1080px x 1350px) -->
                                    @include('components.inputs._inputType',[
                                        "for" => null,
                                        "label" => "Banner Small (1080px x 1350px)",
                                        "name" => "photoSM",
                                        "id" => null,
                                        "required" => false,
                                        "type" => 'file',
                                        "old" => null,
                                        "oninput" => null,
                                        "readonly" => true,
                                        "small" => null,
                                        "accept" => 'image/jpeg,image/jpg,image/png,image/gif',
                                    ])
                                </div>
                                <div class="mb-3">
                                    @include('components.inputs._inputType',[
                                        "for" => null,
                                        "label" => "Ordem de exibição",
                                        "name" => "order",
                                        "id" => null,
                                        "required" => true,
                                        "type" => null,
                                        "old" => old('order', $banner->order),
                                        "oninput" => "javascript:this.value = this.value.replace(/\D/g, '')",
                                        "readonly" => false,
                                        "small" => null,
                                    ])
                                </div>
                                <div class="mb-3">
                                    @include('components.inputs._selectType', [
                                        "for" => "section",
                                        "label" => "Exibição em",
                                        "name" => "section",
                                        "required" => true,
                                        "readonly" => false,
                                        "options" => collect(App\Enums\StatusSectionBanner::cases())
                                            ->mapWithKeys(fn($status) => [$status->name => $status->value])
                                            ->toArray(),
                                        "selected" => old('section', $banner->section ?? ''),
                                        "placeholder" => "Selecione uma seção...",
                                        "small" => "Informe a seção onde o banner deverá aparecer.",
                                        "onchange" => null
                                    ])
                                </div>
                                <div class="mb-3">
                                    @include('components.inputs._selectType', [
                                        "for" => "status",
                                        "label" => "Status",
                                        "name" => "status",
                                        "required" => true,
                                        "readonly" => false,
                                        "options" => collect(App\Enums\StatusEnum::cases())
                                            ->mapWithKeys(fn($status) => [$status->name => $status->value])
                                            ->toArray(),
                                        "selected" => old('status', $banner->status ?? ''),
                                        "placeholder" => "Selecione o status...",
                                        "small" => "Informe o status atual do usuário.",
                                        "onchange" => null
                                    ])
                                </div>
                                @include('components.buttons._backAndSend', [
                                        'url' => 'admin.banners.index', 
                                        'textBack' => 'Voltar', 
                                        'textSend' => 'Atualizar', 
                                        'routeBack' => 'admin.banners.index'
                                    ]
                                )
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    @endsection