{% extends 'base.html.twig' %}

{% block title %}Test Complète tes commerces{% endblock %}

{% block body %}
<div class="container mt-4">
    <h1>Test Complète tes commerces</h1>
    <form method="get" action="{{ path('admin_test_ctc', {'insee_code': ''}) }}" class="row g-3 mb-4">
        <div class="col-auto">
            <input type="text" name="insee_code" class="form-control" placeholder="Code INSEE" value="{{ insee_code|default('') }}" required pattern="\\d+">
        </div>
        <div class="col-auto">
            <button type="submit" class="btn btn-primary">Tester</button>
        </div>
    </form>
    {% if url %}
        <div class="mb-3">
            <strong>URL CTC :</strong> <a href="{{ url }}" target="_blank">{{ url }}</a>
        </div>
    {% endif %}
    {% if error %}
        <div class="alert alert-danger">{{ error }}</div>
    {% endif %}
    {% if json %}
        <h3>JSON reçu :</h3>
        <pre style="background:#222;color:#b5f;font-size:0.95em;padding:1em;border-radius:8px;overflow:auto;max-height:600px;">{{ json|json_decode(constant('JSON_OBJECT_AS_ARRAY'))|json_encode(constant('JSON_PRETTY_PRINT')) }}</pre>
    {% elseif url and not error %}
        <div class="alert alert-warning">Aucune donnée reçue.</div>
    {% endif %}
</div>
{% endblock %} 