{# app/modules/loyalty/templates/loyalty/merchant/program-edit.html #}
{% extends "merchant/base.html" %}
{% from 'shared/macros/headers.html' import page_header_flex %}
{% from 'shared/macros/alerts.html' import loading_state, error_state %}
{% from 'shared/macros/modals.html' import confirm_modal %}

{% block title %}{{ _('loyalty.merchant.program_edit.title') }}{% endblock %}

{% block i18n_modules %}['loyalty']{% endblock %}

{% block alpine_data %}merchantLoyaltySettings(){% endblock %}

{% block content %}
{% call page_header_flex(title=_('loyalty.merchant.program_edit.page_title'), subtitle=_('loyalty.merchant.program_edit.subtitle')) %}{% endcall %}

{{ loading_state(_('loyalty.merchant.program_edit.loading')) }}
{{ error_state(_('loyalty.merchant.program_edit.error_loading')) }}

<div x-show="!loading">
    <form @submit.prevent="saveSettings">
        {% set show_delete = true %}
        {% set show_status = true %}
        {% set cancel_url = '/merchants/loyalty/program' %}
        {% include "loyalty/shared/program-form.html" %}
    </form>
</div>

<!-- Delete Confirmation Modal -->
{{ confirm_modal(
    'deleteProgramModal',
    _('loyalty.merchant.program_edit.delete_title'),
    _('loyalty.merchant.program_edit.delete_message'),
    'deleteProgram()',
    'showDeleteModal',
    _('loyalty.common.delete'),
    _('loyalty.common.cancel'),
    'danger'
) }}
{% endblock %}

{% block extra_scripts %}
<script defer src="{{ url_for('loyalty_static', path='shared/js/loyalty-program-form.js') }}"></script>
<script defer src="{{ url_for('loyalty_static', path='merchant/js/loyalty-settings.js') }}"></script>
{% endblock %}
