{% extends request.ajax ? 'layout_blank.html.twig' : 'layout_default.html.twig' %}

{% import 'macro_functions.html.twig' as mf %}

{% block meta_title %}{{ 'Canned Response'|trans }}{% endblock %}

{% set active_menu = 'support' %}

{% block breadcrumbs %}
    <ol class="breadcrumb">
        <li class="breadcrumb-item">
            <a href="{{ '/'|url }}">
                <svg class="icon">
                    <use xlink:href="#home" />
                </svg>
            </a>
        </li>
        <li class="breadcrumb-item">
            <a href="{{ 'support'|url }}">{{ 'Support'|trans }}</a>
        </li>
        <li class="breadcrumb-item">
            <a href="{{ 'support/canned-responses'|url }}">{{ 'Canned Responses'|trans }}</a>
        </li>
        <li class="breadcrumb-item active" aria-current="page">{{ response.title }}</li>
    </ol>
{% endblock %}

{% block content %}
<div class="card">
    <form method="post" action="{{ 'support/canned_update'|api_url }}" {{ fb_api_form({ redirect: 'support/canned-responses'|url }) }}>
        {% embed 'partial_admin_form_card.html.twig' with {
            title: 'Canned Response'|trans,
            subtitle: response.title,
            body_class: 'pt-4'
        } %}
            {% import 'macro_functions.html.twig' as mf %}
            {% block form_content %}
                <div class="row g-3">
                    <div class="col-lg-6">
                        <label class="form-label">{{ 'Category'|trans }}</label>
                        {{ mf.selectbox('category_id', admin.support_canned_category_pairs, response.category.id, 1) }}
                    </div>
                    <div class="col-lg-6">
                        <label class="form-label">{{ 'Title'|trans }}</label>
                        <input class="form-control" type="text" name="title" value="{{ response.title }}" required>
                    </div>
                    <div class="col-12">
                        <label class="form-label">{{ 'Message'|trans }}</label>
                        <textarea class="editor-textarea" name="content" rows="10">{{ response.content }}</textarea>
                    </div>
                </div>
                <input type="hidden" name="id" value="{{ response.id }}">
            {% endblock %}

            {% block form_actions %}
                <button class="btn btn-primary" type="submit">{{ 'Update'|trans }}</button>
            {% endblock %}
        {% endembed %}
    </form>
</div>
{% endblock %}

{% block head %}{{ wysiwyg('.editor-textarea') }}{% endblock %}
