{% extends request.ajax ? 'layout_blank.html.twig' : 'layout_default.html.twig' %}

{% set active_menu = 'system' %}
{% set can_edit_currency = has_permission('currency', 'edit') %}

{% block meta_title %}{{ 'Currency Management'|trans }}{% endblock %}

{% block breadcrumbs %}
    <ol class="breadcrumb">
        <li class="breadcrumb-item">
            <a href="{{ '/'|url }}">
                <svg class="icon">
                    <use xlink:href="#home" />
                </svg>
            </a>
        </li>
        <li class="breadcrumb-item">
            <a href="{{ 'system'|url }}">{{ 'Settings'|trans }}</a>
        </li>
        <li class="breadcrumb-item">
            <a href="{{ 'extension/settings/currency'|url }}">{{ 'Currency Settings'|trans }}</a>
        </li>
        <li class="breadcrumb-item active" aria-current="page">{{ currency.code }}</li>
    </ol>
{% endblock %}

{% block content %}
<div class="card">
    {% if can_edit_currency %}
    <form method="post" action="{{ 'currency/update'|api_url }}" {{ fb_api_form({message: 'Currency Updated'|trans}) }}>
        <div class="card-body">
            <div class="mb-3">
                <h3 class="card-title mb-1">{{ 'Edit Currency Information'|trans }}</h3>
                <p class="text-secondary mb-0">{{ currency.code }} ({{ currency.code|currency_name }})</p>
            </div>
            <input type="hidden" name="code" value="{{ currency.code }}">
            <div class="row g-3">
                <div class="col-lg-6">
                    <label class="form-label">{{ 'Conversion Rate'|trans }}</label>
                    <input class="form-control" type="text" name="conversion_rate" value="{{ currency.conversion_rate }}" required>
                </div>
            </div>
        </div>
        <div class="card-footer d-flex justify-content-end">
            <button class="btn btn-primary" type="submit">{{ 'Update'|trans }}</button>
        </div>
    </form>
    {% else %}
    <div class="card-body">
        <p class="text-muted mb-0">{{ 'You do not have permission to edit currencies.'|trans }}</p>
    </div>
    {% endif %}
</div>
{% endblock %}
