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

use Magento\Framework\Escaper;
use Magento\Review\Block\Product\View\ListView;

/**
 * @var ListView $block
 * @var Escaper $escaper
 */

$_items = $block->getReviewsCollection()->getItems();
$format = $block->getDateFormat() ?: \IntlDateFormatter::SHORT;
?>
<?php if (count($_items)):?>
<div class="block review-list" id="customer-reviews">
    <div class="block-title">
        <strong><?= $escaper->escapeHtml(__('Customer Reviews')) ?></strong>
    </div>
    <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">
				<div class="review-content-left">
				<div class="review-details">
                    <p class="review-author">
                        <span class="review-details-label"><?= $escaper->escapeHtml(__('Review by')) ?></span>
                        <strong class="review-details-value" itemprop="author"><?= $escaper->escapeHtml($_review->getNickname()) ?></strong>
                    </p>
                    <p class="review-date">
                        <span class="review-details-label"><?= $escaper->escapeHtml(__('Posted on')) ?></span>
                        <time class="review-details-value" itemprop="datePublished" datetime="<?= $escaper->escapeHtmlAttr($block->formatDate($_review->getCreatedAt(), $format)) ?>"><?= $block->escapeHtml($block->formatDate($_review->getCreatedAt(), $format)) ?></time>
                    </p>
                </div>
                <?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><?= $escaper->escapeHtml($_vote->getRatingCode()) ?></span>
                        </span>
						<div class="rating-result"
							 id="review_<?= /* @noEscape */ $_review->getReviewId()
                             ?>_vote_<?= /* @noEscape */ $_vote->getVoteId() ?>"
							 title="<?= $escaper->escapeHtmlAttr($_vote->getPercent()) ?>%">
	                        <meta itemprop="worstRating" content = "1"/>
	                        <meta itemprop="bestRating" content = "100"/>
                            <span style="width: <?= $escaper->escapeHtml($_vote->getPercent()) ?>%;">
                                <span itemprop="ratingValue"><?= $escaper->escapeHtml($_vote->getPercent()) ?>%</span>
                            </span>
                    </div>
                    <?php endforeach; ?>
                    </div>
                <?php endif; ?>


				</div>
				<div class="review-content-right">
					<div class="review-title" itemprop="name"><?= $escaper->escapeHtml($_review->getTitle()) ?></div>
					<div class="review-content" itemprop="description">
						<?= nl2br($escaper->escapeHtml($_review->getDetail())) ?>
					</div>
				</div>
            </li>
        <?php endforeach; ?>
        </ol>
        <div class="toolbar review-toolbar">
            <?= $block->getChildHtml('toolbar') ?>
        </div>
    </div>
</div>
<?php endif;?>