@extends('layouts.admin.theme')
@section("title", env("APP_NAME") . " :: Atualizar Boletim")
@section('content')
    <form action="{{ route('admin.boletins.update', $boletim->id) }}" method="post" enctype="multipart/form-data">
        <div class="container">
            <div class="row">
                <div class="col-12">
                    <div class="card shadow">
                        @include('components.buttons._headLineButtonsBackAdd', [
                            'headLine' => __("Atualizar Boletim"),
                            'routeBack' => 'admin.boletins.index',
                            'routeBackParams' => [], 
                            'nameBack' => __("Voltar"),
                        ])
                        <div class="card-body">
                            @csrf
                            @method('patch')
                            @include("errors.messageFlash")

                            <div class="mb-3">
                                <input type='hidden' name='id' value='{{ old('id', $boletim->id) }}'>
                                <input type="hidden" name="page" value="{{ request()->input('page', 1) }}">

                            <!-- Campo Data -->
                                @include('components.inputs._inputType',[
                                        "for" => null,
                                        "label" => "Data",
                                        "name" => "publicationDate",
                                        "id" => null,
                                        "required" => true,
                                        "type" => "date",
                                        "old" => old('publicationDate', $boletim->publicationDate),
                                        "oninput" => null,
                                        "readonly" => false,
                                        "small" => null,
                                    ])

                            </div>
                            <div class="mb-3">

                            <!-- Campo Mês -->
                                @include('components.inputs._selectType', [
                                        "for" => null,
                                        "label" => "Mês",
                                        "name" => "month",
                                        "required" => true,
                                        "readonly" => false,
                                        "options" => collect(App\Enums\StatusMonth::cases())
                                            ->mapWithKeys(fn($status) => [$status->name => $status->value])
                                            ->toArray(),
                                        "selected" => old('month', $boletim->month),
                                        "placeholder" => "Selecione um mês...",
                                        "small" => "Informe o do boletim.",
                                        "onchange" => null
                                    ])

                            </div>
                            <div class="mb-3">

                            <!-- Campo Número -->
                                @include('components.inputs._inputType',[
                                        "for" => null,
                                        "label" => "Número",
                                        "name" => "number",
                                        "id" => null,
                                        "required" => true,
                                        "type" => null,
                                        "old" => old('number', $boletim->number),
                                        "oninput" => "javascript:this.value = this.value.replace(/\D/g, '')",
                                        "readonly" => false,
                                        "small" => null,
                                    ])

                            </div>

                            <div class="mb-3">

                            <!-- Campo Título -->
                                @include('components.inputs._inputType',[
                                        "for" => null,
                                        "label" => "Título",
                                        "name" => "title",
                                        "id" => null,
                                        "required" => true,
                                        "type" => null,
                                        "old" => old('title', $boletim->title),
                                        "oninput" => "javascript:this.value = this.value.toUpperCase()",
                                        "readonly" => false,
                                        "small" => null,
                                    ])

                            </div>

                            <div class="form-check mb-3">
                                <input class="form-check-input" type="checkbox" name="extraordinaryEdition" {{ old('extraordinaryEdition', $boletim->extraordinaryEdition) ? 'checked' : '' }}>
                                <label class="form-check-label" for="extraordinaryEdition"> Edição Extraordinária </label>
                            </div>

                            <div class="mb-3">
                            <!-- Campo Comprovante -->
                                @include('components.inputs._inputType',[
                                            "for" => null,
                                            "label" => "Arquivo",
                                            "name" => "url",
                                            "id" => null,
                                            "required" => false,
                                            "type" => 'file',
                                            "old" => null,
                                            "oninput" => null,
                                            "readonly" => true,
                                            "small" => null,
                                            "accept" => '.pdf',
                                        ])
                            </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', $boletim->status),
                                        "placeholder" => "Selecione o status...",
                                        "small" => "Informe o status atual do usuário.",
                                        "onchange" => null
                                    ])

                            </div>
                            @include('components.buttons._backAndSend', [
                                    'textBack' => 'Voltar', 
                                    'textSend' => 'Atualizar', 
                                    'routeBack' => 'admin.boletins.index'
                                ]
                            )
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
@endsection