dealroom/internal/handler/audit.go

29 lines
636 B
Go

package handler
import (
"net/http"
"dealroom/templates"
)
func (h *Handler) handleAuditLog(w http.ResponseWriter, r *http.Request) {
profile := getProfile(r.Context())
dealID := r.URL.Query().Get("deal_id")
deals := h.getDeals(profile)
activities := h.getActivitiesFiltered(profile.OrganizationID, dealID, 50)
// Populate deal names
dealNames := make(map[string]string)
for _, d := range deals {
dealNames[d.ID] = d.Name
}
for _, act := range activities {
if name, ok := dealNames[act.DealID]; ok {
act.DealName = name
}
}
templates.AuditLogPage(profile, activities, deals, dealID).Render(r.Context(), w)
}