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

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

$product = $block->getProductData();
?>
<?php if ($product->getId()): ?>
<div class="customer-review view">
    <div class="product-details">
        <div class="line">
            <div class="col-des-3 col-tb-4 col-mb-12">
                <div class="product-media">
                    <a class="product-photo" href="<?= $block->escapeUrl($product->getProductUrl()) ?>">
                        <?php /* customer_account_product_review_page */ ?>
                        <?= $block->getImage($block->getProductData(), 'customer_account_product_review_page')->toHtml() ?>
                    </a>
                </div>
            </div>
            <div class="col-des-9 col-tb-8 col-mb-12">
                <div class="product-info">
                    <h2 class="product-name"><?= $block->escapeHtml($product->getName()) ?></h2>
                    <?php if ($block->getRating() && $block->getRating()->getSize()): ?>
                        <span class="rating-average-label"><?= $block->escapeHtml(__('Average Customer Rating:')) ?></span>
                        <?= $block->getReviewsSummaryHtml($product) ?>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </div>

    <div class="review-details">
        <?php if ($block->getRating() && $block->getRating()->getSize()): ?>
            <div class="title">
                <strong><?= $block->escapeHtml(__('Your Review')) ?></strong>
            </div>
            <div class="customer-review-rating">
                <?php foreach ($block->getRating() as $_rating): ?>
                    <?php if ($_rating->getPercent()): ?>
                        <?php $rating = ceil($_rating->getPercent()) ?>
                        <div class="rating-summary item">
                            <span class="rating-label">
                                <span><?= $block->escapeHtml($_rating->getRatingCode()) ?></span>
                            </span>
                            <div class="rating-result" title="<?= /* @noEscape */ $rating ?>%">
                                <span>
                                    <span><?= /* @noEscape */ $rating ?>%</span>
                                </span>
                            </div>
                            <?= /* @noEscape */ $secureRenderer->renderStyleAsTag(
                                "width:" . /* @noEscape */ $rating . "%",
                                'div.rating-result>span:first-child'
                            ) ?>
                        </div>
                    <?php endif; ?>
                <?php endforeach; ?>
            </div>
        <?php endif; ?>

        <div class="review-title"><?= $block->escapeHtml($block->getReviewData()->getTitle()) ?></div>
        <div class="review-content">
            <?= /* @noEscape */ nl2br($block->escapeHtml($block->getReviewData()->getDetail())) ?>
        </div>
        <div class="review-date">
            <?= $block->escapeHtml(__('Submitted on %1', '<time class="date">' .
                $block->dateFormat($block->getReviewData()->getCreatedAt()) . '</time>'), ['time']) ?>
        </div>
    </div>
</div>
<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 to My Reviews')) ?></span>
        </a>
    </div>
</div>
<?php endif; ?>
