<?php /** @var $block \Swissup\Testimonials\Block\TestimonialsList */ ?>
<?php $testimonials = $block->getTestimonials(); ?>
<?php if (!$block->getIsAjax()): ?>
<div class="newreview">
<a href="/testimonials/index/new/" class="action submit primary"><span>Submit Your Review</span></a>
</div>
<div class="testimonials-list">
    <div class="testimonials" data-mage-init='<?= $block->getJsConfig() ?>'>
<?php endif; ?>
    <?php if($testimonials->getSize()): ?>
        <?php /** @var $testimonial \Swissup\Testimonials\Model\Data */ ?>
        <?php foreach ($testimonials as $testimonial): ?>
            <figure class="testimonial<?php if ($block->getIsAjax()): ?> loaded<?php endif;?>">
                <blockquote>
                    <?= $block->escapeHtml($testimonial->getMessage()); ?>
                    <div class="arrow"></div>
                    <div class="extra-info">
                        <small class="date nobr"><?= $block->formatDate($testimonial->getDate(), \IntlDateFormatter::LONG) ?></small>
                        <?php if ($testimonial->getRating()): ?>
                        <?php $ratingPercent = $block->getRatingPercent($testimonial); ?>
                        <small class="rating nobr">
                            <div class="review-ratings">
                                <div class="rating-summary item">
                                    <span class="label rating-label"><span><?= __('Rating') ?></span></span>
                                    <div class="rating-result" title="<?= $ratingPercent ?>%">
                                        <span style="width:<?= $ratingPercent ?>%">
                                            <span><?= $ratingPercent ?>%</span>
                                        </span>
                                    </div>
                                </div>
                            </div>
                        </small>
                    </div>
                    <?php endif; ?>
                </blockquote>
                <div class="info">
                    <img src="<?= $block->getProfileImageUrl($testimonial) ?>" alt="Profile image" />
                    <div class="author">
                        <h5><?= $block->escapeHtml($testimonial->getName()) ?></h5>
                        <?php if ($companyHtml = $block->getCompanyHtml($testimonial)): ?>
                        <p><?= $companyHtml ?></p>
                        <?php endif; ?>
                        <?php if ($contacts = $block->getContactsHtml($testimonial)): ?>
                        <p class="contacts-info"><?= $contacts ?></p>
                        <?php endif; ?>
                    </div>
                </div>
            </figure>
        <?php endforeach; ?>
    <?php else: ?>
        <p><?= __('No testimonials found.'); ?></p>
    <?php endif; ?>
<?php if (!$block->getIsAjax()): ?>
    </div>
    <?php if (!$block->isLastPage()): ?>
    <div class="more-button">
        <a id="viewMore" target="blank" href=""><?= __('Show more Reviews') ?></a>
    </div>
    <?php endif; ?>
</div>
<?php endif; ?>
