@extends('layouts.main')

@section('content')
    <form id="add-form" method="POST" action="{{ route('save') }}">
        {{ csrf_field() }}
        <div class="form-row justify-content-md-center">
            <div class="col-4">
                <select name="location" class="form-control select2-location">
                    @foreach ($locations as $location)
                        <option value="{{ $location->name }}">{{ $location->name }}</option>
                    @endforeach
                </select>
            </div>
        </div>
        <br />
        <div class="row-container">
            @if (!empty($old))
                @foreach ($old as $index => $item)
                    @include('partials/row', [ 'index' => $index, 'item' => $item ])
                @endforeach
                @include('partials/row', [ 'index' => count($old), 'item' => [] ])
            @else
                @include('partials/row', [ 'index' => 0])
            @endif
        </div>
        <div class="row">
            <div class="col-2">
                <button class="btn btn-primary" name="save" type="submit" style="width:100%">
                    Save
                </button>
            </div>
        </div>
    </form>
    @include('partials/row', [ 'id' => 'add-template', 'htmlClass' => 'invisible' ])
@endsection