Files
ilycats/resources/views/layouts/app.blade.php
T
2026-02-08 15:16:35 +07:00

182 lines
8.9 KiB
PHP

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}" class="h-full">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
@php
// Optimasi: Gunakan try-catch agar jika tabel settings belum dimigrasi, app tidak crash
try {
$settings = \App\Models\Setting::whereIn('key', ['app_name', 'app_slogan', 'app_favicon', 'app_version'])
->pluck('value', 'key');
} catch (\Exception $e) {
$settings = collect();
}
$appName = $settings['app_name'] ?? config('app.name', 'Ily Cattery');
$appSlogan = $settings['app_slogan'] ?? 'Dedikasi untuk Kesehatan dan Kebahagiaan Anabul';
$appVersion = $settings['app_version'] ?? 'v1.0.0';
$favicon = $settings['app_favicon'] ?? null;
@endphp
<link rel="icon" type="image/x-icon" href="{{ $favicon ? Storage::url($favicon) : asset('favicon.ico') }}">
<title>{{ $appName }}</title>
{{-- Fonts & Icons --}}
<link rel="preconnect" href="https://fonts.bunny.net">
<link href="https://fonts.bunny.net/css?family=figtree:400,500,600,800,900&display=swap" rel="stylesheet" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
{{-- Scripts & Styles --}}
@vite(['resources/css/app.css', 'resources/js/app.js'])
@stack('styles')
<style>
.custom-scrollbar::-webkit-scrollbar { width: 6px; }
.custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 10px; }
.custom-scrollbar::-webkit-scrollbar-thumb:hover { background: #cbd5e1; }
[x-cloak] { display: none !important; }
/* Animasi Fade In untuk Main Content */
.page-fade-in { animation: fadeIn 0.4s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
</style>
</head>
<body class="font-sans antialiased text-slate-900 bg-slate-50 h-full overflow-hidden">
<div class="flex h-screen overflow-hidden">
{{-- Sidebar Navigation --}}
@include('layouts.navigation-sidebar')
<div class="flex-1 flex flex-col min-w-0 bg-slate-50 relative">
{{-- Top Navigation --}}
@include('layouts.navigation')
{{-- Main Content Area --}}
<main class="flex-1 overflow-y-auto custom-scrollbar flex flex-col">
<div class="max-w-7xl mx-auto w-full p-4 md:p-8 flex-grow page-fade-in">
{{-- Notifikasi Error/Validasi (Hanya muncul jika bukan AJAX) --}}
@if ($errors->any())
<div x-data="{ show: true }" x-show="show" x-cloak
class="mb-6 p-4 bg-rose-50 border-2 border-rose-100 text-rose-700 rounded-3xl flex items-start shadow-sm transition-all">
<i class="fas fa-exclamation-circle mt-0.5 mr-3 text-lg"></i>
<div>
<h4 class="text-[11px] font-black uppercase tracking-widest mb-1">Terjadi Kesalahan Input:</h4>
<ul class="list-disc list-inside text-[10px] font-bold opacity-80">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
<button @click="show = false" class="ml-auto text-rose-300 hover:text-rose-500"><i class="fas fa-times"></i></button>
</div>
@endif
{{-- Main Slot (Halaman Konten Anda) --}}
{{ $slot }}
</div>
{{-- Footer --}}
<footer class="w-full py-8 border-t border-slate-100 mt-auto bg-white/50 backdrop-blur-md">
<div class="max-w-7xl mx-auto px-8 text-center">
<p class="text-[10px] font-black text-slate-400 uppercase tracking-[0.3em] mb-1">
{{ $appName }}
</p>
<p class="text-[9px] text-slate-300 font-bold tracking-widest italic uppercase">
{{ $appSlogan }} — {{ $appVersion }}
</p>
</div>
</footer>
</main>
</div>
</div>
{{-- SWEETALERT 2 INTEGRATION --}}
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
// 1. KONFIGURASI TOAST
const IlyToast = Swal.mixin({
toast: true,
position: 'top-end',
showConfirmButton: false,
timer: 3500,
timerProgressBar: true,
didOpen: (toast) => {
toast.addEventListener('mouseenter', Swal.stopTimer)
toast.addEventListener('mouseleave', Swal.resumeTimer)
},
customClass: {
popup: 'rounded-2xl shadow-2xl border border-slate-50 p-4',
title: 'text-[11px] font-black uppercase tracking-widest ml-2'
}
});
// 2. FUNGSI GLOBAL TOAST (Bisa dipanggil di file JS manapun)
window.showToast = function(message, icon = 'success') {
IlyToast.fire({
icon: icon,
title: message,
iconColor: icon === 'success' ? '#4f46e5' : '#e11d48',
});
}
// 3. AUTO-TRIGGER FLASH MESSAGE
@if(session('success'))
showToast("{{ session('success') }}", 'success');
@endif
@if(session('error'))
showToast("{{ session('error') }}", 'error');
@endif
// 4. FUNGSI GLOBAL KONFIRMASI DELETE (Universal)
// Mendukung pemanggilan via ID Form (confirmDelete('formId', 'Nama'))
// Atau pemanggilan via Element (confirmDelete(this, 'Nama'))
window.confirmDelete = function(target, itemName = 'Data ini') {
const finalName = itemName || 'Data terpilih';
Swal.fire({
title: 'HAPUS DATA?',
html: "<div class='text-sm text-slate-500 font-medium'>Anda akan menghapus:<br><b class='text-slate-800 uppercase tracking-tighter'>" + finalName + "</b><br><br><span class='text-rose-500 font-bold italic'>Peringatan: Data yang dihapus tidak dapat dipulihkan!</span></div>",
icon: 'warning',
iconColor: '#e11d48',
showCancelButton: true,
confirmButtonColor: '#e11d48',
cancelButtonColor: '#f1f5f9',
confirmButtonText: 'YA, HAPUS PERMANEN',
cancelButtonText: 'BATAL',
reverseButtons: true,
customClass: {
popup: 'rounded-[2.5rem] p-10 border-none shadow-2xl',
confirmButton: 'rounded-2xl font-black uppercase text-[10px] px-8 py-4 ml-3 tracking-widest shadow-lg shadow-rose-100',
cancelButton: 'rounded-2xl font-black uppercase text-[10px] px-8 py-4 text-slate-500 tracking-widest'
}
}).then((result) => {
if (result.isConfirmed) {
// Logic: Jika target adalah string, cari by ID. Jika object, cari closest form.
if (typeof target === 'string') {
const form = document.getElementById(target);
if(form) form.submit();
} else {
const form = target.closest('form');
if(form) form.submit();
}
}
});
}
});
</script>
@stack('scripts')
</body>
</html>