<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

/** @var Magento\Review\Block\Product\View\ListView $block */

$_items = $block->getReviewsCollection()->getItems();
$format = $block->getDateFormat() ?: \IntlDateFormatter::SHORT;
?>
<?php if (count($_items)) : ?>
<div class="block review-list" id="customer-reviews">
    <div class="block-content">
        <div class="toolbar review-toolbar">
            <?= $block->getChildHtml('toolbar') ?>
        </div>
        <ol class="items review-items">
        <?php foreach ($_items as $_review) : ?>
            <li class="item review-item" itemscope itemprop="review" itemtype="http://schema.org/Review">
                <?php if (count($_review->getRatingVotes())) : ?>
                    <div class="review-ratings">
                    <?php foreach ($_review->getRatingVotes() as $_vote) : ?>
                    <div class="rating-summary item" itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">
                        <span class="label rating-label"><span><?= $block->escapeHtml($_vote->getRatingCode()) ?></span></span>
                        <div class="rating-result" title="<?= $block->escapeHtmlAttr($_vote->getPercent()) ?>%">
                            <meta itemprop="worstRating" content = "1"/>
                            <meta itemprop="bestRating" content = "100"/>
                            <span style="width:<?= $block->escapeHtmlAttr($_vote->getPercent()) ?>%">
                                <span itemprop="ratingValue"><?= $block->escapeHtml($_vote->getPercent()) ?>%</span>
                            </span>
                        </div>
                    </div>
                    <?php endforeach; ?>
                    </div>
                <?php endif; ?>
                <div class="review-title" itemprop="name"><?= $block->escapeHtml($_review->getTitle()) ?></div>
                <div class="review-content" itemprop="description">
                    <?= /* @noEscape */ nl2br($block->escapeHtml($_review->getDetail())) ?>
                </div>
                <div class="review-details">
                    <p class="review-author">
                        <span class="review-details-label"><?= $block->escapeHtml(__('Review by')) ?></span>
                        <strong class="review-details-value" itemprop="author"><?= $block->escapeHtml($_review->getNickname()) ?></strong>
                    </p>
                    <p class="review-date">
                        <span class="review-details-label"><?= $block->escapeHtml(__('Posted on')) ?></span>
                        <time class="review-details-value" itemprop="datePublished" datetime="<?= $block->escapeHtmlAttr($block->formatDate($_review->getCreatedAt(), $format)) ?>"><?= $block->escapeHtml($block->formatDate($_review->getCreatedAt(), $format)) ?></time>
                    </p>
                </div>
            </li>
        <?php endforeach; ?>
        </ol>
        <div class="toolbar review-toolbar">
            <?= $block->getChildHtml('toolbar') ?>
        </div>
    </div>
</div>
<?php endif;?>
