diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 1b0c8ed..eecfe24 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -13,26 +13,37 @@ class ProfileController extends Controller { /** - * Menampilkan halaman utama profil pengguna. + * Menampilkan halaman utama profil pengguna secara dinamis berdasarkan role. */ public function index() { $user = Auth::user(); - if (!$user) { return redirect()->route('login'); } - $bukuOffline = DummyDataService::getBukuPinjamOffline($user); - $bukuOnline = DummyDataService::getBacaBukuOnline($user); - $statistik = DummyDataService::getDashboardStats(); + $viewData = ['user' => $user]; - return view('profile.index', [ - 'user' => $user, - 'bukuOffline' => $bukuOffline, - 'bukuOnline' => $bukuOnline, - 'statistik' => $statistik, - ]); + // Menyiapkan data berdasarkan role pengguna + if ($user->role === 'penjaga perpus') { + // Data untuk Penjaga Perpus: Statistik global & aktivitas terkini + $viewData['statistik'] = DummyDataService::getAdminDashboardStats(); + $viewData['aktivitasTerakhir'] = DummyDataService::getAktivitasTerakhir(); + + } elseif ($user->role === 'guru') { + // Data untuk Guru: Data personal + ringkasan laporan minat baca + $viewData['bukuOffline'] = DummyDataService::getBukuPinjamOffline($user); + $viewData['bukuOnline'] = DummyDataService::getBacaBukuOnline($user); + $viewData['laporan'] = DummyDataService::getLaporanMinatBaca(); + + } else { + // Data default untuk Siswa + $viewData['bukuOffline'] = DummyDataService::getBukuPinjamOffline($user); + $viewData['bukuOnline'] = DummyDataService::getBacaBukuOnline($user); + $viewData['statistik'] = DummyDataService::getDashboardStats(); + } + + return view('profile.index', $viewData); } /** diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index ec5adfd..0c8f63a 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -27,8 +27,15 @@ public function boot(): void } View::composer('*', function ($view) { - $notifikasi = collect(DummyDataService::getNotifikasi()); - $unreadNotificationsCount = $notifikasi->where('read', false)->count(); + $notifikasi = collect([]); + $unreadNotificationsCount = 0; + + // Hanya ambil notifikasi jika ada pengguna yang login + if (auth()->check()) { + $user = auth()->user(); + $notifikasi = collect(DummyDataService::getNotifikasiForUser($user)); + $unreadNotificationsCount = $notifikasi->where('read', false)->count(); + } $view->with(compact('notifikasi', 'unreadNotificationsCount')); }); diff --git a/app/Services/DummyDataService.php b/app/Services/DummyDataService.php index 1cb127e..1055854 100644 --- a/app/Services/DummyDataService.php +++ b/app/Services/DummyDataService.php @@ -39,6 +39,7 @@ public static function getAllSiswa(): array 'kelas' => 'XII RPL A', 'golongan' => 'A', ], + [ 'id' => 4, 'nisn' => '5566778899', @@ -205,6 +206,7 @@ public static function getAdminDashboardStats(): array ['label' => 'Denda Menunggu', 'value' => 0, 'icon' => 'bi-cash-coin', 'color' => 'danger'], ]; } + /** * Data untuk bar chart di dashboard admin (total peminjaman per bulan). */ @@ -240,17 +242,19 @@ public static function getAktivitasTerakhir(): array ['nama' => 'Rina Marlina', 'judul_buku' => 'Modul Ajar IPAS', 'tipe' => 'Peminjaman', 'waktu' => 'Kemarin', 'status' => 'Dipinjam'], ]; } - /** - * Data untuk 4 kartu statistik + * Data untuk halaman Dashboard Siswa dan Guru dengan warna spesifik. */ public static function getDashboardStats(): array { return [ - ['label' => 'Buku yang dipinjam', 'value' => 3, 'icon' => 'bi-book-half', 'color' => 'primary'], - ['label' => 'Tenggat Waktu', 'value' => '2', 'icon' => 'bi-clock-history', 'color' => 'warning'], - ['label' => 'Buku dikembalikan', 'value' => 12, 'icon' => 'bi-check-circle', 'color' => 'success'], - ['label' => 'History Baca', 'value' => 15, 'icon' => 'bi-hourglass-split', 'color' => 'info'], + ['label' => 'Buku yang dipinjam', 'value' => 3, 'icon' => 'bi-book-half', 'color' => '#5A81FA'], + + ['label' => 'Tenggat Waktu', 'value' => '2', 'icon' => 'bi-clock-history', 'color' => '#5A5FBA'], + + ['label' => 'Buku dikembalikan', 'value' => 12, 'icon' => 'bi-check-circle', 'color' => '#696E82'], + + ['label' => 'History Baca', 'value' => 15, 'icon' => 'bi-hourglass-split', 'color' => '#A8B1CE'], ]; } @@ -642,19 +646,86 @@ public static function getRiwayatOnline(): array } /** - * Data untuk fitur notifikasi. + * Data untuk notifikasi pengguna. + * @param \App\Models\User $user Pengguna yang sedang login. + * @return array Daftar notifikasi. */ - public static function getNotifikasi(): array + public static function getNotifikasiForUser($user): array { - return [ - ['icon' => 'bi-check2-circle', 'color' => 'success', 'title' => 'Buku "Perahu Kertas" berhasil dipinjam.', 'time' => '5 menit yang lalu', 'read' => false], - ['icon' => 'bi-exclamation-triangle', 'color' => 'danger', 'title' => 'Buku "Sosiologi" akan jatuh tempo besok!', 'time' => '1 jam yang lalu', 'read' => false], - ['icon' => 'bi-book-half', 'color' => 'info', 'title' => '5 buku baru ditambahkan ke kategori Fiksi.', 'time' => '3 jam yang lalu', 'read' => false], - ['icon' => 'bi-arrow-repeat', 'color' => 'primary', 'title' => 'Peminjaman buku "Modul IPAS" telah diperpanjang.', 'time' => 'Kemarin', 'read' => true], - ['icon' => 'bi-check-circle', 'color' => 'success', 'title' => 'Anda telah mengembalikan buku "The Last Spell Breather".', 'time' => 'Kemarin', 'read' => true], - ['icon' => 'bi-info-circle', 'color' => 'info', 'title' => 'Perpustakaan akan mengadakan acara baca buku bersama.', 'time' => '2 hari yang lalu', 'read' => true], - ['icon' => 'bi-person-check', 'color' => 'primary', 'title' => 'Profil Anda berhasil diperbarui.', 'time' => '2 hari yang lalu', 'read' => true], - ['icon' => 'bi-exclamation-triangle', 'color' => 'warning', 'title' => 'Sistem akan maintenance pada pukul 23:00.', 'time' => '3 hari yang lalu', 'read' => true], + $notifikasi = []; + + $bukuPinjaman = self::getBukuPinjamOffline($user); + + if (!empty($bukuPinjaman)) { + $bukuTerbaru = $bukuPinjaman[0]; + $notifikasi[] = [ + 'icon' => 'bi-check2-circle', + 'color' => 'success', + 'title' => 'Buku "' . $bukuTerbaru['judul'] . '" berhasil dipinjam.', + 'time' => '5 menit yang lalu', + 'read' => false, + 'type' => 'riwayat_peminjaman', + 'link_id' => null, + ]; + } + + + foreach ($bukuPinjaman as $buku) { + if ($buku['sisa_hari'] <= 3) { + $notifikasi[] = [ + 'icon' => 'bi-exclamation-triangle', + 'color' => 'danger', + 'title' => 'Buku "' . $buku['judul'] . '" akan jatuh tempo!', + 'time' => '1 jam yang lalu', + 'read' => false, + 'type' => 'riwayat_peminjaman', + 'link_id' => null, + ]; + } + } + + if ($user->role === 'guru') { + $notifikasi[] = [ + 'icon' => 'bi-lightbulb-fill', + 'color' => 'success', + 'title' => 'Rekomendasi pembelajaran baru telah ditambahkan.', + 'time' => 'Kemarin', + 'read' => true, + 'type' => 'rekomendasi', + 'link_id' => 1, + ]; + } + + $notifikasiUmum = [ + [ + 'icon' => 'bi-book-half', + 'color' => 'info', + 'title' => 'Buku baru ditambahkan ke kategori Fiksi.', + 'time' => '3 jam yang lalu', + 'read' => false, + 'type' => 'katalog_kategori', + 'link_id' => 'Fiksi', + ], + [ + 'icon' => 'bi-megaphone-fill', + 'color' => 'warning', + 'title' => 'Perpustakaan akan tutup lebih awal pada hari Jumat.', + 'time' => '1 hari yang lalu', + 'read' => true, + 'type' => 'halaman_profil', + 'link_id' => null, + ], + [ + 'icon' => 'bi-calendar-event', + 'color' => 'primary', + 'title' => 'Acara "Bedah Buku" akan diadakan minggu depan.', + 'time' => '2 hari yang lalu', + 'read' => true, + 'type' => 'halaman_profil', + 'link_id' => null, + ], ]; + + return array_merge($notifikasi, $notifikasiUmum); } } diff --git a/public/images/assets/vector-dashboard.svg b/public/images/assets/vector-dashboard.svg new file mode 100644 index 0000000..a465e4b --- /dev/null +++ b/public/images/assets/vector-dashboard.svg @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/js/dashboard-charts.js b/public/js/dashboard-charts.js index ba23c9c..de8410e 100644 --- a/public/js/dashboard-charts.js +++ b/public/js/dashboard-charts.js @@ -11,7 +11,7 @@ document.addEventListener('DOMContentLoaded', function () { labels: statistikData.labels, datasets: [{ label: 'Buku Dibaca', - backgroundColor: '#435ebe', + backgroundColor: '#5A81FA', data: statistikData.data, borderRadius: 8 }] @@ -63,7 +63,7 @@ document.addEventListener('DOMContentLoaded', function () { labels: ['Telah Dibaca', 'Belum Dibaca'], datasets: [{ data: [progressData.selesai, progressData.sisa], - backgroundColor: ['#435ebe', '#e9ecef'], + backgroundColor: ['#5A81FA', '#e9ecef'], borderColor: ['#ffffff'], borderWidth: 3, }] diff --git a/resources/scss/_variables.scss b/resources/scss/_variables.scss index 4a126f6..c66c9a9 100644 --- a/resources/scss/_variables.scss +++ b/resources/scss/_variables.scss @@ -1,13 +1,13 @@ @use "sass:color"; // =================================== -// VARIABLES & MAPS +// VARIABLES & MAPS // =================================== // Theme Colors Map $theme-colors: ( - "primary": #435ebe, - "secondary": color.mix(#6c757d, #ffffff, 80%), + "primary": #5A81FA, + "secondary": #5A5FBA, "success": color.mix(#198754, #ffffff, 85%), "info": color.mix(#0dcaf0, #ffffff, 80%), "warning": color.mix(#ffc107, #ffffff, 80%), @@ -16,10 +16,9 @@ $theme-colors: ( // Gray Colors Map $grays: ( - "light": #f4f7f8, - "dark": #4c5053, + "light": #f9f9f9, + "dark": #696E82, ); - // Spacing & Sizing $border-radius: 0.5rem; $border-radius-sm: 0.25rem; @@ -117,9 +116,9 @@ $transition: all 0.3s ease; } .icon-circle { - width: 50px; - height: 50px; - border-radius: 50%; + width: 60px; + height: 60px; + border-radius: 15%; } .icon-box { diff --git a/resources/scss/app.scss b/resources/scss/app.scss index 1b0f6a3..df9f16a 100644 --- a/resources/scss/app.scss +++ b/resources/scss/app.scss @@ -44,7 +44,7 @@ body { } .main-wrapper { - margin-left: 250px; + margin-left: 240px; } .sidebar.minimized { diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php index 410b396..400b2cd 100644 --- a/resources/views/dashboard.blade.php +++ b/resources/views/dashboard.blade.php @@ -6,34 +6,37 @@ Pinjam Buku Baru --}} -
-

{{ $greeting }}, {{ $user->nama_lengkap }} !

-

Apa yang ingin kamu baca hari ini?

+
+
+
+

{{ $greeting }}, {{ $user->nama_lengkap }}!

+

Siap memulai harimu dengan bacaan baru?

+
+
+ +
+ Ilustrasi Dashboard +
@foreach ($stats as $stat) -
-
-
-
-
-
{{ $stat['label'] }}
-

{{ $stat['value'] }}

-
-
-
- -
-
-
+
+
+
+
+ +
+
+

{{ $stat['value'] }}

+

{{ $stat['label'] }}

+
@endforeach
-
@@ -46,7 +49,7 @@
- [], 'data' => []])'> + [], 'data' => []])'>
@@ -63,7 +66,7 @@
- 0, 'sisa' => 0])'> + 0, 'sisa' => 0])'>
@@ -81,7 +84,6 @@
-
@@ -99,21 +101,21 @@
@forelse(collect($pengumuman)->take(2) as $item) -
@@ -134,156 +136,148 @@
@forelse(collect($pemberitahuan)->take(3) as $item) -
-
-
- -
-
-
{{ $item['title'] }}:
-
{{ $item['content'] }}
-
+
+
+
+ +
+
+
{{ $item['title'] }}:
+
{{ $item['content'] }}
- - {{ $item['badge'] }} -
- @if (!$loop->last) -
- @endif + + {{ $item['badge'] }} + +
+ @if (!$loop->last) +
+ @endif @empty -
- -

