
<?php $__env->startSection('breadcrumb-first', 'Masuk'); ?>
<?php $__env->startSection('breadcrumb-second', website_config('main')->website_name); ?>

<?php $__env->startSection('content'); ?>
<div class="row">
	<div class="col-lg-6 offset-lg-3">
		<div class="card card-custom">
			<div class="card-body">
                <form method="post" action="<?php echo e(request()->url()); ?>" id="input_form">
                    <?php echo csrf_field(); ?>
                    <div class="form-group">
                        <label class="form-label">Username <text class="text-danger">*</text></label>
                        <input class="form-control" type="text" name="username" id="username">
                        <small id="username"></small>
                    </div>
                    <div class="form-group">
                        <div class="d-flex justify-content-between">
                            <label class="form-label">Password <text class="text-danger">*</text></label>
                        </div>
                        <input type="password" class="form-control" name="password" id="password">
                        <small id="password"></small>
                    </div>
                    <div class="form-group">
                        <div class="custom-control custom-checkbox">
                            <input type="checkbox" class="custom-control-input" name="remember" id="remember" value="1">
                            <label class="custom-control-label" for="remember">Tetap masuk selama 30 hari</label>
                        </div>
                    </div>
                    <div class="button-items d-grid gap-2">
                        <button type="submit" class="btn btn-custom btn btn-block waves-effect waves-light">Masuk</button>
                    </div>
                </form>
			</div>
		</div>
	</div>
</div>
<script>
    $("#input_form").on('submit', function(element) {
        element.preventDefault();
        $.ajax({
            url: $(this).attr('action'),
            method: $(this).attr('method'),
            data: new FormData(this),
            processData: false,
            dataType: 'json',
            contentType: false,
            beforeSend: function() {
				$('#preloader').fadeIn("slow");
                $('button:submit').attr('disabled', 'true');
                $('button:submit').text('');
                $('button:submit').append('Mohon tunggu...');
                $(document).find('input, select').removeClass('is-invalid').removeClass('is-valid');
            },
            success: function(response) {
				$('#preloader').fadeOut("slow");
                $('button:submit').removeAttr('disabled');
                $('button:submit').text('Masuk');
                if (response.status == false) {
                    if (response.type == 'validation') {
                        $.each(response.message, function(key, value) {
							$('input#'+key+', select#'+key+'').addClass('is-invalid');
							$('small#'+key+'').addClass('invalid-feedback').html(value[0]);
                        });
                        showAlert('danger', 'Periksa Input', 3000, 'col-lg-6 offset-lg-3');
                    } 
                    if (response.type == 'alert') {
                        showAlert(
                            response.hasOwnProperty('alert') ? response.alert : 'danger', 
                            response.message, 
                            response.hasOwnProperty('timeout') ? response.timeout : 5000, 
                            response.hasOwnProperty('size') ? response.size : 'col-lg-6 offset-lg-3'
                        );
                    }
                } else {
                    $('button:submit').attr('disabled', 'true');
                    $('button:submit').text('');
                    $('button:submit').append('Mohon tunggu...');
                    showAlert(
                        'success', 
                        response.message, 
                        1000, 
                        'col-lg-6 offset-lg-3', 
                        '<?= url('admin') ?>'
                    );
                }
                $("input, select").each(function() {
                    if (this.classList.contains('is-invalid') == false && this.id !== 'remember') {
                        this.classList.add('is-valid');
                    }
                });
            },
            error: function() {
				$('#preloader').fadeOut("slow");
                $('button:submit').removeAttr('disabled');
                $('button:submit').text('Masuk');
                showAlert(
                    'danger', 
                    'Terjadi kesalahan.', 
                    5000, 
                    'col-lg-6 offset-lg-3'
                );
            },
        });
    });
</script>
<?php $__env->stopSection(); ?>


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