dstpabuaran.com/docs/notification-highlight.md
Yoga Pangestu 22c9a4cf2a feat: add notification highlight feature to various services and frontend components
- 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.
2026-08-15 00:11:40 +07:00

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 — tambah highlight ke validatedWithDefaults()
  • app/Services/Admin/Master/CategoryService.php — tambah $highlight parameter + ->where('id', $highlight)
  • app/Services/Admin/Finance/ExpenseService.php — sama
  • app/Services/Admin/Finance/EmployeeAdvanceService.php — sama
  • app/Services/Admin/Finance/Payroll/PayrollPeriodService.php — sama
  • app/Services/Admin/Finance/Cash/CashTransactionService.php — sama
  • app/Services/Admin/Master/RawMaterial/RawMaterialService.php — sama
  • app/Services/Admin/Master/Product/ProductService.php — sama
  • app/Services/Admin/HR/LeaveRequestService.php — sama
  • app/Services/Admin/Manage/RestockService.php — sama
  • app/Services/Admin/Manage/PurchaseService.php — sama
  • app/Services/Admin/Manage/CuttingService.php — sama
  • app/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?: number prop + info message

Pola yang Ditemukan

Backend Flow

  1. PaginatedRequest validasi highlight query parameter
  2. validatedWithDefaults() return highlight ke controller
  3. Controller spread ke service: $this->service->paginated(...$request->validatedWithDefaults())
  4. Service filter: ->when($highlight, fn ($q) => $q->where('id', $highlight))
  5. Controller pass highlight ke view: 'highlight' => $request->input('highlight')

Frontend Flow

  1. Notification URL sudah include ?highlight={id} (contoh: /admin/manage/transactions?highlight=123)
  2. Klik notifikasi → router.visit(notification.url) + markAsRead(id)
  3. Halaman index terima highlight prop
  4. Tampilkan info message: "Menampilkan data dari notifikasi. [Tampilkan semua]"
  5. 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'] ?? null ke validatedWithDefaults()

2. Services (14 files)

  • Tambah ?int $highlight = null parameter ke paginated() 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('...') menjadi route('...', ['highlight' => $entity->id])

5. Notification Bell (notification-bell.tsx)

  • Tambah markAsRead() saat klik notifikasi (sebelum navigasi)

6. Index Pages (13 files)

  • Tambah highlight?: number ke Props type
  • Tambah highlight ke 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