package handlers import ( "fmt" "net/http" "strconv" "strings" "time" "go-crm/internal/db" "go-crm/internal/templates" "github.com/go-chi/chi/v5" ) func (a *App) LeadReviewQueue(w http.ResponseWriter, r *http.Request) { accountID, ok := a.requireAuth(w, r) if !ok { return } clientID := a.clientIDForAccount(accountID) if clientID == 0 { http.Error(w, "No client found for account", http.StatusBadRequest) return } limit, _ := strconv.Atoi(r.URL.Query().Get("limit")) offset, _ := strconv.Atoi(r.URL.Query().Get("offset")) if limit == 0 { limit = 50 } leads, err := db.ListLeadsForReview(a.DB, clientID, limit, offset) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } statuses, _ := db.ListLeadStatuses(a.DB, clientID) services := a.serviceNames(clientID) pendingCount := len(leads) buf := templates.BufRender() badge := "" if pendingCount > 0 { badge = fmt.Sprintf(`%d`, pendingCount) } fmt.Fprint(buf, templates.PageHeader("Review Queue", "Confirm or correct leads with unidentified service interest")) fmt.Fprintf(buf, `