{# app/modules/loyalty/templates/loyalty/merchant/devices.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.terminal_devices.title') }}{% endblock %}

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

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

{% block content %}
{% call page_header_flex(title=_('loyalty.terminal_devices.title'), subtitle=_('loyalty.terminal_devices.subtitle')) %}
    <div class="flex items-center gap-3">
        {{ refresh_button(loading_var='loading', onclick='loadDevices()', variant='secondary') }}
        <button @click="openPairModal()"
                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.terminal_devices.pair_device') }}
        </button>
    </div>
{% endcall %}

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

{% set devices_api_prefix = '/merchants/loyalty' %}
{% set show_store_filter = true %}
{% set show_crud = true %}
{% include 'loyalty/shared/devices-list.html' %}
{% endblock %}

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