{{define "title"}}{{.PageTitle}}{{end}}
{{define "content"}}
<div class="container">
    <section class="hero is-info is-bold">
        <div class="hero-body">
            <div class="container">
                <h1 class="title">
                    {{.PageTitle}}
                </h1>
            </div>
        </div>
    </section>

    <div class="block p-4">
        <div class="columns is-centered">
            <div class="column is-half">

                <div class="card" style="width: 100%; max-width: 640px">
                    <header class="card-header has-background-link">
                        <p class="card-header-title has-text-light">
                            <span class="icon"><i class="fa fa-message"></i></span>
                            <span>{{.PageTitle}}</span>
                        </p>
                    </header>
                    <div class="card-content">

                        <form action="/contact" method="POST">
                            {{InputCSRF}}
                            <input type="hidden" name="intent" value="{{.Intent}}">
                            <input type="hidden" name="id" value="{{.TableID}}">

                            <p class="block">
                                You may use this form to contact the site administrators to provide
                                feedback, criticism, or to report a problem you have found on the
                                site such as inappropriate content posted by one of our members.
                            </p>

                            <div class="field block">
                                <label for="subject" class="label">Subject</label>
                                <div class="select is-fullwidth">
                                    {{$Subject := .Subject}}
                                    <select name="subject" id="subject"{{if ne $Subject ""}} disabled{{end}}>
                                        {{range .Subjects}}
                                        <optgroup label="{{.Header}}">
                                            {{range .Options}}
                                            <option value="{{.Value}}"{{if eq $Subject .Value}} selected{{end}}>{{.Label}}</option>
                                            {{end}}
                                        </optgroup>
                                        {{end}}
                                    </select>
                                </div>

                                <!-- In case the selectbox is disabled -->
                                {{if ne .Subject ""}}<input type="hidden" name="subject" value="{{.Subject}}">{{end}}
                            </div>

                            <!-- If they are reporting on a TableID and we have a label, show it -->
                            {{if ne .TableLabel ""}}
                            <div class="field block">
                                <label class="label">About</label>
                                <p>{{.TableLabel}}</p>
                            </div>
                            {{end}}

                            <div class="field block">
                                <label for="message" class="label">Message{{if not .MessageRequired}} (optional){{else}} (required){{end}}</label>
                                <textarea class="textarea" cols="80" rows="4"
                                    name="message"
                                    id="message"
                                    placeholder="Message"
                                    {{if .MessageRequired}}required{{end}}>{{.Message}}</textarea>
                                {{if not .MessageRequired}}
                                <p class="help">
                                    Write a description of the problem (optional).
                                </p>
                                {{end}}
                            </div>

                            {{if not .LoggedIn}}
                            <div class="field block">
                                <label for="email" class="label">Reply To (optional)</label>
                                <input type="email" class="input"
                                    name="email" id="email"
                                    placeholder="name@domain.com">
                                <p class="help">
                                    Optional; you are not logged in to an account so you <em>MAY</em> leave us
                                    a reply-to email address if you would like a response to your feedback.
                                </p>
                            </div>
                            {{end}}

                            <div class="field has-text-centered">
                                <button type="submit" class="button is-success">
                                    Send Message
                                </button>
                            </div>
                        </form>

                    </div>
                </div>

            </div>
        </div>
    </div>

</div>

<script type="text/javascript">
    window.addEventListener("DOMContentLoaded", (event) => {
        let $file = document.querySelector("#file"),
            $fileName = document.querySelector("#fileName");

        $file.addEventListener("change", function() {
            let file = this.files[0];
            $fileName.innerHTML = file.name;
        });
    });
</script>
{{end}}