@inject ('websiteReviewRepository', 'TPS\Shop\Repositories\WebsiteReviewRepository')
@php
  $websiteReview = $websiteReviewRepository->paginate(4)
@endphp

<section class="reviews-section">
    <div class="container">
      <div class="reviews-inner">

        <div class="reviews-top">
          <h2 class="reviews-title">{{__('shop::app.review.reviews')}}</h2>
          <a href="{{ route('shop.website_reviews.index') }}" class="reviews-top-link"><span>{{__('shop::app.review.all-reviews')}}</span>
            <img src="../assets/icons/chevron-right.svg" alt="">
          </a>
        </div>

        <div class="reviews-content">

        @if ($websiteReview->count() > 0)

          @foreach($websiteReview as $vol)

            <div class="review-card">
              <div class="review-rating">
                @for ($i = 1; $i <= 5; $i++)
                    <svg class="review-card-star{{ $i <= $vol->rating ? '--active' : '' }}" data-index="{{ $i }}" width="32" height="29" viewBox="0 0 32 29" fill="none" xmlns="http://www.w3.org/2000/svg">
                      <path d="M16 0L19.5922 11.0557H31.2169L21.8123 17.8885L25.4046 28.9443L16 22.1115L6.59544 28.9443L10.1877 17.8885L0.783095 11.0557H12.4078L16 0Z" fill="currentColor"></path>
                    </svg>
                @endfor 
              </div>
              <div class="review-details">
                <p class="review-text">{{ $vol->review_text }}</p>
                <div class="review-data">
                  <h3 class="reviewer-name">{{ $vol->customer->first_name }}</h3>
                  <div class="review-date">{{ $vol->created_at->format('d.m.Y') }}</div>
                </div>
              </div>
            </div>
          @endforeach
          
        @endif
        </div>

        @auth('customer')
            <script>
                var isAuthenticated = true;
            </script>
        @else
            <script>
                var isAuthenticated = false;
            </script>
        @endauth

        <button id="openReviewPopupBtn" class="add-review-button">{{__('shop::app.review.write-review')}}</button> 

      </div>
    </div>
  </section>