

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

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

		<div class="card card-datatable table-responsive">
			<div class="card-header">
				<div id="custom-dt-toolbar">
					<div class="row">
						<div class="col-md-6">
							<div class="dt-toolbar-left">
								<h5 class="card-title mb-0">Manage SubCounties</h5>
							</div>
						</div>
						
						<div class="col-md-6 text-end">
							<div class="dt-toolbar-right">
								<?php if(auth()->user()->can('create-subcounties')): ?>
								<button class="btn create-new btn-kco-green openCreateModal" type="button">
									<span><i class="bx bx-plus bx-sm me-sm-2"></i> 
									<span class="d-none d-sm-inline-block">Add SubCounty</span>
									</span>
								</button>
								<?php endif; ?>
							</div>
						</div>
						
						</div>
					</div>
			</div><!--/.header-->
			<div class="card-body overflow-hidden">
				<?php
$__split = function ($name, $params = []) {
    return [$name, $params];
};
[$__name, $__params] = $__split('subcounties-table');

$__html = app('livewire')->mount($__name, $__params, 'lw-656501773-0', $__slots ?? [], get_defined_vars());

echo $__html;

unset($__html);
unset($__name);
unset($__params);
unset($__split);
if (isset($__slots)) unset($__slots);
?>
				<?php
$__split = function ($name, $params = []) {
    return [$name, $params];
};
[$__name, $__params] = $__split('subcounties');

$__html = app('livewire')->mount($__name, $__params, 'lw-656501773-1', $__slots ?? [], get_defined_vars());

echo $__html;

unset($__html);
unset($__name);
unset($__params);
unset($__split);
if (isset($__slots)) unset($__slots);
?>
			</div>
		</div>
		
<?php $__env->stopSection(); ?>

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

<script>
$(document).ready( function () {
	$(".openCreateModal").click(function(){
	Livewire.dispatch('openAddModal');
	});

	$(".rmv_modal_backdrop").click(function(){
	$('.modal-backdrop').remove();
	});
	        	
});
		window.addEventListener('openModal', (event) => {
			$('.modal-backdrop').remove();
			 //$('#editModal').modal('show');
			 const modalId = event.detail;
             //find modal
             const modal = new bootstrap.Modal(document.getElementById(modalId), {});
				modal.show();
		})
		
         window.addEventListener('closeModal', (event) => { 
             //the Id of the modal is passed from component
             const modalId = event.detail;
             //find modal
             const modalName = document.getElementById(modalId);
			 var modal = bootstrap.Modal.getInstance(modalName)
				modal.hide();
				$('.modal-backdrop').remove();
         })
     </script>

<script>
 //prepare toast
 window.Toast = Swal.mixin({
	 toast: true,
	 position: 'top-right',
	 showConfirmButton: false,
	 showCloseButton: true,
	 timer: 3000,
	 timerProgressBar: true,
	 didOpen: (toast) => {
		 toast.addEventListener('mouseenter', Swal.stopTimer)
		 toast.addEventListener('mouseleave', Swal.resumeTimer)
	 }
 });

  //fire toast on alert event
 window.addEventListener('alert', (event) => {

	 const eventData = event.detail;
	 const type = eventData[0].type;
	 const message = eventData[0].message;

	 Toast.fire({
		 icon: type,
		 title: message
	 })
 });

 //open a confirm dialog on confirmDelete event
 window.addEventListener('confirmDelete', (event) => {
	//event data (id, and deleteProductEvent)
	const eventData = event.detail;
	 Swal.fire({
		 title: 'Delete SubCounty?',
		 text: "You won't be able to revert this!",
		 icon: 'warning',
		 showCancelButton: true,
		 confirmButtonColor: '#3085d6',
		 cancelButtonColor: '#d33',
		 confirmButtonText: 'Yes, delete it!'
	 }).then((result) => {
		 if (result.isConfirmed) {
			 window.Livewire.dispatch(eventData.targetEvent, {id:eventData.id});
		 }
	 })
 });
</script>
<?php $__env->stopSection(); ?> 
<?php echo $__env->make('layouts/contentNavbarLayout', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\kcofbms3\resources\views/subcounties/index.blade.php ENDPATH**/ ?>