@extends('admin.layouts.main')
@section('section')

    <div class="page-body">
        <div class="container-fluid">
            <div class="row page-title">
                <div class="col-sm-6">
                    <h3>Deleted Post List</h3>
                </div>
                <div class="col-sm-6">
                    <nav>
                        <ol class="breadcrumb justify-content-sm-end align-items-center">
                            <li class="breadcrumb-item"><a href="{{ route('dashboard') }}">
                                    <svg class="svg-color">
                                        <use href="{{ asset('assets/svg/iconly-sprite.svg#Home') }}"></use>
                                    </svg></a>
                            </li>
                            <li class="breadcrumb-item">Posts</li>
                            <li class="breadcrumb-item ">Post List</li>
                            <li class="breadcrumb-item active">Deleted Post List</li>
                        </ol>
                    </nav>
                </div>
            </div>
        </div>

        <!-- Container-fluid starts-->
        <div class="container-fluid list-products">
            <div class="row">
                <div class="col-md-12 project-list">
                    <div class="card">
                        <div class="row align-items-center justify-content-between">
                            <!-- Left Side: Active Post Link -->
                         

                            <div class="col-md-6 col-12 mb-2 mb-md-0">
                                <a class="btn btn-warning d-inline-flex" href="{{ route('post.list') }}">
                                    <svg class="feather me-2">
                                        <use href="{{ asset('assets/svg/feather-icons/dist/feather-sprite.svg#target') }}">
                                        </use>
                                    </svg>
                                    Active Post
                                </a>
                            </div>

                            <!-- Right Side: Add New Post Button -->
                            <div class="col-md-6 col-12 text-md-end">
                                <a class="btn btn-primary d-inline-flex align-items-center" href="{{ route('post.add') }}">
                                    <svg class="feather me-2">
                                        <use
                                            href="{{ asset('assets/svg/feather-icons/dist/feather-sprite.svg#plus-square') }}">
                                        </use>
                                    </svg>
                                    Add New Post
                                </a>
                            </div>
                        </div>
                    </div>
                </div>


                <!-- Post Table -->
                <div class="col-sm-12">
                    <div class="card">
                        <div class="card-body">
                            <div class="table-responsive theme-scrollbar product-table">
                                <table class="table display" id="post-datatable">
                                    <thead>
                                        <tr>
                                            <th>S.no</th>
                                            <th>Title</th>
                                            <th>Details</th>
                                            <th>Status</th>
                                            <th>Image</th>
                                            <th>Created By</th>
                                            <th>Created Date</th>
                                            <th>Action</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @foreach ($titles as $post)
                                            <tr>
                                                <td>{{ $loop->iteration }}</td>
                                                <td>{{ $post->title }}</td>
                                                <td>{{ Str::limit(strip_tags($post->content), 30) }}</td>
                                                <td>
                                                    <span
                                                        class="badge rounded-pill toggle-status {{ $post->status ? 'bg-success' : 'bg-danger' }}">
                                                        {{ $post->status ? 'Publish' : 'Unpublish' }}
                                                    </span>
                                                </td>
                                                <td>
                                                    @if ($post->featured_image)
                                                        <img src="{{ asset('storage/' . $post->featured_image) }}" width="60"
                                                            height="50" class="rounded">
                                                    @else
                                                        N/A
                                                    @endif
                                                </td>
                                                <td>{{ $post->author->name ?? 'N/A' }}</td>
                                                <td>{{ $post->created_at ? $post->created_at->format('d/m/Y') : 'N/A' }}</td>
                                                <td>
                                                    <!-- Restore Button -->
                                                    <a href="{{ route('restore.post', $post->id) }}"
                                                        class="badge bg-warning text-dark rounded-pill btn-sm">
                                                        Restore
                                                    </a>

                                                    <!-- Permanent Delete Button -->
                                                    <a href="{{ route('delete.post', $post->id) }}"
                                                        class="badge bg-danger text-white rounded-pill btn-sm"
                                                        onclick="return confirm('Are you sure you want to permanently delete this post?')">
                                                        Permanently Delete
                                                    </a>
                                                </td>

                                            </tr>
                                        @endforeach
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- DataTables Script -->
    <script src="{{ asset('assets/js/vendors/simple-datatables/dist/umd/simple-datatables.js') }}"></script>

@endsection