{{ define "title" }}Edit Event{{ end }}
{{ define "content" }}
<form action="/e/admin/edit" method="POST">
<input type="hidden" name="_csrf" value="{{ .CSRF }}">
{{ if .Data.preview }}
<div class="card mb-5">
    <div class="card-header">
        Preview
    </div>
    <div class="card-body">
        <h1>{{ .Data.event.Title }}</h1>

        {{ if .Data.event.Location }}
        <address>{{ .Data.event.Location }}</address>
        {{ end }}

        {{ .Data.preview }}
    </div>
</div>
{{ end }}

{{ with .Data.event }}
<input type="hidden" name="id" value="{{ or .ID "" }}">
<div class="card">
    <div class="card-body">
        <h1>Edit Event</h1>

        <div class="form-row">
            <div class="form-group col-12">
                <label for="title">Event Title:</label>
                <input type="text"
                    name="title"
                    id="title"
                    class="form-control"
                    value="{{ .Title }}"
                    placeholder="Event Title Goes Here">
            </div>

            <div class="form-group col-md-6">
                <label for="start_date">Start Time:</label>
                <div class="form-row">
                    <div class="col">
                        <input type="date"
                            name="start_date"
                            id="start_date"
                            class="form-control"
                            value="{{ .StartTime.Format "2006-01-02" }}"
                            placeholder="YYYY-MM-DD">
                    </div>
                    <div class="col">
                        <input type="time"
                            name="start_time"
                            id="start_time"
                            class="form-control"
                            value="{{ .StartTime.Format "15:04" }}"
                            placeholder="HH:MM">
                    </div>
                </div>
            </div>
            <div class="form-group col-md-6">
                <label for="end_date">End Time:</label>
                <label class="ml-4">
                    <input type="checkbox"
                        name="all_day"
                        value="true">
                        All day
                </label>
                <div class="form-row">
                    <div class="col">
                        <input type="date"
                            name="end_date"
                            id="end_date"
                            class="form-control"
                            value="{{ .EndTime.Format "2006-01-02" }}"
                            placeholder="YYYY-MM-DD">
                    </div>
                    <div class="col">
                        <input type="time"
                            name="end_time"
                            id="end_time"
                            class="form-control"
                            value="{{ .EndTime.Format "15:04" }}"
                            placeholder="HH:MM">
                    </div>
                </div>
            </div>

            <div class="form-group col-12">
                <label for="location">Location:</label>
                <textarea
                    name="location"
                    id="location"
                    class="form-control"
                    cols="80"
                    rows="3"
                    placeholder="123 Nowhere Drive">{{ .Location }}</textarea>
            </div>

            <div class="form-group col-12">
                <label for="description">Description (<a href="/markdown" target="_blank">Markdown</a> supported):</label>
                <textarea
                    name="description"
                    id="description"
                    class="form-control text-monospace"
                    cols="80"
                    rows="12"
                    placeholder="Come to my awesome event!">{{ .Description }}</textarea>
            </div>

            <div class="form-group col-12">
                <label for="fragment">Custom URL fragment (<abbr title="a-z 0-9 - . _">URL-safe characters only</abbr>):</label>
                <input type="text"
                    name="fragment"
                    id="fragment"
                    class="form-control"
                    pattern="[A-Za-z0-9\-_.]*"
                    value="{{ .Fragment }}"
                    placeholder="example: spring-break-2032">
            </div>

            <div class="col-12">
                <button type="submit"
                    name="submit"
                    value="preview"
                    class="btn btn-primary">Preview</button>
                <button type="submit"
                    name="submit"
                    value="save"
                    class="btn btn-success">Save</button>
            </div>
        </div>
    </div>
</div>
{{ end }}

</form>

{{ end }}
