sidakpelem/resources/views/admin/layouts/app.blade.php

95 lines
2.5 KiB
PHP

<!DOCTYPE html>
<html lang="en">
<head>
@include('admin.partials.head', [
'title' => trim($__env->yieldContent('title', 'Home')) . ' | SidakDesa',
])
@stack('styles')
</head>
<body data-pc-preset="preset-1" data-pc-direction="ltr" data-pc-theme="light">
@include('admin.partials.loader')
@include('admin.partials.sidebar')
@include('admin.partials.header')
<div class="pc-container">
<div class="pc-content">
@yield('content')
</div>
</div>
@php
$toastMessages = [];
if (session('success')) {
$toastMessages[] = [
'type' => 'success',
'title' => 'Berhasil',
'message' => session('success'),
];
}
if (session('error')) {
$toastMessages[] = [
'type' => 'error',
'title' => 'Gagal',
'message' => session('error'),
];
}
if ($errors->any()) {
$toastMessages[] = [
'type' => 'error',
'title' => 'Validasi gagal',
'message' => $errors->first(),
];
}
@endphp
@include('admin.partials.footer')
@include('admin.partials.scripts')
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
if (typeof Swal === 'undefined') {
return;
}
const toastMessages = @json($toastMessages);
if (!toastMessages.length) {
return;
}
const Toast = Swal.mixin({
toast: true,
position: 'top-end',
showConfirmButton: false,
timer: 4000,
timerProgressBar: true,
didOpen: (toast) => {
toast.addEventListener('mouseenter', Swal.stopTimer);
toast.addEventListener('mouseleave', Swal.resumeTimer);
}
});
toastMessages.forEach(function(toast, index) {
window.setTimeout(function() {
Toast.fire({
icon: toast.type,
title: toast.title,
text: toast.message,
});
}, index * 150);
});
});
</script>
@stack('scripts')
</body>
</html>