feat: add feedback acknowledgement
This commit is contained in:
@@ -55,6 +55,19 @@ func (h *StatsHandler) Render(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
// AcknowledgeFeedback handles the per-row "Acknowledge" form POST. Marks
|
||||
// the row acknowledged (one-way) and emails the author that we've seen
|
||||
// it and started work, then 303-redirects back to /stats. Already-
|
||||
// acknowledged or unknown ids redirect silently.
|
||||
func (h *StatsHandler) AcknowledgeFeedback(w http.ResponseWriter, r *http.Request) {
|
||||
id := chi.URLParam(r, "id")
|
||||
if err := h.svc.Acknowledge(r.Context(), id); err != nil && !errors.Is(err, service.ErrAlreadyAcknowledged) {
|
||||
http.Error(w, "acknowledge failed: "+err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
http.Redirect(w, r, "/stats", http.StatusSeeOther)
|
||||
}
|
||||
|
||||
// ResolveFeedback handles the per-row "Mark resolved" form POST. It marks
|
||||
// the row resolved (one-way) and fires the author thank-you email, then
|
||||
// 303-redirects back to /stats so a refresh doesn't re-submit. Already-
|
||||
@@ -99,10 +112,13 @@ h2 { font-size: 1.05rem; margin-top: 2rem; margin-bottom: 0.5rem; border-bottom:
|
||||
.fb .cat-pill { font-weight: 700; text-transform: capitalize; color: #1a1a1a }
|
||||
.fb .msg { white-space: pre-wrap; font-size: 0.95rem }
|
||||
.fb .author { font-size: 0.78rem; color: #888; margin-top: 0.5rem }
|
||||
.fb .foot { display: flex; justify-content: flex-end; margin-top: 0.6rem }
|
||||
.fb .foot { display: flex; justify-content: flex-end; align-items: center; gap: 0.6rem; margin-top: 0.6rem }
|
||||
.resolved-badge { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.78rem; font-weight: 600; color: #1e7a4a }
|
||||
.acked-badge { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.78rem; font-weight: 600; color: #9a6b2f }
|
||||
.resolve-btn { font: inherit; font-size: 0.8rem; font-weight: 600; color: #fff; background: #1e7a4a; border: 0; border-radius: 6px; padding: 0.4rem 0.85rem; cursor: pointer }
|
||||
.resolve-btn:hover { background: #196b40 }
|
||||
.ack-btn { font: inherit; font-size: 0.8rem; font-weight: 600; color: #9a6b2f; background: #fff; border: 1px solid #d6b27a; border-radius: 6px; padding: 0.4rem 0.85rem; cursor: pointer }
|
||||
.ack-btn:hover { background: #faf5ea }
|
||||
code { background: #f4f4f4; padding: 0.05em 0.3em; border-radius: 3px; font-size: 0.85em }
|
||||
.empty { color: #888; font-style: italic }
|
||||
</style>
|
||||
@@ -150,8 +166,16 @@ code { background: #f4f4f4; padding: 0.05em 0.3em; border-radius: 3px; font-size
|
||||
</div>
|
||||
<div class="foot">
|
||||
{{if .ResolvedAt}}
|
||||
{{if .AcknowledgedAt}}<span class="acked-badge">✓ Acknowledged {{fmtTime .AcknowledgedAt}}</span>{{end}}
|
||||
<span class="resolved-badge">✓ Resolved {{fmtTime .ResolvedAt}}</span>
|
||||
{{else}}
|
||||
{{if .AcknowledgedAt}}
|
||||
<span class="acked-badge">✓ Acknowledged {{fmtTime .AcknowledgedAt}}</span>
|
||||
{{else}}
|
||||
<form method="post" action="/stats/feedback/{{.ID}}/acknowledge" onsubmit="return confirm('Acknowledge this feedback? The author will be emailed that we have seen it and started work. This cannot be undone.');">
|
||||
<button type="submit" class="ack-btn">Acknowledge</button>
|
||||
</form>
|
||||
{{end}}
|
||||
<form method="post" action="/stats/feedback/{{.ID}}/resolve" onsubmit="return confirm('Mark this feedback as resolved? This cannot be undone, and the author will be emailed.');">
|
||||
<button type="submit" class="resolve-btn">Mark resolved</button>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user