<?php /** @var \App\Models\EntryReview $review */ ?>
@php if( !isset($entry) && isset($news) ){ $entry = $news; $newsMode = true; } else { $newsMode = false; } @endphp
<div class="{{ !$newsMode ? 'grid-c2' : '' }}" style="margin-top:1%;">
    @if( !$newsMode )
        <div id="reviews-section" x-data="{reviewModalOpen: false}">
            <div class="entry-content">
                <x-entry-section-title label="Reviews" icon="star" />

                <div class="review-header-right">
                        @if($entry->reviews_count_cached > 0)
                            <div class="review-avg-badge">
                                <i data-lucide="star" size="13"></i>
                                {{ $entry->average_rating }}
                                <span class="review-avg-count">({{ $entry->reviews_count_cached }})</span>
                            </div>
                        @endif

                        @auth
                            <button @click="reviewModalOpen = true" class="btn primary">
                                <i data-lucide="pen-line" size="13"></i> Write a review
                            </button>
                        @endauth
                    </div>

                @forelse( $reviews as $review )
                    <x-review-card :review="$review" />
                @empty
                    <span style="text-align:center" class="whisper">Be the first to post a review</span>
                @endforelse
                <a href="{!! reviewsRoute( ['entryId' => $entry->id ]) !!}" class="modcp-list-see-all">
                    See all {{ $entry->reviews_count_cached }} reviews
                </a>
            @include('reviews.submit')
            </div>
        </div>
    @endif
    <div id="comments-section">
        <div class="entry-content">
            <x-entry-section-title label="Last comments" icon="message-circle" />
            @forelse( $comments as $comment )
                @if(( $comment['user_id'] === config('xenforo.bot_user_id') || $comment['username'] === 'Romhack Plaza' ) && $comment['position'] == 0)
                    @continue
                @else
                    <div class="comment-block">
                        <div class="comment-avatar">
                            <x-xen-foro-avatar :user="$comment['user_id']" />
                        </div>

                        <div class="comment-content">
                            <div class="comment-meta">
                                <span class="comment-author">{{ $comment['User']['username'] ?? $comment['username'] ?? 'Guest' }}</span>
                                <span class="comment-separator"></span>
                                <span class="comment-date">{{ date('Y-m-d', $comment['post_date']) }}</span>
                            </div>

                            <div class="comment-body">
                                {!! $comment['message'] !!}
                            </div>
                        </div>
                    </div>
                @endif
            @empty
                <span class="whisper">Be the first to post a comment</span>
            @endforelse
            <a href="{{ xfRoute("threads/{$entry->comments_thread_id}/latest") }}" class="btn primary" style="margin-top: 1%;">
                <i data-lucide="pen"></i> Post a comment
            </a>
        </div>
    </div>
</div>
