@layout('theme::layouts/admin')

@section('title')Deleted content@endsection
@section('page_title')Deleted content@endsection

@section('content')

@notempty($notice)
<div class="admin-alert admin-alert-success">{{ $notice }}</div>
@endnotempty

<div class="admin-card">
    <div class="admin-card-header">Deleted topics</div>
    <div class="admin-card-body">
        <p class="form-hint">
            Deleting hides something and keeps it. Everything here can be put back exactly as it was,
            or removed for good &mdash; and <strong>removing for good cannot be undone</strong>.
        </p>
    </div>

    @notempty($topics)
    <table class="admin-table">
        <thead>
            <tr><th>Title</th><th>Where</th><th>By</th><th>Deleted</th><th>Replies</th><th></th></tr>
        </thead>
        <tbody>
            @each ($topics as $topic)
            <tr>
                <td>{{ $topic['title'] }}</td>
                <td>
                    {# A topic owned by an application has no forum, which is normal. #}
                    {{ $topic['forum']['title'] ?? '—' }}
                </td>
                <td>{{ $topic['author']['username'] ?? 'Unknown' }}</td>
                <td>{{ \Convoro\Engine\Support\Presence::ago($topic['deleted_at']) }}</td>
                <td class="cv-tabular">{{ $topic['post_count_all'] }}</td>
                <td class="admin-table-actions">
                    <form method="POST" action="/admin/moderation/deleted/topic/{{ $topic['id'] }}/restore"
                          class="admin-inline-form">
                        @csrf
                        <button type="submit" class="btn btn-outline btn-sm">Restore</button>
                    </form>
                    <form method="POST" action="/admin/moderation/deleted/topic/{{ $topic['id'] }}/purge"
                          class="admin-inline-form"
                          onsubmit="return confirm('Delete “{{ $topic['title'] }}” and its {{ $topic['post_count_all'] }} replies for good? This cannot be undone.')">
                        @csrf
                        <button type="submit" class="btn btn-quiet-danger btn-sm">Delete for good</button>
                    </form>
                </td>
            </tr>
            @endeach
        </tbody>
    </table>
    @endnotempty

    @empty($topics)
    <div class="admin-card-body">
        <p class="form-hint">Nothing has been deleted.</p>
    </div>
    @endempty
</div>

<div class="admin-card">
    <div class="admin-card-header">Deleted replies</div>
    <div class="admin-card-body">
        <p class="form-hint">
            Replies deleted on their own. Replies inside a deleted topic are not listed separately
            &mdash; restoring the topic brings them all back with it.
        </p>
    </div>

    @notempty($posts)
    <table class="admin-table">
        <thead><tr><th>In</th><th>By</th><th>Deleted</th><th></th></tr></thead>
        <tbody>
            @each ($posts as $post)
            <tr>
                <td>{{ $post['topic']['title'] ?? 'Unknown topic' }}</td>
                <td>{{ $post['author']['username'] ?? 'Unknown' }}</td>
                <td>{{ \Convoro\Engine\Support\Presence::ago($post['deleted_at']) }}</td>
                <td class="admin-table-actions">
                    <form method="POST" action="/admin/moderation/deleted/post/{{ $post['id'] }}/restore"
                          class="admin-inline-form">
                        @csrf
                        <button type="submit" class="btn btn-outline btn-sm">Restore</button>
                    </form>
                    <form method="POST" action="/admin/moderation/deleted/post/{{ $post['id'] }}/purge"
                          class="admin-inline-form"
                          onsubmit="return confirm('Delete this reply for good? This cannot be undone.')">
                        @csrf
                        <button type="submit" class="btn btn-quiet-danger btn-sm">Delete for good</button>
                    </form>
                </td>
            </tr>
            @endeach
        </tbody>
    </table>
    @endnotempty

    @empty($posts)
    <div class="admin-card-body">
        <p class="form-hint">No replies have been deleted on their own.</p>
    </div>
    @endempty
</div>

@endsection
