@extends('layouts.nova')

@section('content')
<div class="container legacy-page">
    <div class="page-header-wrap">
        <div class="clearfix">
            <h2 style="margin:0;display:inline-block">My Artworks</h2>
            <span class="text-muted pull-right" style="margin-top:6px">
                {{ method_exists($artworks, 'total') ? $artworks->total() : $artworks->count() }} items
            </span>
        </div>
        <div class="text-muted" style="margin-top:6px;font-size:12px">Manage and edit your uploads.</div>
    </div>

    @if(session('status'))
        <div class="alert alert-success" role="status">{{ session('status') }}</div>
    @endif

    <div class="panel panel-default uploads-panel">
        <div class="panel-body">
            <div class="table-responsive">
                <table class="table table-bordered table-striped table-hover table-advanced" style="margin-bottom:0">
                    <thead>
                        <tr>
                            <th style="width:92px">Preview</th>
                            <th>Title</th>
                            <th style="width:120px" class="text-center">Created</th>
                            <th style="width:90px" class="text-center">Public</th>
                            <th style="width:95px" class="text-center">Approved</th>
                            <th style="width:150px" class="text-center">Actions</th>
                        </tr>
                    </thead>
                    <tbody>
                    @forelse($artworks as $artwork)
                        <tr>
                            <td class="text-center">
                                <a href="{{ route('dashboard.artworks.edit', $artwork->id) }}" title="Edit {{ $artwork->title }}">
                                    <img
                                        src="{{ $artwork->thumb_url ?? $artwork->thumb }}"
                                        @if(!empty($artwork->thumb_srcset)) srcset="{{ $artwork->thumb_srcset }}" @endif
                                        sizes="70px"
                                        alt="{{ $artwork->title }}"
                                        class="img-thumbnail"
                                        style="width:70px;height:70px;object-fit:cover"
                                    >
                                </a>
                            </td>
                            <td>
                                <div style="font-weight:700;line-height:1.2">
                                    <a href="{{ route('dashboard.artworks.edit', $artwork->id) }}">{{ $artwork->title }}</a>
                                </div>
                                <div class="text-muted" style="font-size:12px">#{{ $artwork->id }}</div>
                                @if(!empty($artwork->description))
                                    <div class="text-muted" style="margin-top:4px;font-size:12px">
                                        {{ str($artwork->description)->stripTags()->limit(120) }}
                                    </div>
                                @endif
                            </td>
                            <td class="text-center">{{ optional($artwork->created_at)->format('d.m.Y') }}</td>
                            <td class="text-center">
                                @if($artwork->is_public)
                                    <span class="label label-success">Yes</span>
                                @else
                                    <span class="label label-default">No</span>
                                @endif
                            </td>
                            <td class="text-center">
                                @if($artwork->is_approved)
                                    <span class="label label-primary">Yes</span>
                                @else
                                    <span class="label label-warning">No</span>
                                @endif
                            </td>
                            <td class="text-center">
                                <div class="btn-group" role="group" aria-label="Actions">
                                    <a href="{{ route('dashboard.artworks.edit', $artwork->id) }}" class="btn btn-xs btn-default">
                                        <i class="fa fa-pencil fa-fw"></i> Edit
                                    </a>

                                    <form method="POST" action="{{ route('dashboard.artworks.destroy', $artwork->id) }}" style="display:inline-block" onsubmit="return confirm('Delete this artwork?');">
                                        @csrf
                                        @method('DELETE')
                                        <button type="submit" class="btn btn-xs btn-danger">
                                            <i class="fa fa-trash fa-fw"></i> Delete
                                        </button>
                                    </form>
                                </div>
                            </td>
                        </tr>
                    @empty
                        <tr>
                            <td colspan="6">No artworks found.</td>
                        </tr>
                    @endforelse
                    </tbody>
                </table>
            </div>
        </div>
    </div>

    <div class="paginationMenu text-center">
        {{ $artworks->links('pagination::bootstrap-3') }}
    </div>
</div>
@endsection
