
<div class="row hidden" id="alert">
	<div class="col-lg-12" id="alert-size">
		<div class="alert alert-secondary alert-dismissible show fade text-dark" role="alert" id="alert-type">
			<button type="button" class="close" data-dismiss="alert" aria-label="Close">
				<span aria-hidden="true">&times;</span>
			</button>
			<div class="alert-body" id="alert-body">
				{{-- <i class="fa fa-times-circle"></i> <b>Gagal</b>: Silahkan masuk terlebih dahulu --}}
			</div>
		</div>
	</div>
</div>
<script>
function showAlert(type = 'danger', message = 'Halo!', timeOut = 5000, size = 'col-lg-12', redirect = '') {
	if (type == 'danger') {
		message = '<b><i class="fa fa-times-circle"></i> Gagal:</b> '+message;
	} else if (type == 'success') {
		message = '<b><i class="fa fa-check-circle"></i> Berhasil:</b> '+message;
	} else if (type == 'info') {
		message = '<b><i class="fa fa-info-circle"></i> Informasi:</b> '+message;
	} else if (type == 'primary') {
		message = '<b><i class="fa fa-info-circle"></i> Informasi:</b> '+message;
	}
	$('html,body').animate({
		scrollTop: $('#alert').offset().top
	}, 'slow');
	$('#alert').removeClass('hidden'); 
	$('#alert-body').html(message);
	document.getElementById('alert-size').className = size;
	document.getElementById('alert-type').className = 'text-white alert-dismissible show fade alert alert-'+ type +' bg-'+ type +' border-'+ type;
	setTimeout(() => {
		$('#alert').addClass('hidden');
		if (redirect !== '') {
			window.location = redirect;
		}
	}, timeOut);
}
</script>
@if(session()->has('result'))
<script>
	var type = '{{ session()->get('result')['alert'] ?? "danger" }}';
	var message = '{!! session()->get('result')['message'] ?? "Halo!" !!}';
	var timeOut = '{{ session()->get('result')['timeout'] ?? 5000 }}';
	var size = '{{ session()->get('result')['size'] ?? "col-lg-12" }}';
	showAlert(type, message, timeOut, size);
</script>
@endif
