@extends('layout/template')

@section('content')
    <div class="row" style="margin-top: 20px;">
        <div class="col-md-12">
            <h1>Gallery</h1>
            @if ($errors->any())
                <div class="alert alert-danger">
                    <ul>
                        @foreach ($errors->all() as $error)
                            <li>{{ $error }}</li>
                        @endforeach
                    </ul>
                </div>
            @endif
        </div>
    </div>
    <div class="row">
        <div class="col-md-9">
            <form method="post">
                @csrf
                <input name="name" value="{{ old('name') ?? $gallery->name }}" placeholder="Name" class="form-control">
                <textarea name="description"  style="height: 300px;" placeholder="Description" class="form-control">{{ old('description') ?? $gallery->description }}</textarea>

                <div class="accordion" id="accordionExample">

                    <div class="card">
                        <div class="card-header" id="headingTwo">
                            <h2 class="mb-0">
                                <button class="btn btn-link btn-block text-left collapsed" type="button" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
                                    Advanced Settings
                                </button>
                            </h2>
                        </div>
                        <div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordionExample">
                            <div class="card-body">
                                <input name="date" value="{{ old('date') ?? $gallery->gallery_create_time }}" class="form-control" placeholder="Create Date (yyyy-mm-dd, today if empty)">
                                <input name="url" value="{{ old('url') ?? $gallery->url }}" placeholder="URL" class="form-control">
                            </div>
                        </div>
                    </div>

                </div>


        </div>
        <div class="col-md-3">
            <div class="custom-control custom-switch">
                <b>Status</b>
                <select name="status" class="custom-select" id="exampleSelect2"">
                    <option @if ($status == "preview") selected @endif value="preview">Preview</option>
                    <option @if ($status == "online") selected @endif value="online">Online</option>
                    <option @if ($status == "archiv") selected @endif value="archiv">Archiv</option>
                    <option @if ($status == "deleted") selected @endif value="deleted" disabled>Deleted</option>
                </select>

                <div class="custom-control custom-switch"  style="margin-top: 10px;">
                    <input type="checkbox" class="custom-control-input" name="listed" id="customSwitch1" @if ($listed) checked @endif>
                    <label class="custom-control-label" for="customSwitch1">List Gallery for Tenant</label>
                </div>
                <div style="margin-top: 20px;border-top: 1px solid grey;padding-top: 10px;">
                    <b>Tags (sperate by comma)</b>
                    <textarea class="form-control" name="tags" rows="3" placeholder="Tags">{{ old('tags') ?? $tags }}</textarea>
                </div>
                <div style="margin-top: 10px;">
                    @if (!empty($gallery->url))
                        <a href="/{{ $current_tenant->url }}/{{ $gallery->url }}/" class="btn btn-outline-primary" style="width: 48%">View Gallery</a>
                        <a href="/g/{{$gallery->url}}" class="btn btn-outline-primary" style="width: 48%;float: right;">Editn Images</a>
                    @endif
                    <input type="submit" class="btn btn-outline-success" value="Save" style="margin-top: 10px; width: 100%;">
                </div>
            </div>
        </div>
        </form>
    </div>
@endsection
