<?php $__env->startSection('title', 'User'); ?>
<?php $__env->startPush('css'); ?>
    <style>
        .is-invalid {
            border-color: var(--color-primary) !important;
        }
    </style>
<?php $__env->stopPush(); ?>
<?php $__env->startSection('content'); ?>
    <div class="content">
        <div class="container-fluid">
            <div class="d-flex justify-content-between align-items-center">
                <div class="">
                    <h4 class="mb-1">Users</h4>
                    <nav style="--bs-breadcrumb-divider: '|';"  aria-label="breadcrumb" >
                        <ol class="breadcrumb m-0">
                            <li class="breadcrumb-item"><a href="#!" class="text-primary">User</a></li>
                            <li class="breadcrumb-item active" aria-current="page">List</li>
                        </ol>
                    </nav>
                </div>
                <div>
                    <a href="<?php echo e(route('user.create')); ?>" class="btn btn-primary">Add User</a>
                </div>
            </div>
            <div class="row">
                <div class="row g-3">
                    <?php $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <div class="col-xl-3 user-col col-lg-4 col-md-4 col-sm-6">
                            <div class="card user-card-div">
                                <div class="user-opt-ab">
                          <span class="user-opt-dot"><i class="fa-solid fa-ellipsis"></i>
                            <div class="user-opt-select">
                                <a href="<?php echo e(route('user.edit',['id' => $user->id])); ?>">Edit</a>
                                <a href="#">Delete</a>
                            </div>
                          </span>
                                </div>
                                <div class="d-flex justify-content-between align-items-center">
                                    <div class="d-flex align-items-center">
                                        <img src="<?php echo e(asset('assets/img/default_image.jpeg')); ?>" class="user-img-div me-3" alt="profile">
                                        <div>
                                            <h6 class="mb-0"><?php echo e($user->name); ?></h6>
                                            <small class="text-muted"><?php echo e($user->email); ?></small>
                                            <p class="mb-0"><small class="text-muted"><?php echo e($user->user_type); ?></small></p>
                                        </div>
                                    </div>

                                    <div>
                                        <div class="form-check form-switch">
                                            <input class="form-check-input toggleStatus"  data-id =<?php echo e($user->id); ?> type="checkbox" <?php echo e($user->status==1 ? 'checked' :''); ?> id="activeToggle">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </div>
            </div>
        </div>
    </div>

    <?php $__env->startPush('scripts'); ?>
        <script>
            $(document).on('change', '.toggleStatus', function () {
                let userId = $(this).data('id');
                let status = $(this).is(':checked') ? 1 : 0;

                $.ajax({
                    url: "<?php echo e(route('user.toggleStatus')); ?>",
                    type: "POST",
                    data: {
                        _token: "<?php echo e(csrf_token()); ?>",
                        id: userId,
                        status: status
                    },
                    success: function (response) {
                        if (response.success) {
                           notification('success',response.message,'success',2000)
                        } else {
                            notification('error',response.message,'danger',2000)
                        }
                    },
                    error: function (xhr) {
                        console.error(xhr.responseText);
                        notification('error',response.message,'danger',2000)
                    }
                });
            });
        </script>
    <?php $__env->stopPush(); ?>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.admin.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/zprintin/public_html/admin.narinetwork.online/resources/views/admin/user_list.blade.php ENDPATH**/ ?>