@extends('layouts.modcp')

@section('page-title', $pageTitle . ' - ' . config('app.name') )

@section('modcp-content')
    <div class="modcp-page-title">
        {{ $pageTitle }}
        <span class="modcp-count">{{ $entries->count() }}</span>
    </div>

    @if($entries->isEmpty())
        <div class="modcp-empty">
            <i data-lucide="check-circle" size="36"></i>
            <p>No {{ $state }} entries.</p>
        </div>
    @else
        <div class="modcp-list">
            @foreach($entries as $entry)
                <div class="modcp-list-item">
                    <div class="modcp-list-item-cover">
                        @if($entry->main_image)
                            <img src="{{ Storage::url($entry->main_image) }}" alt="">
                        @else
                            <i data-lucide="image" size="20"></i>
                        @endif
                    </div>
                    <div class="modcp-list-item-info">
                        <span class="modcp-list-item-title">{{ $entry->complete_title }}</span>
                        <span class="modcp-list-item-meta">
                    <span class="badge {{ $entry->type }}">{{ \App\Livewire\Database::ENTRY_TYPES[$entry->type] }}</span>
                    @if($entry->getRealPlatform())
                                <span class="badge">{{ $entry->getRealPlatform()->name }}</span>
                            @endif
                    Added {{ $entry->created_at->format('d M Y') }} by<x-xf-username-link :user-id="$entry->user_id" />
                </span>
                    </div>
                    <div class="modcp-list-item-actions">
                        <a href="{{ route('entries.show', ['section' => $entry->type, 'entry' => $entry]) }}"
                           class="btn" target="_blank">
                            <i data-lucide="eye" size="13"></i> View
                        </a>
                        <a href="{{ route('submit.edit', [$entry->type, $entry->id]) }}"
                           class="btn">
                            <i data-lucide="pen" size="13"></i> Edit
                        </a>
                    </div>
                </div>
            @endforeach
        </div>
        {{ $entries->links() }}
    @endif
@endsection
