{% form_theme form with app_form_themes() only %}

<div {{ attributes.defaults({ 'data-review-form': '' }) }}>
    {% if saved %}
        <div data-review-status class="mb-8 rounded border border-green-300 bg-green-50 p-4 text-green-900" role="status">
            {{ (this.hasEligibleProducts ? 'marketing.review.form.saved_next' : 'marketing.review.form.saved')|trans }}
        </div>
    {% endif %}

    {% if this.hasEligibleProducts %}
        {{ form_start(form, {
            attr: {
                class: 'space-y-6',
                'data-action': 'live#action:prevent',
                'data-live-action-param': 'submitReview',
                'data-model': 'norender|*',
                novalidate: 'true'
            }
        }) }}
            {{ form_errors(form) }}
            {{ form_row(form.productId) }}
            {{ form_row(form.rating) }}
            {{ form_row(form.comment) }}

            <button
                class="inline-flex min-h-12 items-center justify-center rounded px-6 py-3 font-semibold disabled:cursor-not-allowed disabled:opacity-50"
                type="submit"
                data-loading="addAttribute(disabled)"
            >
                {{ 'marketing.review.form.submit'|trans }}
            </button>

            <div class="hidden">{{ form_rest(form) }}</div>
        {{ form_end(form) }}
    {% else %}
        <div data-review-status class="rounded border p-6 text-center" role="status">
            <h2 class="text-xl font-semibold">{{ 'marketing.review.form.complete_title'|trans }}</h2>
            <p class="mt-3">{{ 'marketing.review.form.complete_text'|trans }}</p>
        </div>
    {% endif %}
</div>
