package components import ( "context" "fmt" "strconv" ) // Note: To implement pagination, update the NotificationsData struct in notifications.templ // to include these fields: // CurrentPage int // TotalPages int // TotalCount int // PerPage int templ NotificationsPage(ctx context.Context, data NotificationsData) { @LayoutWithContext("Notifications", ctx) {

Notifications

Total: { fmt.Sprint(data.TotalCount) } notifications
Mark all as read
if len(data.Notifications) == 0 {

No notifications

You don't have any notifications yet.

} else {
if data.TotalPages > 1 {
if data.CurrentPage > 1 { Previous } else { Previous } if data.CurrentPage < data.TotalPages { Next } else { Next }
}
}

Notifications keep you updated on important system events and alerts.

Unread notifications are highlighted in blue. Mark them as read to clear the highlight.

Adjust how many notifications to display per page using the dropdown menu.

} } // Helper function for pagination math func minInt(a, b int) int { if a < b { return a } return b } // Helper function for pagination math func maxInt(a, b int) int { if a > b { return a } return b } // Add the pageNumbers template for consistent pagination layout templ notificationPageNumbers(currentPage int, totalPages int, perPage int) { // Show at most 5 page numbers with the current page in the middle when possible for i := 1; i <= totalPages; i++ { if i == currentPage { { fmt.Sprint(i) } } else if i == 1 || i == totalPages || (i >= currentPage-2 && i <= currentPage+2) { { fmt.Sprint(i) } } else if i == currentPage-3 || i == currentPage+3 { ... } } }