- Added dedicated route and view for reading individual notifications (/account/notifications/read) - Ensured notification is only marked as read if it hasn't already been - Updated Notification model to use Subject and Body fields - Fixed field references in templates (Title → Subject, Message → Body) - Updated topbar dropdown to use correct field names and display logic - Gracefully handle "notification not found" cases in template output - Ensured consistent template parsing with layout and topbar inclusion - Improved error logging for better diagnosis
24 lines
756 B
HTML
24 lines
756 B
HTML
{{ define "notifications" }}
|
|
<div class="container py-4">
|
|
<h2 class="mb-4">Notifications</h2>
|
|
|
|
{{ if .Notifications }}
|
|
<ul class="list-group">
|
|
{{ range .Notifications }}
|
|
<li class="list-group-item d-flex justify-content-between align-items-start {{ if not .IsRead }}fw-bold{{ end }}">
|
|
<div class="ms-2 me-auto">
|
|
<div class="fw-semibold">{{ .Title }}</div>
|
|
<small class="text-muted">{{ .Message }}</small>
|
|
</div>
|
|
{{ if not .IsRead }}
|
|
<a href="/account/notifications/read?id={{ .ID }}" class="badge bg-primary text-decoration-none">Mark as read</a>
|
|
{{ end }}
|
|
</li>
|
|
{{ end }}
|
|
</ul>
|
|
{{ else }}
|
|
<div class="alert alert-info">You have no notifications.</div>
|
|
{{ end }}
|
|
</div>
|
|
{{ end }}
|