<!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
{% block sw_review_detail %}
<sw-page class="sw-review-detail">

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_review_detail_header %}
    <template #smart-bar-header>
        <h2>{{ placeholder(review, 'title', $tc('sw-review.detail.textHeadline')) }}</h2>
    </template>
    {% endblock %}

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_review_detail_actions %}
    <template #smart-bar-actions>

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_review_detail_actions_abort %}
        <sw-button
            v-tooltip.bottom="tooltipCancel"
            @click="onCancel"
        >
            {{ $tc('global.default.cancel') }}
        </sw-button>
        {% endblock %}

        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
        {% block sw_review_detail_actions_save %}
        <sw-button-process
            v-tooltip.bottom="tooltipSave"
            class="sw-review-detail__save-action"
            variant="primary"
            :disabled="isLoading || !acl.can('review.editor') || undefined"
            :process-success="isSaveSuccessful"
            @update:process-success="onSaveFinish"
            @click="onSave"
        >
            {{ $tc('global.default.save') }}
        </sw-button-process>
        {% endblock %}
    </template>
    {% endblock %}

    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
    {% block sw_review_detail_content %}
    <template #content>
        <sw-card-view>
            <template v-if="isLoading">
                <sw-skeleton />
                <sw-skeleton variant="detail-bold" />
            </template>

            <template v-else>

                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                {% block sw_review_detail_basic_info_card %}
                <sw-card
                    v-if="review"
                    position-identifier="sw-review-detail-basic-info"
                    :title="$tc('sw-review.detail.cardTitleReviewInfo')"
                >

                    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                    {% block sw_customer_card_rows %}
                    <template #grid>
                        <sw-container rows="auto auto">

                            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                            {% block sw_customer_card_row_primary %}
                            <sw-card-section divider="bottom">

                                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                                {% block sw_customer_card_metadata_container %}
                                <sw-container>

                                    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                                    {% block sw_customer_card_metadata %}
                                    <div class="sw-review-detail__metadata">

                                        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                                        {% block sw_customer_card_metadata_customer_name %}
                                        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                                        {% block sw_custsomer_card_metadata_customer_name_label %}
                                        <div class="sw-review-detail__metadata-review-headline">
                                            <sw-container
                                                columns="auto 150px"
                                                gap="0px 15px"
                                            >
                                                <div class="sw-review-detail__metadata-review-title">
                                                    {{ review.title }}
                                                </div>
                                                <div
                                                    v-if="stars"
                                                    class="sw-review-detail__metadata-review-stars"
                                                >
                                                    <sw-rating-stars
                                                        :value="review.points"
                                                        class="star-count-display"
                                                    />
                                                    <div class="star-count-description">
                                                        {{ $tc(`sw-review.detail.review${Math.round(stars)}PointRatingText`) }}
                                                    </div>
                                                </div>
                                            </sw-container>
                                        </div>
                                        <p class="sw-review-detail__metadata-review-content">
                                            {{ review.content }}
                                        </p>
                                        {% endblock %}
                                        {% endblock %}
                                    </div>
                                    {% endblock %}
                                </sw-container>
                                {% endblock %}
                            </sw-card-section>
                            {% endblock %}

                            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                            {% block sw_customer_card_row_secondary %}
                            <sw-card-section
                                secondary
                                slim
                            >
                                <slot name="default">

                                    <sw-container
                                        class="sw-review-base-info"
                                        columns="repeat(auto-fit, minmax(250px, 1fr))"
                                        gap="0px 15px"
                                    >
                                        <div class="sw-review-base-info-columns">

                                            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                                            {% block sw_customer_base_metadata_created_at %}
                                            <sw-description-list>

                                                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                                                {% block sw_customer_base_metadata_created_at_label %}
                                                <dt class="sw-review-base-info__label">
                                                    {{ $tc('sw-review.detail.labelCreatedAt') }}
                                                </dt>
                                                {% endblock %}

                                                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                                                {% block sw_customer_base_metadata_created_at_content %}
                                                <dd>
                                                    {{ dateFilter(review.createdAt, { hour: '2-digit', minute: '2-digit', second: '2-digit' }) }}
                                                </dd>
                                                {% endblock %}
                                            </sw-description-list>
                                            {% endblock %}

                                            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                                            {% block sw_customer_base_metadata_sales_channel %}
                                            <sw-description-list>

                                                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                                                {% block sw_customer_base_metadata_sales_channel_label %}
                                                <dt class="sw-review-base-info__label">
                                                    {{ $tc('sw-review.detail.labelSalesChannel') }}
                                                </dt>
                                                {% endblock %}

                                                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                                                {% block sw_customer_base_metadata_sales_channel_content %}
                                                <dd>
                                                    {{ review.salesChannel.name }}
                                                </dd>
                                                {% endblock %}
                                            </sw-description-list>
                                            {% endblock %}

                                            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                                            {% block sw_customer_base_metadata_product %}
                                            <sw-description-list>

                                                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                                                {% block sw_customer_base_metadata_product_label %}
                                                <dt class="sw-review-base-info__label">
                                                    {{ $tc('sw-review.detail.labelProduct') }}
                                                </dt>
                                                {% endblock %}

                                                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                                                {% block sw_customer_base_metadata_product_content %}
                                                <dd>{{ review.product.translated.name }}</dd>
                                                {% endblock %}
                                            </sw-description-list>
                                            {% endblock %}
                                        </div>
                                        <div class="sw-review-base-info-columns">

                                            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                                            {% block sw_customer_base_metadata_customer %}
                                            <sw-description-list>

                                                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                                                {% block sw_customer_base_metadata_customer_label %}
                                                <dt class="sw-review-base-info__label">
                                                    {{ $tc('sw-review.detail.labelCustomer') }}
                                                </dt>
                                                {% endblock %}

                                                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                                                {% block sw_customer_base_metadata_customer_content %}
                                                <dd v-if="review.customer">
                                                    {{ salutation(review.customer) }}
                                                </dd>
                                                <dd v-else>
                                                    {{ review.externalUser }}
                                                </dd>
                                                {% endblock %}
                                            </sw-description-list>
                                            {% endblock %}

                                            <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                                            {% block sw_customer_base_metadata_email %}
                                            <sw-description-list>
                                                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                                                {% block sw_customer_base_metadata_email_label %}
                                                <dt class="sw-review-base-info__label">
                                                    {{ $tc('sw-review.detail.labelEmail') }}
                                                </dt>
                                                {% endblock %}

                                                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                                                {% block sw_customer_base_metadata_email_content %}
                                                <dd v-if="review.customer">
                                                    {{ emailIdnFilter(review.customer.email) }}
                                                </dd>
                                                <dd v-else>
                                                    {{ review.externalEmail }}
                                                </dd>
                                                {% endblock %}
                                            </sw-description-list>
                                            {% endblock %}
                                        </div>
                                    </sw-container>
                                </slot>
                            </sw-card-section>
                            {% endblock %}
                        </sw-container>
                    </template>
                    {% endblock %}
                </sw-card>
                {% endblock %}

                <sw-card
                    v-if="review"
                    position-identifier="sw-review-detail-properties"
                    class="sw-review-properties"
                    :title="$tc('sw-review.detail.cardTitleReviewProperties')"
                >

                    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                    {% block sw_review_detail_basic_info_card_description_list %}
                    <sw-container
                        columns="1fr 1fr"
                        gap="16px"
                    >

                        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                        {% block sw_review_detail_description_list_language %}
                        <sw-entity-single-select
                            id="language"
                            v-model:value="review.languageId"
                            name="sw-field--review-languageId"
                            entity="language"
                            class="sw-review__language-select"
                            required
                            show-clearable-button
                            :disabled="!acl.can('review.editor') || undefined"
                            :label="$tc('sw-review.detail.labelLanguage')"
                            :criteria="languageCriteria"
                        />
                        {% endblock %}

                        <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                        {% block sw_review_detail_description_list_status %}
                        <sw-switch-field
                            v-model:value="review.status"
                            name="sw-field--review-status"
                            class="status-switch"
                            :disabled="!acl.can('review.editor') || undefined"
                            :label="$tc('sw-review.detail.labelStatus')"
                            bordered
                        />
                        {% endblock %}
                    </sw-container>
                    {% endblock %}
                </sw-card>

                <sw-card
                    v-if="review"
                    position-identifier="sw-review-detail-comment"
                    :title="$tc('sw-review.detail.labelComment')"
                >

                    <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                    {% block sw_review_detail_basic_info_card_comment %}
                    <sw-textarea-field
                        v-model:value="review.comment"
                        name="sw-field--review-comment"
                        class="sw-review__comment-field"
                        :disabled="!acl.can('review.editor') || undefined"
                        :label="$tc('sw-review.detail.titleCardComment')"
                        :placeholder="$tc('sw-review.detail.placeholderComment')"
                    />
                    {% endblock %}
                </sw-card>

                <!-- eslint-disable-next-line sw-deprecation-rules/no-twigjs-blocks -->
                {% block sw_review_detail_custom_field_sets %}
                <sw-card
                    v-if="showCustomFields"
                    position-identifier="sw-review-detail-custom-field-sets"
                    :title="$tc('sw-settings-custom-field.general.mainMenuItemGeneral')"
                >
                    <sw-custom-field-set-renderer
                        :entity="review"
                        :disabled="!acl.can('review.editor')"
                        :sets="customFieldSets"
                    />
                </sw-card>
                {% endblock %}
            </template>
        </sw-card-view>
    </template>
    {% endblock %}
</sw-page>
{% endblock %}
