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

{% block content %}
<div class="card">
    <div class="card-body">
        <h5>{{ 'Canned response'|trans }}</h5>
        <p class="text-muted">{{ response.title }}</p>

        <form method="post" action="{{ 'api/admin/support/canned_update'|link }}" class="api-form" data-api-redirect="{{ 'support/canned-responses'|alink }}">
            <input type="hidden" name="CSRFToken" value="{{ CSRFToken }}"/>
            <div class="mb-3 row">
                <label class="form-label col-3 col-form-label">{{ 'Category'|trans }}:</label>
                <div class="col">
                    {{ mf.selectbox('category_id', admin.support_canned_category_pairs, response.category.id, 1) }}
                </div>
            </div>
            <div class="mb-3 row">
                <label class="form-label col-3 col-form-label">{{ 'Title'|trans }}:</label>
                <div class="col">
                    <input class="form-control" type="text" name="title" value="{{ response.title }}" required>
                </div>
            </div>
            <div class="mb-3 row">
                <label class="form-label col-3 col-form-label">{{ 'Message'|trans }}:</label>
                <div class="col">
                    <textarea class="bb-textarea" name="content" rows="10">{{ response.content }}</textarea>
                </div>
            </div>

            <input type="hidden" name="id" value="{{ response.id }}">
            <input type="submit" value="{{ 'Update'|trans }}" class="btn btn-primary w-100">
        </form>
    </div>
</div>
{% endblock %}

{% block head %}{{ mf.bb_editor('.bb-textarea') }}{% endblock %}
