

<?php $__env->startSection('section'); ?>
    <div class="page-body">
        <div class="container-fluid">
            <div class="row">
                <div class="container-fluid">
                    <div class="row page-title">
                        <div class="col-sm-6">
                            <h3>Tag List</h3>
                        </div>
                        <div class="col-sm-6 text-end">
                            <a class="btn btn-primary" href="<?php echo e(route('tag.add')); ?>">
                                <svg class="feather">
                                    <use href="<?php echo e(asset('assets/svg/feather-icons/dist/feather-sprite.svg#plus-square')); ?>">
                                    </use>
                                </svg>
                                Add New Tag
                            </a>
                        </div>
                    </div>
                </div>
                <div class="col-sm-12">
                    <!-- Tag table -->
                    <div class="card">
                        <div class="card-body">
                            <div class="table-responsive theme-scrollbar product-table">
                                <table class="display table table-bordered" id="basic-3">
                                    <thead>
                                        <tr>
                                            <th>S.No</th>
                                            <th>Name</th>
                                            <th>Status</th>
                                            <th>Actions</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php $__empty_1 = true; $__currentLoopData = $tags; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $tag): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                            <tr>
                                                <td><?php echo e($loop->iteration); ?></td>
                                                <td><?php echo e($tag->name); ?></td>
                                                <td>
                                                    <span
                                                        class="badge rounded-pill toggle-status <?php echo e($tag->status == 1 ? 'bg-success' : 'bg-danger'); ?>"
                                                        data-id="<?php echo e($tag->id); ?>" style="cursor: pointer;">
                                                        <?php echo e($tag->status == 1 ? 'Active' : 'Inactive'); ?>

                                                    </span>
                                                </td>
                                                <td>
                                                    <a href="<?php echo e(route('edit.tag', $tag->id)); ?>" class="btn btn-primary btn-xs"
                                                        title="Edit">Edit</a>
                                                    <form action="<?php echo e(route('tag.delete', $tag->id)); ?>" method="POST"
                                                        class="d-inline-block"
                                                        onsubmit="return confirm('Are you sure you want to delete this tag?');">
                                                        <?php echo csrf_field(); ?>
                                                        <?php echo method_field('DELETE'); ?>
                                                        <button type="submit" class="btn btn-danger btn-xs"
                                                            title="Delete">Delete</button>
                                                    </form>
                                                </td>
                                            </tr>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                            <tr>
                                                <td colspan="4" class="text-center">No tags found.</td>
                                            </tr>
                                        <?php endif; ?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- Container-fluid ends-->
    </div>

    <script src="<?php echo e(asset('assets/js/vendors/simple-datatables/dist/umd/simple-datatables.js')); ?>"></script>
    <script src="<?php echo e(asset('assets/js/product/product-list-custom.js')); ?>"></script>

    <script>
        document.addEventListener("DOMContentLoaded", function () {
            const statusButtons = document.querySelectorAll('.toggle-status');

            statusButtons.forEach(button => {
                button.addEventListener('click', function () {
                    const tagId = this.getAttribute('data-id');

                    fetch("<?php echo e(route('tag.changeStatusAjax')); ?>", {
                        method: 'POST',
                        headers: {
                            'X-CSRF-TOKEN': '<?php echo e(csrf_token()); ?>',
                            'Content-Type': 'application/json'
                        },
                        body: JSON.stringify({ id: tagId })
                    })
                        .then(response => response.json())
                        .then(data => {
                            if (data.success) {
                                this.classList.toggle('bg-success', data.status == 1);
                                this.classList.toggle('bg-danger', data.status == 0);
                                this.textContent = data.status == 1 ? 'Active' : 'Inactive';
                            }
                        })
                        .catch(error => console.error('Error:', error));
                });
            });
        });
    </script>

<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.layouts.main', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH A:\xamp102024\htdocs\sachin\androidwale.com\resources\views/admin/tag/list.blade.php ENDPATH**/ ?>