{# app/modules/loyalty/templates/loyalty/merchant/pins.html #}
{% extends "merchant/base.html" %}
{% from 'shared/macros/headers.html' import page_header_flex, refresh_button %}
{% from 'shared/macros/alerts.html' import loading_state, error_state %}

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

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

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

{% block content %}
{% call page_header_flex(title=_('loyalty.merchant.pins.title'), subtitle=_('loyalty.merchant.pins.subtitle')) %}
    <div class="flex items-center gap-3">
        {{ refresh_button(loading_var='loading', onclick='loadPins()', variant='secondary') }}
        <button @click="openCreateModal()" x-show="program"
                class="flex items-center px-4 py-2 text-sm font-medium text-white bg-purple-600 rounded-lg hover:bg-purple-700">
            <span x-html="$icon('plus', 'w-4 h-4 mr-2')"></span>
            {{ _('loyalty.shared.pins.create_pin') }}
        </button>
    </div>
{% endcall %}

{{ loading_state(_('loyalty.merchant.pins.loading')) }}

{{ error_state(_('loyalty.merchant.pins.error_loading')) }}

{% set pins_api_prefix = '/merchants/loyalty' %}
{% set show_store_filter = true %}
{% set show_crud = true %}
{% include 'loyalty/shared/pins-list.html' %}

{% endblock %}

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