<?php $__env->startSection('title', 'Pages'); ?>

<?php $__env->startSection('content'); ?>

<div class="container-fluid">

    <div class="page-title-head d-flex align-items-center">
        <div class="flex-grow-1">
            <h4 class="page-main-title m-0">Pages</h4>
        </div>
        <div class="text-end">
            <ol class="breadcrumb m-0 py-0">
                <li class="breadcrumb-item"><a href="<?php echo e(url('/')); ?>">Dashboard</a></li>
                <li class="breadcrumb-item"><a href="<?php echo e(route('settings.index')); ?>">Settings</a></li>
                <li class="breadcrumb-item active">Pages</li>
            </ol>
        </div>
    </div>

    <?php if(session('success')): ?>
        <div class="alert alert-success alert-dismissible fade show" role="alert">
            <?php echo e(session('success')); ?>

            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
        </div>
    <?php endif; ?>

    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-header border-light d-flex justify-content-between align-items-center">
                    <p class="text-muted fs-xs mb-0">
                        Static content pages rendered on the storefront at <code>/pages/&#123;slug&#125;</code>
                        — e.g. About Us and Terms &amp; Conditions in the site footer.
                    </p>
                    <?php if (\Illuminate\Support\Facades\Blade::check('permission', 'pages.create')): ?>
                    <a href="<?php echo e(route('pages.create')); ?>" class="btn btn-primary btn-sm">
                        <i class="ti ti-plus fs-sm me-1"></i> Add Page
                    </a>
                    <?php endif; ?>
                </div>

                <div class="table-responsive">
                    <table class="table table-striped dt-responsive align-middle mb-0">
                        <thead class="bg-light align-middle bg-opacity-25 thead-sm">
                            <tr class="text-uppercase fs-xxs">
                                <th>Title</th>
                                <th>Slug</th>
                                <th>Last Updated</th>
                                <th class="text-center" style="width: 1%;">Actions</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__empty_1 = true; $__currentLoopData = $pages; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $page): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <tr>
                                    <td class="fw-medium"><?php echo e($page->title); ?></td>
                                    <td><code class="text-muted">/pages/<?php echo e($page->slug); ?></code></td>
                                    <td><?php echo e(optional($page->updated_at)->format('d M, Y') ?? '—'); ?></td>
                                    <td class="text-center">
                                        <div class="d-flex justify-content-center gap-1">
                                            <a href="<?php echo e(route('website.pages.show', $page)); ?>" target="_blank"
                                                class="btn btn-default btn-icon btn-sm" title="View on Site">
                                                <i class="ti ti-external-link fs-lg"></i>
                                            </a>
                                            <?php if (\Illuminate\Support\Facades\Blade::check('permission', 'pages.edit')): ?>
                                            <a href="<?php echo e(route('pages.edit', $page)); ?>" class="btn btn-default btn-icon btn-sm" title="Edit">
                                                <i class="ti ti-edit fs-lg"></i>
                                            </a>
                                            <?php endif; ?>
                                            <?php if (\Illuminate\Support\Facades\Blade::check('permission', 'pages.delete')): ?>
                                            <button type="button" class="btn btn-default btn-icon btn-sm js-delete text-danger"
                                                data-url="<?php echo e(route('pages.destroy', $page)); ?>" data-name="<?php echo e(e($page->title)); ?>" title="Delete">
                                                <i class="ti ti-trash fs-lg"></i>
                                            </button>
                                            <?php endif; ?>
                                        </div>
                                    </td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr>
                                    <td colspan="4" class="text-center text-muted py-4">No pages yet.</td>
                                </tr>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

</div>

<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>
<script>
    $(function () {
        const csrfToken = $('meta[name="csrf-token"]').attr('content');

        $('.js-delete').on('click', function () {
            const url  = $(this).data('url');
            const name = $(this).data('name');
            if (!confirm('Delete "' + name + '"? (This is a soft delete.)')) return;
            $.ajax({
                url: url,
                type: 'DELETE',
                headers: { 'X-CSRF-TOKEN': csrfToken, 'Accept': 'application/json' },
                success: function (res) {
                    if (res.success) location.reload();
                    else alert(res.message || 'Could not delete page.');
                },
                error: function (xhr) {
                    const msg = (xhr.responseJSON && xhr.responseJSON.message) ? xhr.responseJSON.message : 'Failed to delete page.';
                    alert(msg);
                },
            });
        });
    });
</script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layout.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH F:\VScode LIve ftp\paces\resources\views/pages/index.blade.php ENDPATH**/ ?>