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

/**
 * @var \Magento\Review\Block\Customer\ListCustomer $block
 * @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer
 */

/** @var \Magento\Review\Helper\Data $reviewHelper */
$reviewHelper = $block->getData('reviewHelper');
?>
<?php if ($block->getReviews() && count($block->getReviews())): ?>
    <div class="table-wrapper reviews">
        <table class="data table table-reviews" id="my-reviews-table">
            <caption class="table-caption"><?= $block->escapeHtml(__('Product Reviews')) ?></caption>
            <thead>
                <tr>
                    <th scope="col" class="col date"><?= $block->escapeHtml(__('Created')) ?></th>
                    <th scope="col" class="col item"><?= $block->escapeHtml(__('Product Name')) ?></th>
                    <th scope="col" class="col summary"><?= $block->escapeHtml(__('Rating')) ?></th>
                    <th scope="col" class="col description"><?= $block->escapeHtml(__('Review')) ?></th>
                    <th scope="col" class="col actions">&nbsp;</th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ($block->getReviews() as $review): ?>
                <tr>
                    <td data-th="<?= $block->escapeHtml(__('Created')) ?>"
                        class="col date"><?= $block->escapeHtml($block->dateFormat($review->getReviewCreatedAt())) ?>
                    </td>
                    <td data-th="<?= $block->escapeHtml(__('Product Name')) ?>" class="col item">
                        <strong class="product-name">
                            <a href="<?= $block->escapeUrl($block->getProductUrl($review)) ?>">
                                <?= $block->escapeHtml($review->getName()) ?>
                            </a>
                        </strong>
                    </td>
                    <td data-th="<?= $block->escapeHtml(__('Rating')) ?>" class="col summary">
                    <?php if ($review->getSum()): ?>
                        <div class="rating-summary">
                            <span class="label"><span><?= $block->escapeHtml(__('Rating')) ?>:</span></span>
                            <div class="rating-result"
                                 title="<?= /* @noEscape */ ((int)$review->getSum() / (int)$review->getCount()) ?>%">
                                <span>
                                    <span>
                                        <?= /* @noEscape */ ((int)$review->getSum() / (int)$review->getCount()) ?>%
                                    </span>
                                </span>
                            </div>
                        </div>
                        <?= /* @noEscape */ $secureRenderer->renderStyleAsTag(
                            "width:" . /* @noEscape */ ((int)$review->getSum() / (int)$review->getCount()) . "%;",
                            'div.rating-summary div.rating-result>span:first-child'
                        ) ?>
                    <?php endif; ?>
                    </td>
                    <td data-th="<?= $block->escapeHtmlAttr(__('Review')) ?>" class="col description">
                        <?= $reviewHelper->getDetailHtml($review->getDetail()) ?>
                    </td>
                    <td data-th="<?= $block->escapeHtmlAttr(__('Actions')) ?>" class="col actions">
                        <a href="<?= $block->escapeUrl($block->getReviewUrl($review)) ?>" class="action more">
                            <span><?= $block->escapeHtml(__('See Details')) ?></span>
                        </a>
                    </td>
                </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
    </div>
    <?php if ($block->getToolbarHtml()): ?>
        <div class="toolbar products-reviews-toolbar bottom">
            <?= $block->getToolbarHtml() ?>
        </div>
    <?php endif; ?>
<?php else: ?>
    <div class="message info empty"><span><?= $block->escapeHtml(__('You have submitted no reviews.')) ?></span></div>
<?php endif; ?>
<div class="actions-toolbar-form">
    <div class="secondary">
        <a class="action btn btn-secondary btn-sm back" href="<?= $block->escapeUrl($block->getBackUrl()) ?>">
            <span><?= $block->escapeHtml(__('Back')) ?></span>
        </a>
    </div>
</div>
