{% extends 'base.html.twig' %}

{% import "user/_macro/_user_macro.html.twig" as userMacro %}

{# @var settings \App\Service\Setting\SettingsDto #}
{%- set settings = settings() -%}

{% block title %}{{ 'trans.Edit listing' | trans }}{% endblock %}

{% block body %}
    <div class="container mt-4">
        <div class="row">
            <div class="col-md-4 col-lg-3 mb-4 d-none d-md-block">
                {% include 'user/_part/user_navigation_card.html.twig' %}
            </div>

            <div class="col-md-8 col-lg-9">
                <div>
                    <div>
                        <a
                                href="{{ path('app_listing_show', {'id': listing.id, 'slug': listing.slug, 'showListingPreviewForOwner': 1}) }}"
                                target="_blank"
                                class="float-md-left btn btn-link pl-0"
                        >
                            {{- 'trans.Preview listing' | trans -}}
                        </a>
                    </div>

                    <div class="text-md-right mb-2">
                        <span class="{{ getListingStatusClass(listing) }}">{{ getListingStatus(listing) }}</span>
                        {% if listing.status in [constant('\App\\Entity\\Listing::STATUS_REJECTED')] and listing.rejectionReason is empty and settings.linkRejectionReason is not empty %}
                            <a href="{{ path('app_page', {'slug': settings.linkRejectionReason}) }}">
                                {{- 'trans.more information' | trans -}}
                            </a>
                        {% endif %}

                        {% if settings.paymentAllowed and listing.status in [constant('\App\\Entity\\Listing::STATUS_ACTIVE'), constant('\App\\Entity\\Listing::STATUS_ACTIVE_FEATURED')] %}
                            <a href="{{ path('app_user_feature_listing', {"id": listing.id}) }}" class="btn btn-dark mb-1">
                                {{- 'trans.Feature this listing' | trans -}}
                            </a>
                        {% endif %}

                        {{ userMacro.listingButtons(listing) }}

                        {% if isAdminInPublic() %}
                            <a
                                    href="{{ path('app_admin_listing_edit', {'id': listing.id}) }}"
                                    class="btn btn-outline-danger mb-1"
                            >
                                {{- 'trans.Edit listing as Admin' | trans -}}
                            </a>
                        {% endif %}
                    </div>

                    <div class="clearfix"></div>
                </div>

                {{ include('user/listing/_form.html.twig', {'button_label': 'trans.Update' | trans}) }}
            </div>
        </div>
    </div>
{% endblock %}

{% block js %}
    {{ encore_entry_link_tags('listing_edit') }}
    {{ encore_entry_script_tags('listing_edit') }}
{% endblock %}