Tidak ada pemberitahuan baru.

-
+
+ +

Tidak ada pemberitahuan baru.

+
@endforelse
- -
+
Buku Pinjam Offline
@if (count($bukuPinjamOffline) > 2) -
- -
+
+ +
@endif
-
+
@forelse($bukuPinjamOffline as $buku) -
- -
- - Sisa: {{ $buku['sisa_hari'] }} hari -
-
-
- @empty - {{-- Jika tidak ada buku, akan menampilkan pesan ini di dalam card-body --}} -
-
- -

Tidak ada buku yang sedang dipinjam secara offline.

+
+ +
+ + Sisa: {{ $buku['sisa_hari'] }} hari
+
+
+ @empty +
+
+ +

Tidak ada buku yang sedang dipinjam secara offline.

+
@endforelse
- -
+
Baca Buku Online
@if (count($bacaBukuOnline) > 3) -
- -
+
+ +
@endif
-
+
@forelse($bacaBukuOnline as $buku) -
- -
-
- Progress - {{ $buku['progress'] }}% -
-
-
-
+
+ +
+
+ Progress + {{ $buku['progress'] }}% +
+
+
- -
- @empty - {{-- Jika tidak ada buku, akan menampilkan pesan ini di dalam card-body --}} -
-
- -

Tidak ada buku yang sedang dibaca secara online.

+ +
+ @empty +
+
+ +

Tidak ada buku yang sedang dibaca secara online.

+
@endforelse
- @if (Auth::user()->role == 'guru') -
-
-
- Rekomendasi Pembelajaran -
- -
-
- @forelse($rekomendasiPembelajaran->take(3) as $item) - - Thumbnail -
-
{{ $item['judul'] }}
- {{ $item['kategori'] }} -
-
- @if (!$loop->last) -
- @endif - @empty -

Belum ada rekomendasi.

- @endforelse -
+
+
+
+ Rekomendasi Pembelajaran +
+
+
+ @forelse(collect($rekomendasiPembelajaran)->take(3) as $item) + + Thumbnail +
+
{{ $item['judul'] }}
+ {{ $item['kategori'] }} +
+
+ @if (!$loop->last) +
+ @endif + @empty +

Belum ada rekomendasi.

+ @endforelse +
+
@endif @@ -300,16 +294,16 @@ class="badge fw-normal text-primary border me-1">{{ $item['kategori'] }}