@extends('layouts.app')

@section('content')
    <div class="container">
        <div>
            <h2 class="pb-2">Editer la consolidation</h2>
        </div>

        @include('layouts.commons.errors')
        @include('layouts.commons.success')

        <form method="POST" action="{{ route('consolidations.update', $consolidation->id) }}">
            @csrf
            {{ method_field('PUT') }}

            <!-- Nom -->
            <div class="form-group row">
                <label for="nom" class="col-md-4 col-form-label text-md-right">Nom<span class="text-danger">*</span></label>
                <div class="col-md-6">
                    <input id="nom" type="text" class="form-control" name="nom" value="{{ old('nom', $consolidation->nom) }}" required autofocus>
                </div>
            </div>

            <!-- Région -->
            <div class="form-group row">
                <label for="region" class="col-md-4 col-form-label text-md-right">Région<span class="text-danger">*</span></label>
                <div class="col-md-6">
                    <select class="form-control" id="region" name="region">
                        <option value="" {{ old('region') == '' ? 'selected' : '' }}>Sélectionner</option>
                        <option value="{{ REGION::AUVERGNE_RHONE_ALPES }}" {{ old('region', $consolidation->region) == REGION::AUVERGNE_RHONE_ALPES ? 'selected' : '' }}>{{ REGION::REGIONS_FORMATTED[REGION::AUVERGNE_RHONE_ALPES] }}</option>
                        <option value="{{ REGION::BOURGOGNE_FRANCHE_COMTE }}" {{ old('region', $consolidation->region) == REGION::BOURGOGNE_FRANCHE_COMTE ? 'selected' : '' }}>{{ REGION::REGIONS_FORMATTED[REGION::BOURGOGNE_FRANCHE_COMTE] }}</option>
                        <option value="{{ REGION::BRETAGNE }}" {{ old('region', $consolidation->region) == REGION::BRETAGNE ? 'selected' : '' }}>{{ REGION::REGIONS_FORMATTED[REGION::BRETAGNE] }}</option>
                        <option value="{{ REGION::CENTRE_VAL_DE_LOIRE }}" {{ old('region', $consolidation->region) == REGION::CENTRE_VAL_DE_LOIRE ? 'selected' : '' }}>{{ REGION::REGIONS_FORMATTED[REGION::CENTRE_VAL_DE_LOIRE] }}</option>
                        <option value="{{ REGION::CORSE }}" {{ old('region', $consolidation->region) == REGION::CORSE ? 'selected' : '' }}>{{ REGION::REGIONS_FORMATTED[REGION::CORSE] }}</option>
                        <option value="{{ REGION::GRAND_EST }}" {{ old('region', $consolidation->region) == REGION::GRAND_EST ? 'selected' : '' }}>{{ REGION::REGIONS_FORMATTED[REGION::GRAND_EST] }}</option>
                        <option value="{{ REGION::HAUTS_DE_FRANCE }}" {{ old('region', $consolidation->region) == REGION::HAUTS_DE_FRANCE ? 'selected' : '' }}>{{ REGION::REGIONS_FORMATTED[REGION::HAUTS_DE_FRANCE] }}</option>
                        <option value="{{ REGION::ILE_DE_FRANCE }}" {{ old('region', $consolidation->region) == REGION::ILE_DE_FRANCE ? 'selected' : '' }}>{{ REGION::REGIONS_FORMATTED[REGION::ILE_DE_FRANCE] }}</option>
                        <option value="{{ REGION::NORMANDIE }}" {{ old('region', $consolidation->region) == REGION::NORMANDIE ? 'selected' : '' }}>{{ REGION::REGIONS_FORMATTED[REGION::NORMANDIE] }}</option>
                        <option value="{{ REGION::NOUVELLE_AQUITAINE }}" {{ old('region', $consolidation->region) == REGION::NOUVELLE_AQUITAINE ? 'selected' : '' }}>{{ REGION::REGIONS_FORMATTED[REGION::NOUVELLE_AQUITAINE] }}</option>
                        <option value="{{ REGION::OCCITANIE }}" {{ old('region', $consolidation->region) == REGION::OCCITANIE ? 'selected' : '' }}>{{ REGION::REGIONS_FORMATTED[REGION::OCCITANIE] }}</option>
                        <option value="{{ REGION::PAYS_DE_LA_LOIRE }}" {{ old('region', $consolidation->region) == REGION::PAYS_DE_LA_LOIRE ? 'selected' : '' }}>{{ REGION::REGIONS_FORMATTED[REGION::PAYS_DE_LA_LOIRE] }}</option>
                        <option value="{{ REGION::PROVENCE_ALPES_COTE_AZUR }}" {{ old('region', $consolidation->region) == REGION::PROVENCE_ALPES_COTE_AZUR ? 'selected' : '' }}>{{ REGION::REGIONS_FORMATTED[REGION::PROVENCE_ALPES_COTE_AZUR] }}</option>
                    </select>
                </div>
            </div>

            <div class="form-group row mb-0">
                <div class="col-md-8 offset-md-4">
                    <button type="submit" class="btn btn-outline-success">
                        Sauvegarder
                    </button>
                    <a href="{{ route('consolidations.index') }}" class="btn btn-outline-warning">Annuler</a>
                </div>
            </div>
        </form>
    </div>
@endsection
