{% extends "admin/base.html" %} {% import "macros/ui.html" as ui %} {% block title %}{% if product %}{{ t(key="edit-product", lang=lang | default(value='sk')) }}{% else %}{{ t(key="new-product", lang=lang | default(value='sk')) }}{% endif %}{% endblock title %} {% block crumb %}{{ t(key="admin-products", lang=lang | default(value='sk')) }}{% endblock crumb %} {% block content %}

{% if product %}{{ t(key="edit-product", lang=lang | default(value='sk')) }}{% else %}{{ t(key="new-product", lang=lang | default(value='sk')) }}{% endif %}

{{ ui::button(variant="outline-secondary", label=t(key="cancel", lang=lang | default(value='sk')), href="/admin/catalog/products", size="px-3 py-2 text-sm") }}
{{ ui::csrf_field() }} {% if product %} {% set v_name = product.name %}{% set v_currency = product.currency %}{% set v_desc = product.description | default(value="") %}{% set v_pub = product.published %} {% else %} {% set v_name = "" %}{% set v_currency = "EUR" %}{% set v_desc = "" %}{% set v_pub = false %} {% endif %} {% set inp = "w-full rounded-radius border border-outline bg-surface-alt px-3 py-2 text-sm text-on-surface focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary dark:border-outline-dark dark:bg-surface-dark-alt/50 dark:text-on-surface-dark dark:focus-visible:outline-primary-dark" %} {% set sublabel = "text-xs font-medium text-on-surface/70 dark:text-on-surface-dark/70" %}
{{ ui::input(name="name", id="name", required=true, value=v_name) }}
{{ ui::input(name="currency", id="currency", value=v_currency, attrs='maxlength="3"', extra="uppercase") }}
{# --- Variants / options editor ------------------------------------------- #} {# Each product is sold as one or more variants (a free-text label such as #} {# "10cm x 13cm" or "5ml" plus its own price/stock/sku, and optional public & #} {# business sale prices). Rows are managed client-side; names are indexed #} {# (variants[i][...]) and read back by the controller. #}
{{ t(key="variants-options", lang=lang | default(value='sk')) }}
{{ ui::textarea(name="description", id="description", rows="5", value=v_desc) }}
{% if product and product.image %} {% endif %} {{ ui::file_input(name="image", id="image", accept="image/*") }}
{{ ui::checkbox(name="published", id="published", label=t(key="published", lang=lang | default(value='sk')), checked=v_pub) }}
{{ ui::button(label=t(key="save", lang=lang | default(value='sk')), type="submit") }} {{ ui::button(variant="outline-secondary", label=t(key="cancel", lang=lang | default(value='sk')), href="/admin/catalog/products") }}
{% endblock content %}