{% extends 'layout.twig' %}
{% block title %}Submit a Ticket — {{ brand.name }}{% endblock %}
{% block content %}
    <section class="page-head">
        <div class="container">
            <h1>Submit a Support Ticket</h1>
            <p class="lead">Tell us what's going on and we'll get back to you by email.</p>
        </div>
    </section>
    <section class="container narrow">
        <form action="{{ app_url('/tickets/new') }}" method="post" enctype="multipart/form-data" class="form">
            {{ csrf_field()|raw }}

            {% if not current_user %}
                <div class="form-row two">
                    <div>
                        <label>Your Name</label>
                        <input type="text" name="name" value="{{ old('name') }}" required>
                    </div>
                    <div>
                        <label>Your Email</label>
                        <input type="email" name="email" value="{{ old('email') }}" required>
                    </div>
                </div>
            {% endif %}

            <div class="form-row">
                <label>Subject</label>
                <input type="text" name="subject" value="{{ old('subject') }}" required maxlength="250">
            </div>

            {% if departments|length > 0 %}
            <div class="form-row">
                <label>Department</label>
                <select name="department_id">
                    <option value="">— Choose —</option>
                    {% for d in departments %}
                        <option value="{{ d.id }}" {{ old('department_id') == d.id ? 'selected' : '' }}>{{ d.name }}</option>
                    {% endfor %}
                </select>
            </div>
            {% endif %}

            <div class="form-row">
                <label>Describe the issue</label>
                <textarea name="body" id="ticket-body" rows="10" required>{{ old('body') }}</textarea>
            </div>

            <div class="form-row">
                <label>Attachments <span class="muted small">(optional, up to 10MB each)</span></label>
                <input type="file" name="attachments[]" multiple>
            </div>

            <div class="form-actions">
                <button type="submit" class="btn btn-primary">Submit Ticket</button>
                <a href="{{ app_url('/') }}" class="btn btn-light">Cancel</a>
            </div>
        </form>
    </section>
{% endblock %}
{% block scripts %}
{% include 'partials/tinymce.twig' with {selector: '#ticket-body', allow_images: false} %}
{% endblock %}
