feat: Enhance notifications and pagination functionality

- Implemented pagination for user notifications, allowing users to navigate through their notifications more efficiently.
- Updated the notifications page to display the total count of notifications and provide controls for adjusting the number of notifications shown per page.
- Added backend support for fetching paginated notifications and counting total notifications for users.
- Improved the user interface for notifications, including a new layout and additional help sections to guide users on managing their notifications.
This commit is contained in:
StarFleetCPTN committed 2025-03-23 09:54:06 -07:00
1 parent db6259f8a3
commit 3140d9e143
11 files changed
+1187 -895

No files matched your search

+14
View File
@@ -38,6 +38,20 @@ func (db *DB) GetUserNotifications(userID uint, limit int) ([]UserNotification,
return notifications, result.Error
}
// GetUserNotificationCount returns the total count of notifications for a user
func (db *DB) GetUserNotificationCount(userID uint) (int64, error) {
var count int64
result := db.Model(&UserNotification{}).Where("user_id = ?", userID).Count(&count)
return count, result.Error
}
// GetPaginatedUserNotifications returns paginated notifications for a user
func (db *DB) GetPaginatedUserNotifications(userID uint, offset, limit int) ([]UserNotification, error) {
var notifications []UserNotification
result := db.Where("user_id = ?", userID).Order("created_at DESC").Offset(offset).Limit(limit).Find(&notifications)
return notifications, result.Error
}
// GetUnreadNotificationCount returns the count of unread notifications for a user
func (db *DB) GetUnreadNotificationCount(userID uint) (int64, error) {
var count int64