{% extends '@CpCreationVitiCore/admin/base.html.twig' %}

{% block content %}
    <h1 class="page-header">{{ 'emailing.configuration.title'|trans }}</h1>
    <div class="alert alert-info">{{ 'emailing.configuration.secret_help'|trans }}</div>

    <form method="post" class="panel panel-default">
        <input type="hidden" name="_token" value="{{ csrf_token('brevo_configuration') }}">
        <div class="panel-body">
            <div class="checkbox">
                <label><input type="checkbox" name="enabled" value="1" {{ configuration.enabled ? 'checked' }}> {{ 'emailing.configuration.enabled'|trans }}</label>
            </div>
            <div class="form-group">
                <label for="brevo-api-key">{{ 'emailing.configuration.api_key'|trans }}</label>
                <input id="brevo-api-key" class="form-control" type="password" name="api_key" autocomplete="new-password">
                <p class="help-block">
                    {% if configuration.apiKeyHint %}
                        {{ 'emailing.configuration.api_key_kept'|trans({'%hint%': configuration.apiKeyHint}) }}
                    {% else %}
                        {{ 'emailing.configuration.api_key_empty'|trans }}
                    {% endif %}
                </p>
            </div>
            <dl class="dl-horizontal">
                <dt>{{ 'emailing.configuration.status'|trans }}</dt><dd>{{ ('emailing.configuration.status_' ~ configuration.connectionStatus)|trans }}</dd>
                <dt>{{ 'emailing.configuration.account'|trans }}</dt><dd>{{ configuration.companyName ?: configuration.accountEmail ?: '—' }}</dd>
                <dt>{{ 'emailing.configuration.last_check'|trans }}</dt><dd>{{ configuration.lastCheckedAt ? configuration.lastCheckedAt|date('d/m/Y H:i:s') : '—' }}</dd>
            </dl>
            {% if configuration.lastError %}<div class="alert alert-danger">{{ configuration.lastError }}</div>{% endif %}
        </div>
        <div class="panel-footer">
            <button class="btn btn-primary" type="submit">{{ 'emailing.configuration.save_and_test'|trans }}</button>
            <a class="btn btn-default" href="{{ path('admin_marketing_emailing') }}">{{ 'emailing.common.back'|trans }}</a>
        </div>
    </form>
{% endblock %}
