- Updated paginated methods in multiple services to accept a highlight parameter for filtering results. - Modified notification URLs to include the highlight parameter for specific entity IDs. - Enhanced frontend components to display a message when filtered by notification, with an option to show all entries. - Implemented mark as read functionality in the notification bell component upon clicking a notification. - Updated multiple index pages to handle the highlight prop and display relevant messages.
3.8 KiB
3.8 KiB
Fitur: Notification Highlight — Klik Notifikasi → Tabel Filtered by ID
Tujuan
Saat user klik notifikasi, mereka dibawa ke halaman tabel yang sesuai (misalnya Transaksi, Kasbon, dll), tapi hanya menampilkan data spesifik dari notifikasi tersebut. User tetap di halaman tabel dan bisa klik "Tampilkan semua" untuk kembali ke semua data.
File yang Dibaca
Backend
app/Http/Requests/PaginatedRequest.php— tambahhighlightkevalidatedWithDefaults()app/Services/Admin/Master/CategoryService.php— tambah$highlightparameter +->where('id', $highlight)app/Services/Admin/Finance/ExpenseService.php— samaapp/Services/Admin/Finance/EmployeeAdvanceService.php— samaapp/Services/Admin/Finance/Payroll/PayrollPeriodService.php— samaapp/Services/Admin/Finance/Cash/CashTransactionService.php— samaapp/Services/Admin/Master/RawMaterial/RawMaterialService.php— samaapp/Services/Admin/Master/Product/ProductService.php— samaapp/Services/Admin/HR/LeaveRequestService.php— samaapp/Services/Admin/Manage/RestockService.php— samaapp/Services/Admin/Manage/PurchaseService.php— samaapp/Services/Admin/Manage/CuttingService.php— samaapp/Services/Admin/Manage/TransactionService.php— sama- 13 Controller files — tambah
'highlight' => $request->input('highlight')ke Inertia::render - 14 Service files — update notification URL dengan
['highlight' => $entity->id]
Frontend
resources/js/components/notifications/notification-bell.tsx— mark as read saat klik- 13 Index pages — tambah
highlight?: numberprop + info message
Pola yang Ditemukan
Backend Flow
PaginatedRequestvalidasihighlightquery parametervalidatedWithDefaults()returnhighlightke controller- Controller spread ke service:
$this->service->paginated(...$request->validatedWithDefaults()) - Service filter:
->when($highlight, fn ($q) => $q->where('id', $highlight)) - Controller pass
highlightke view:'highlight' => $request->input('highlight')
Frontend Flow
- Notification URL sudah include
?highlight={id}(contoh:/admin/manage/transactions?highlight=123) - Klik notifikasi →
router.visit(notification.url)+markAsRead(id) - Halaman index terima
highlightprop - Tampilkan info message: "Menampilkan data dari notifikasi. [Tampilkan semua]"
- Klik "Tampilkan semua" → navigasi ke index tanpa highlight parameter
Notification URL Pattern
// Sebelum:
url: route('admin.manage.transactions.index')
// Sesudah:
url: route('admin.manage.transactions.index', ['highlight' => $order->id])
Perubahan yang Dilakukan
1. PaginatedRequest (app/Http/Requests/PaginatedRequest.php)
- Tambah
'highlight' => $validated['highlight'] ?? nullkevalidatedWithDefaults()
2. Services (14 files)
- Tambah
?int $highlight = nullparameter kepaginated()method - Tambah
->when($highlight, fn ($q) => $q->where('id', $highlight))di query
3. Controllers (13 files)
- Tambah
'highlight' => $request->input('highlight')ke Inertia::render data
4. Notification URLs (48 call sites di 14 service files)
- Update semua
route('...')menjadiroute('...', ['highlight' => $entity->id])
5. Notification Bell (notification-bell.tsx)
- Tambah
markAsRead()saat klik notifikasi (sebelum navigasi)
6. Index Pages (13 files)
- Tambah
highlight?: numberke Props type - Tambah
highlightke destructured props - Tambah info message di PageHeader dengan tombol "Tampilkan semua"
Catatan
- Attendance page menggunakan pattern berbeda (year/month params), jadi "Tampilkan semua" preserve year/month
- Jobs (CheckAttendancePenaltiesJob, SendAttendanceReminderJob) tidak di-update karena tidak ada specific entity ID
- Pre-existing TypeScript errors tidak terkait dengan fitur ini