Phase 2 part 2: prospects, the review screen and the suppression list

Schema 6 adds prospect_companies, prospect_contacts (merged by domain and
email, each with its source, detail and date) and suppressions. Prospects
-> Review lists New, Accepted and Set aside: accepting a company queues an
EspoCRM Account, a person a Lead at their company, with provenance and
why they fit in the description; the page warns about records already in
the CRM as of the last sync, and shows each accepted prospect's CRM
progress. Prospects can be added by hand. The suppression list (emails
and domains) is checked on add and again before queueing, and suppressing
sets matching new prospects aside. Search finds prospects too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-21 16:51:05 -07:00
co-authored by Claude Opus 5.5
parent 1dc5476d43
commit 7633697567
14 changed files with 1667 additions and 5 deletions
+282
View File
@@ -0,0 +1,282 @@
package web
import (
"errors"
"net/http"
"strconv"
"strings"
"time"
"supermarket/internal/crm"
"supermarket/internal/prospects"
)
// newProspects is how many companies and people wait for review.
func (s *Server) newProspects() int {
counts, err := prospects.Counts(s.DB)
if err != nil {
s.Log.Error("counting prospects", "err", err)
}
return counts[prospects.StatusNew]
}
// reviewTab is the status a request asks for, new by default.
func reviewTab(v string) string {
for _, st := range prospects.Statuses {
if v == st {
return v
}
}
return prospects.StatusNew
}
func (s *Server) prospectsPage(w http.ResponseWriter, r *http.Request) {
s.renderProspects(w, r, reviewTab(r.URL.Query().Get("status")), "")
}
func (s *Server) renderProspects(w http.ResponseWriter, r *http.Request, tab, errMsg string) {
companies, loose, err := prospects.Review(s.DB, tab, 200)
if err != nil {
s.serverError(w, err)
return
}
counts, err := prospects.Counts(s.DB)
if err != nil {
s.serverError(w, err)
return
}
// Records already in the CRM that look like each prospect, from the
// last sync. Only worth showing before a decision.
matches := map[string][]crm.Record{}
if tab == prospects.StatusNew {
for i := range companies {
c := &companies[i]
if m, err := c.CRMMatches(s.DB); err == nil && len(m) > 0 {
matches["company:"+strconv.FormatInt(c.ID, 10)] = m
}
for j := range c.Contacts {
p := &c.Contacts[j]
if m, err := p.CRMMatches(s.DB); err == nil && len(m) > 0 {
matches["contact:"+strconv.FormatInt(p.ID, 10)] = m
}
}
}
for i := range loose {
if m, err := loose[i].CRMMatches(s.DB); err == nil && len(m) > 0 {
matches["contact:"+strconv.FormatInt(loose[i].ID, 10)] = m
}
}
}
sync, err := crm.LoadSync(s.DB)
if err != nil {
s.serverError(w, err)
return
}
s.render(w, r, "prospects", page{Title: "Review prospects", Nav: "prospects/review", Error: errMsg, Data: map[string]any{
"Tab": tab,
"Statuses": prospects.Statuses,
"Counts": counts,
"Companies": companies,
"Loose": loose,
"Matches": matches,
"Synced": sync.Last,
}})
}
// prospectAction handles the review screen's buttons.
func (s *Server) prospectAction(w http.ResponseWriter, r *http.Request) {
kind, action := r.PathValue("kind"), r.PathValue("action")
id, err := strconv.ParseInt(r.PathValue("id"), 10, 64)
if err != nil || (kind != "company" && kind != "contact") {
http.NotFound(w, r)
return
}
if err := r.ParseForm(); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
tab := reviewTab(r.PostFormValue("tab"))
now := time.Now()
var msg string
switch kind + "/" + action {
case "company/accept":
err, msg = ignore(prospects.AcceptCompany(s.DB, id, now)), "accepted"
case "company/accept-all":
err, msg = prospects.AcceptAll(s.DB, id, now), "accepted"
case "contact/accept":
err, msg = ignore(prospects.AcceptContact(s.DB, id, now)), "accepted"
case "company/reject":
err, msg = prospects.RejectCompany(s.DB, id, now), "rejected"
case "contact/reject":
err, msg = prospects.RejectContact(s.DB, id, now), "rejected"
case "company/reconsider", "contact/reconsider":
err, msg = prospects.Reconsider(s.DB, kind, id), "reconsidered"
case "company/suppress":
c, gerr := prospects.GetCompany(s.DB, id)
if err = gerr; err == nil {
if c.Domain == "" {
err = errors.New(c.Name + " has no website, so there's no domain to suppress")
} else {
err = prospects.Suppress(s.DB, "domain", c.Domain, r.PostFormValue("reason"), now)
}
}
msg = "suppressed"
case "contact/suppress":
p, gerr := prospects.GetContact(s.DB, id)
if err = gerr; err == nil {
if p.Email == "" {
err = errors.New(p.Name() + " has no email address to suppress")
} else {
err = prospects.Suppress(s.DB, "email", p.Email, r.PostFormValue("reason"), now)
}
}
msg = "suppressed"
default:
http.NotFound(w, r)
return
}
if errors.Is(err, prospects.ErrNotFound) {
http.NotFound(w, r)
return
}
if err != nil {
s.renderProspects(w, r, tab, "Couldn't do that: "+err.Error())
return
}
redirect(w, r, "/prospects?status="+tab, msg)
}
// ignore drops a result and keeps the error.
func ignore[T any](_ T, err error) error { return err }
// --- Adding by hand ---
type prospectFormData struct {
Company prospects.Company
Contact prospects.Contact
CompanyID int64 // adding a person at a company already in review
Companies []prospects.Company
For string // that company's name
}
func (s *Server) prospectForm(w http.ResponseWriter, r *http.Request) {
d := prospectFormData{}
if id, err := strconv.ParseInt(r.URL.Query().Get("company"), 10, 64); err == nil {
c, err := prospects.GetCompany(s.DB, id)
if err != nil {
http.NotFound(w, r)
return
}
d.CompanyID, d.For = c.ID, c.Name
}
s.render(w, r, "prospect-new", page{Title: "Add a prospect", Nav: "prospects/review", Data: d})
}
func (s *Server) prospectAdd(w http.ResponseWriter, r *http.Request) {
if err := r.ParseForm(); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
f := r.PostFormValue
now := time.Now()
d := prospectFormData{
Company: prospects.Company{
Name: f("company_name"), Website: f("website"), LinkedIn: f("company_linkedin"),
Industry: f("industry"), Size: f("size"), Location: f("location"), Why: f("why"),
Source: prospects.SourceManual, SourceDetail: f("source_detail"),
},
Contact: prospects.Contact{
FirstName: f("first_name"), LastName: f("last_name"), Title: f("title"), Email: f("email"),
LinkedIn: f("linkedin"), Phone: f("phone"),
Source: prospects.SourceManual, SourceDetail: f("source_detail"),
},
}
d.CompanyID, _ = strconv.ParseInt(f("company_id"), 10, 64)
if d.CompanyID != 0 {
c, err := prospects.GetCompany(s.DB, d.CompanyID)
if err != nil {
http.NotFound(w, r)
return
}
d.For = c.Name
}
fail := func(msg string) {
s.render(w, r, "prospect-new", page{Title: "Add a prospect", Nav: "prospects/review", Error: msg, Data: d})
}
hasCompany := strings.TrimSpace(d.Company.Name) != "" || strings.TrimSpace(d.Company.Website) != ""
hasPerson := strings.TrimSpace(d.Contact.FirstName+d.Contact.LastName+d.Contact.Email) != ""
if !hasCompany && !hasPerson && d.CompanyID == 0 {
fail("Give a company, a person, or both.")
return
}
if d.CompanyID == 0 && hasCompany {
if strings.TrimSpace(d.Company.Name) == "" {
fail("Give the company's name.")
return
}
id, _, err := prospects.AddCompany(s.DB, d.Company, now)
if err != nil {
fail(addError(err))
return
}
d.CompanyID = id
}
if hasPerson {
d.Contact.CompanyID = d.CompanyID
if _, _, err := prospects.AddContact(s.DB, d.Contact, now); err != nil {
fail(addError(err))
return
}
} else if d.CompanyID != 0 && !hasCompany {
fail("Give the person's name or email.")
return
}
redirect(w, r, "/prospects", "prospect-added")
}
func addError(err error) string {
if errors.Is(err, prospects.ErrSuppressed) {
return "That's on your suppression list (" + strings.TrimSuffix(err.Error(), ": "+prospects.ErrSuppressed.Error()) +
"), so it can't be added. Take it off the list first if that's a mistake."
}
return err.Error()
}
// --- Suppression list ---
func (s *Server) suppressedPage(w http.ResponseWriter, r *http.Request) {
s.renderSuppressed(w, r, "", "")
}
func (s *Server) renderSuppressed(w http.ResponseWriter, r *http.Request, value, errMsg string) {
list, err := prospects.Suppressions(s.DB)
if err != nil {
s.serverError(w, err)
return
}
s.render(w, r, "suppressed", page{Title: "Suppression list", Nav: "prospects/suppressed", Error: errMsg, Data: map[string]any{
"List": list,
"Value": value,
}})
}
func (s *Server) suppressedAction(w http.ResponseWriter, r *http.Request) {
if err := r.ParseForm(); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
value := r.PostFormValue("value")
if r.PostFormValue("remove") != "" {
if err := prospects.Unsuppress(s.DB, r.PostFormValue("kind"), value); err != nil {
s.renderSuppressed(w, r, "", err.Error())
return
}
redirect(w, r, "/prospects/suppressed", "unsuppressed")
return
}
if err := prospects.Suppress(s.DB, "", value, r.PostFormValue("reason"), time.Now()); err != nil {
s.renderSuppressed(w, r, value, err.Error())
return
}
redirect(w, r, "/prospects/suppressed", "suppressed")
}
+33 -1
View File
@@ -8,8 +8,17 @@ import (
"supermarket/internal/content"
"supermarket/internal/inventory"
"supermarket/internal/profile"
"supermarket/internal/prospects"
)
// prospectBadge is a prospect's status as search shows it.
func prospectBadge(status string) string {
if status == prospects.StatusRejected {
return "set aside"
}
return status
}
// hit is one search result.
type hit struct {
Title, Detail, Link string
@@ -143,6 +152,29 @@ func (s *Server) search(q string) ([]hitGroup, error) {
posts = append(posts, hit{Title: text, Detail: detail, Link: link, Badge: d.Status})
}
companies, people, err := prospects.Search(s.DB, words, searchLimit)
if err != nil {
return nil, err
}
var prospectHits []hit
for _, c := range companies {
detail := "Company"
if c.Domain != "" {
detail += " · " + c.Domain
}
prospectHits = append(prospectHits, hit{Title: c.Name, Detail: detail, Link: "/prospects?status=" + c.Status, Badge: prospectBadge(c.Status)})
}
for _, p := range people {
detail := "Person"
if p.Title != "" {
detail += " · " + p.Title
}
if p.Email != "" {
detail += " · " + p.Email
}
prospectHits = append(prospectHits, hit{Title: p.Name(), Detail: detail, Link: "/prospects?status=" + p.Status, Badge: prospectBadge(p.Status)})
}
var settings []hit
if p, err := profile.Load(s.DB); err == nil && p.IsSet() {
for _, pr := range p.Products {
@@ -158,7 +190,7 @@ func (s *Server) search(q string) ([]hitGroup, error) {
}
var groups []hitGroup
for _, g := range []hitGroup{{"Posts", posts}, {"Fetched items", found}, {"Inventory", inv}, {"Settings", settings}} {
for _, g := range []hitGroup{{"Posts", posts}, {"Fetched items", found}, {"Inventory", inv}, {"Prospects", prospectHits}, {"Settings", settings}} {
if len(g.Hits) > 0 {
groups = append(groups, g)
}
+21 -2
View File
@@ -127,6 +127,12 @@ func (s *Server) Handler() (http.Handler, error) {
mux.HandleFunc("POST /drafts/{id}/{action}", s.draftAction)
mux.HandleFunc("POST /reddit/rules/{name}", s.refreshRules)
mux.HandleFunc("GET /prospects", s.prospectsPage)
mux.HandleFunc("GET /prospects/new", s.prospectForm)
mux.HandleFunc("POST /prospects/new", s.prospectAdd)
mux.HandleFunc("GET /prospects/suppressed", s.suppressedPage)
mux.HandleFunc("POST /prospects/suppressed", s.suppressedAction)
mux.HandleFunc("POST /prospects/{kind}/{id}/{action}", s.prospectAction)
mux.HandleFunc("GET /crm", s.crmPage)
mux.HandleFunc("GET /crm/reach", s.crmReach)
mux.HandleFunc("POST /crm/{action}", s.crmAction)
@@ -263,6 +269,8 @@ type page struct {
Data any
Inbox int // drafts waiting for review, shown in the menu
Query string // the search box's text
NewProspects int // companies and people waiting for review, shown in the menu
}
// Section is the top bar's first breadcrumb, from Nav.
@@ -290,7 +298,7 @@ type module struct {
var modules = []module{
{"content", "Content", "Phase 1", "Draft posts from partner and competitor news and your own products; review and publish to X, LinkedIn and Reddit.", "/content"},
{"prospects", "Prospects", "Phase 2", "Find companies and people who fit your targets, and add the ones you approve to EspoCRM through Hermes.", "/crm"},
{"prospects", "Prospects", "Phase 2", "Find companies and people who fit your targets, and add the ones you approve to EspoCRM through Hermes.", "/prospects"},
{"seo", "SEO", "Phase 3", "Audit your websites and open fixes as pull requests on your Hugo repositories.", ""},
{"metrics", "Metrics", "Phase 4", "Pipeline influence, CAC, CLV and NRR from Stripe, EspoCRM and Plausible.", ""},
{"sites", "Sites", "Phase 5", "Build pages and sites from a component library and publish them through Gitea.", ""},
@@ -309,6 +317,7 @@ func (s *Server) render(w http.ResponseWriter, r *http.Request, name string, p p
}
p.Version = s.Version
p.Inbox = s.inboxCount()
p.NewProspects = s.newProspects()
if p.Flash == "" {
p.Flash = flashes[r.URL.Query().Get("msg")]
}
@@ -340,6 +349,12 @@ var flashes = map[string]string{
"reddit-connected": "Reddit is connected.",
"crm-test": "Test Lead queued. Hermes creates it on its next run; or run it now (below).",
"crm-sync": "Sync requested: Hermes copies CRM records on its next run.",
"accepted": "Accepted: queued for the CRM. Hermes adds it on its next run.",
"rejected": "Set aside.",
"reconsidered": "Back in New.",
"suppressed": "Added to the suppression list.",
"unsuppressed": "Taken off the suppression list.",
"prospect-added": "Added. Review it below.",
"rules-refreshed": "Rules refreshed.",
"imported": "Imported.",
"oauth-expired": "That sign-in took too long or was already used. Try again.",
@@ -355,7 +370,11 @@ var flashes = map[string]string{
func redirect(w http.ResponseWriter, r *http.Request, path, msg string) {
if msg != "" {
path += "?msg=" + url.QueryEscape(msg)
sep := "?"
if strings.Contains(path, "?") {
sep = "&"
}
path += sep + "msg=" + url.QueryEscape(msg)
}
http.Redirect(w, r, path, http.StatusSeeOther)
}
+62 -1
View File
@@ -25,6 +25,7 @@ import (
"supermarket/internal/mcpserver"
"supermarket/internal/models"
"supermarket/internal/profile"
"supermarket/internal/prospects"
"supermarket/internal/secrets"
)
@@ -97,7 +98,8 @@ func TestEveryPageRenders(t *testing.T) {
"/inventory/new", "/inventory/1", "/inventory/import", "/inventory/export",
"/settings/ai", "/settings/accounts", "/settings/core", "/static/app.css", "/favicon.ico", "/static/favicon.png", "/static/logo.png", "/static/apple-touch-icon.png", "/search", "/crm", "/search?q=rival", "/search?q=nothing+here", "/static/htmx.min.js", "/healthz",
"/content", "/content/1", "/content/1?dismissed=1", "/posts", "/posts?msg=drafted",
"/content/scheduled", "/content/published"} {
"/content/scheduled", "/content/published",
"/prospects", "/prospects?status=accepted", "/prospects?status=rejected", "/prospects/new", "/prospects/suppressed"} {
rec := do(h, http.MethodGet, path, nil, nil)
if rec.Code != http.StatusOK {
t.Errorf("core=%v GET %s: %d %s", c != nil, path, rec.Code, rec.Body.String())
@@ -538,3 +540,62 @@ func TestCRMReachHint(t *testing.T) {
t.Errorf("unreachable: %s", body)
}
}
// Prospects: add by hand, see the CRM warning, accept into the CRM queue,
// and the suppression list stops what's on it.
func TestProspectsReview(t *testing.T) {
s, h := newTestServer(t, nil)
rec, _ := crm.RecordFrom("Account", map[string]any{"id": "a1", "name": "Acme", "website": "https://acme.com"}, time.Now())
crm.Ingest(s.DB, []crm.Record{rec})
if rec := postForm(h, "/prospects/new", url.Values{}); !strings.Contains(rec.Body.String(), "Give a company, a person, or both") {
t.Error("an empty form was accepted")
}
form := url.Values{"company_name": {"Acme"}, "website": {"acme.com"}, "why": {"Runs its own servers"},
"first_name": {"Pat"}, "last_name": {"Lee"}, "title": {"CTO"}, "email": {"pat@acme.com"}, "source_detail": {"Met at FOSDEM"}}
if rec := postForm(h, "/prospects/new", form); rec.Code != http.StatusSeeOther {
t.Fatalf("add: %d %s", rec.Code, rec.Body.String())
}
body := do(h, http.MethodGet, "/prospects", nil, nil).Body.String()
for _, want := range []string{"Acme", "Pat Lee", "Runs its own servers", "Met at FOSDEM", "Already in your CRM", "Accept with 1 person",
`<span class="count-badge" title="2 waiting for review">2</span>`} {
if !strings.Contains(body, want) {
t.Errorf("review page lacks %q in %s", want, body)
}
}
if rec := postForm(h, "/prospects/company/1/accept-all", url.Values{"tab": {"new"}}); rec.Code != http.StatusSeeOther {
t.Fatalf("accept all: %d %s", rec.Code, rec.Body.String())
}
as, _ := crm.List(s.DB, 10)
if len(as) != 2 {
t.Fatalf("queued: %+v", as)
}
if body := do(h, http.MethodGet, "/prospects?status=accepted", nil, nil).Body.String(); !strings.Contains(body, "waiting for Hermes") {
t.Error("accepted tab doesn't show the CRM state")
}
// Suppression.
postForm(h, "/prospects/new", url.Values{"first_name": {"Ray"}, "last_name": {"Doe"}, "email": {"ray@other.org"}})
if rec := postForm(h, "/prospects/suppressed", url.Values{"value": {"other.org"}, "reason": {"partner"}}); rec.Code != http.StatusSeeOther {
t.Fatalf("suppress: %d %s", rec.Code, rec.Body.String())
}
if body := do(h, http.MethodGet, "/prospects?status=rejected", nil, nil).Body.String(); !strings.Contains(body, "Ray Doe") {
t.Error("a suppressed prospect should be set aside")
}
if rec := postForm(h, "/prospects/new", url.Values{"last_name": {"Kim"}, "email": {"kim@other.org"}}); !strings.Contains(rec.Body.String(), "suppression list (kim@other.org)") {
t.Errorf("adding a suppressed person: %s", rec.Body.String())
}
if body := do(h, http.MethodGet, "/prospects/suppressed", nil, nil).Body.String(); !strings.Contains(body, "other.org") || !strings.Contains(body, "partner") {
t.Error("suppression list page")
}
postForm(h, "/prospects/suppressed", url.Values{"kind": {"domain"}, "value": {"other.org"}, "remove": {"1"}})
if list, _ := prospects.Suppressions(s.DB); len(list) != 0 {
t.Errorf("remove: %+v", list)
}
if body := do(h, http.MethodGet, "/search?q=pat+cto", nil, nil).Body.String(); !strings.Contains(body, "Pat Lee") || !strings.Contains(body, "/prospects?status=accepted") {
t.Error("search doesn't find the prospect")
}
if rec := postForm(h, "/prospects/contact/99/accept", url.Values{}); rec.Code != http.StatusNotFound {
t.Errorf("missing prospect: %d", rec.Code)
}
}
+9
View File
@@ -371,3 +371,12 @@ form.inline { display: inline-block; margin: 0 0 0.75rem; }
.by-hand p { margin: 0 0 0.5rem; }
.by-hand-done { margin: 0.5rem 0 0.75rem; }
.by-hand-done .row input { margin: 0; }
/* Prospects review */
.prospect h2 { margin: 0 0 0.2rem; }
.prospect-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.prospect-head .row-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; justify-content: flex-end; white-space: normal; }
.prospect-head .row-actions form { margin: 0; }
.prospect .why { margin: 0.6rem 0 0.3rem; }
.prospect .people { margin: 0.9rem 0 0.5rem; }
.prospect .warnings { margin: 0.5rem 0; }
+2
View File
@@ -40,6 +40,8 @@
{{end}}
{{if eq .ID "prospects"}}
<div class="subnav">
<a href="/prospects" {{if eq $nav "prospects/review"}}aria-current="page"{{end}}>Review{{with $.NewProspects}} <span class="count-badge" title="{{.}} waiting for review">{{.}}</span>{{end}}</a>
<a href="/prospects/suppressed" {{if eq $nav "prospects/suppressed"}}aria-current="page"{{end}}>Suppression list</a>
<a href="/crm" {{if eq $nav "prospects/crm"}}aria-current="page"{{end}}>CRM queue</a>
</div>
{{end}}
+35
View File
@@ -0,0 +1,35 @@
{{define "content"}}{{with .Data}}
<h1>{{if .For}}Add a person at {{.For}}{{else}}Add a prospect{{end}}</h1>
<p class="lede">{{if .For}}They go into review with {{.For}}.{{else}}A company, a person at it, or both. They go into review first; nothing reaches your CRM until you accept it.{{end}}</p>
<form method="post" action="/prospects/new" class="card">
{{if .For}}<input type="hidden" name="company_id" value="{{.CompanyID}}">
{{else}}
<h2>Company</h2>
<div class="cols">
<label>Name <input name="company_name" value="{{.Company.Name}}" autocomplete="off"></label>
<label>Website <input name="website" value="{{.Company.Website}}" placeholder="example.com" autocomplete="off"></label>
<label>Industry <input name="industry" value="{{.Company.Industry}}"></label>
<label>Size <input name="size" value="{{.Company.Size}}" placeholder="e.g. 50–200 people"></label>
<label>Location <input name="location" value="{{.Company.Location}}"></label>
<label>LinkedIn page <input name="company_linkedin" value="{{.Company.LinkedIn}}" placeholder="https://www.linkedin.com/company/…"></label>
</div>
<label>Why they fit <textarea name="why" rows="2" placeholder="What makes them a good prospect">{{.Company.Why}}</textarea></label>
<h2>Person <span class="muted small">(optional)</span></h2>
{{end}}
<div class="cols">
<label>First name <input name="first_name" value="{{.Contact.FirstName}}" autocomplete="off"></label>
<label>Last name <input name="last_name" value="{{.Contact.LastName}}" autocomplete="off"></label>
<label>Job title <input name="title" value="{{.Contact.Title}}"></label>
<label>Email <input name="email" type="email" value="{{.Contact.Email}}" autocomplete="off"></label>
<label>Phone <input name="phone" value="{{.Contact.Phone}}"></label>
<label>LinkedIn profile <input name="linkedin" value="{{.Contact.LinkedIn}}" placeholder="https://www.linkedin.com/in/…"></label>
</div>
<label>Where you found them <input name="source_detail" value="{{.Contact.SourceDetail}}" placeholder="A link, an event, a referral…">
<span class="help">Kept with the prospect and written into the CRM record, so you can always say where a contact came from.</span></label>
<div class="actions">
<button type="submit">Add for review</button>
<a href="/prospects">Cancel</a>
</div>
</form>
{{end}}{{end}}
+121
View File
@@ -0,0 +1,121 @@
{{define "content"}}{{with .Data}}{{$tab := .Tab}}{{$matches := .Matches}}
<div class="heading">
<h1>Review prospects</h1>
<div class="buttons">
<a class="button" href="/prospects/new">Add a prospect</a>
</div>
</div>
<p class="lede">Companies and people who may fit your targets. Nothing goes to your CRM until you accept it: accepting a company adds an Account, accepting a person adds a Lead, through <a href="/crm">the CRM queue</a>. Each one keeps where and when it was found.</p>
<nav class="tabs">
{{range .Statuses}}<a href="/prospects?status={{.}}" {{if eq $tab .}}aria-current="page"{{end}}>{{if eq . "new"}}New{{else if eq . "accepted"}}Accepted{{else}}Set aside{{end}}{{with index $.Data.Counts .}} <span class="muted">{{.}}</span>{{end}}</a>{{end}}
</nav>
{{if and (eq $tab "new") (or .Companies .Loose)}}
<p class="help">{{if .Synced.IsZero}}Your CRM hasn't been synced yet, so Supermarket can't warn you about records you already have.{{else}}Checked against your CRM as of {{ago .Synced}}.{{end}}</p>
{{end}}
{{range .Companies}}{{$c := .}}
<section class="card prospect">
<div class="prospect-head">
<div>
<h2>{{.Name}}{{if ne .Status $tab}} <span class="badge">{{template "prospect-status" .Status}}</span>{{end}}</h2>
<p class="meta">
{{with .Website}}<a href="{{.}}" target="_blank" rel="noopener noreferrer">{{$c.Domain}}</a>{{end}}
{{with .Industry}} · {{.}}{{end}}{{with .Size}} · {{.}}{{end}}{{with .Location}} · {{.}}{{end}}
{{with .LinkedIn}} · <a href="{{.}}" target="_blank" rel="noopener noreferrer">LinkedIn</a>{{end}}
</p>
</div>
{{if eq .Status $tab}}
<div class="row-actions">
{{if eq $tab "new"}}
{{if .Contacts}}<form method="post" action="/prospects/company/{{.ID}}/accept-all"><input type="hidden" name="tab" value="{{$tab}}"><button type="submit" class="small">Accept with {{len .Contacts}} {{if eq (len .Contacts) 1}}person{{else}}people{{end}}</button></form>{{end}}
<form method="post" action="/prospects/company/{{.ID}}/accept"><input type="hidden" name="tab" value="{{$tab}}"><button type="submit" class="small {{if .Contacts}}secondary{{end}}">Accept {{if .Contacts}}company only{{else}}company{{end}}</button></form>
<form method="post" action="/prospects/company/{{.ID}}/reject"><input type="hidden" name="tab" value="{{$tab}}"><button type="submit" class="secondary small">Set aside</button></form>
{{if .Domain}}<form method="post" action="/prospects/company/{{.ID}}/suppress" data-confirm="Never add anyone at {{.Domain}}? This puts the domain on your suppression list."><input type="hidden" name="tab" value="{{$tab}}"><button type="submit" class="secondary small">Suppress {{.Domain}}</button></form>{{end}}
{{else if eq $tab "accepted"}}
{{template "crm-state" dict "CRM" .CRM "Kind" "company" "ID" .ID "Tab" $tab}}
{{else}}
<form method="post" action="/prospects/company/{{.ID}}/reconsider"><input type="hidden" name="tab" value="{{$tab}}"><button type="submit" class="secondary small">Reconsider</button></form>
{{end}}
</div>
{{end}}
</div>
{{with .Why}}<p class="why">{{.}}</p>{{end}}
<p class="meta">{{template "provenance" .}}</p>
{{with index $matches (printf "company:%d" .ID)}}{{template "crm-matches" .}}{{end}}
{{if .Contacts}}
<ul class="items people">
{{range .Contacts}}{{template "contact" dict "P" . "Tab" $tab "Matches" $matches}}{{end}}
</ul>
{{end}}
{{if eq $tab "new"}}<p class="small"><a href="/prospects/new?company={{.ID}}">Add a person at {{.Name}}</a></p>{{end}}
</section>
{{end}}
{{if .Loose}}
<section class="card prospect">
<h2>People without a company</h2>
<ul class="items people">
{{range .Loose}}{{template "contact" dict "P" . "Tab" $tab "Matches" $matches}}{{end}}
</ul>
</section>
{{end}}
{{if not (or .Companies .Loose)}}
<section class="card empty">
{{if eq $tab "new"}}<p>Nothing to review. <a href="/prospects/new">Add a prospect</a> by hand; finding them for you comes next.</p>
{{else if eq $tab "accepted"}}<p>Nothing accepted yet.</p>
{{else}}<p>Nothing set aside.</p>{{end}}
</section>
{{end}}
{{end}}{{end}}
{{define "contact"}}{{$p := .P}}{{$tab := .Tab}}
<li class="item">
<div class="prospect-head">
<div>
<strong>{{$p.Name}}</strong>{{with $p.Title}} · {{.}}{{end}}{{if ne $p.Status $tab}} <span class="badge">{{template "prospect-status" $p.Status}}</span>{{end}}
<div class="meta">
{{with $p.Email}}<a href="mailto:{{.}}">{{.}}</a>{{if eq $p.EmailStatus "valid"}} <span class="badge published">verified</span>{{else if eq $p.EmailStatus "risky"}} <span class="badge">risky</span>{{else if eq $p.EmailStatus "invalid"}} <span class="badge failed">bounces</span>{{else}} <span class="muted">not verified</span>{{end}}{{end}}
{{with $p.Phone}} · {{.}}{{end}}
{{with $p.LinkedIn}} · <a href="{{.}}" target="_blank" rel="noopener noreferrer">LinkedIn</a>{{end}}
</div>
<div class="meta">{{template "provenance" $p}}</div>
{{with index .Matches (printf "contact:%d" $p.ID)}}{{template "crm-matches" .}}{{end}}
</div>
{{if eq $p.Status $tab}}
<div class="row-actions">
{{if eq $tab "new"}}
<form method="post" action="/prospects/contact/{{$p.ID}}/accept"><input type="hidden" name="tab" value="{{$tab}}"><button type="submit" class="small">Accept</button></form>
<form method="post" action="/prospects/contact/{{$p.ID}}/reject"><input type="hidden" name="tab" value="{{$tab}}"><button type="submit" class="secondary small">Set aside</button></form>
{{if $p.Email}}<form method="post" action="/prospects/contact/{{$p.ID}}/suppress" data-confirm="Never add {{$p.Email}}? This puts the address on your suppression list."><input type="hidden" name="tab" value="{{$tab}}"><button type="submit" class="secondary small">Suppress</button></form>{{end}}
{{else if eq $tab "accepted"}}
{{template "crm-state" dict "CRM" $p.CRM "Kind" "contact" "ID" $p.ID "Tab" $tab}}
{{else}}
<form method="post" action="/prospects/contact/{{$p.ID}}/reconsider"><input type="hidden" name="tab" value="{{$tab}}"><button type="submit" class="secondary small">Reconsider</button></form>
{{end}}
</div>
{{end}}
</div>
</li>
{{end}}
{{define "prospect-status"}}{{if eq . "new"}}new{{else if eq . "accepted"}}accepted{{else}}set aside{{end}}{{end}}
{{define "provenance"}}{{if eq .Source "manual"}}Added by hand{{else}}Found by {{.Source}}{{end}} {{ago .FoundAt}}{{with .SourceDetail}} · {{if or (hasPrefix . "https://") (hasPrefix . "http://")}}<a href="{{.}}" target="_blank" rel="noopener noreferrer">source</a>{{else}}{{.}}{{end}}{{end}}{{end}}
{{define "crm-matches"}}
<p class="warnings">Already in your CRM: {{range $i, $r := .}}{{if $i}}, {{end}}{{$r.Entity}} <strong>{{$r.Name}}</strong>{{with $r.Email}} ({{.}}){{end}}{{end}}.</p>
{{end}}
{{define "crm-state"}}
{{if eq .CRM.Status "done"}}<span class="badge published">{{if eq .CRM.Outcome "existing"}}already in the CRM{{else}}in the CRM{{end}}</span>
{{else if eq .CRM.Status "failed"}}<span class="badge failed">failed</span> <a class="small" href="/crm">CRM queue</a>
{{else if eq .CRM.Status "cancelled"}}<span class="badge">cancelled</span>
<form method="post" action="/prospects/{{.Kind}}/{{.ID}}/accept"><input type="hidden" name="tab" value="{{.Tab}}"><button type="submit" class="secondary small">Queue again</button></form>
{{else if eq .CRM.Status "claimed"}}<span class="badge scheduled">with Hermes</span>
{{else if .CRM.Status}}<span class="badge draft">waiting for Hermes</span>
{{else}}<span class="badge">accepted</span>{{end}}
{{end}}
+35
View File
@@ -0,0 +1,35 @@
{{define "content"}}{{with .Data}}
<h1>Suppression list</h1>
<p class="lede">People and companies Supermarket must never add to your CRM: someone who asked not to be contacted, existing customers, partners, competitors. It's checked before a prospect is added, and again before anything is queued. A domain covers everyone with an email there.</p>
<form method="post" action="/prospects/suppressed" class="card">
<div class="cols">
<label>Email or domain <input name="value" value="{{.Value}}" placeholder="name@example.com or example.com" required autocomplete="off"></label>
<label>Reason <span class="muted small">(optional)</span> <input name="reason" placeholder="e.g. asked not to be contacted"></label>
</div>
<button type="submit">Add to the list</button>
</form>
{{if .List}}
<table class="list">
<thead><tr><th>Email or domain</th><th>Reason</th><th>Added</th><th></th></tr></thead>
<tbody>
{{range .List}}
<tr>
<td><strong>{{.Value}}</strong> <span class="muted small">{{.Kind}}</span></td>
<td>{{.Reason}}</td>
<td>{{ago .CreatedAt}}</td>
<td class="row-actions">
<form method="post" action="/prospects/suppressed" data-confirm="Take {{.Value}} off the suppression list?">
<input type="hidden" name="kind" value="{{.Kind}}"><input type="hidden" name="value" value="{{.Value}}">
<button type="submit" name="remove" value="1" class="secondary small">Remove</button>
</form>
</td>
</tr>
{{end}}
</tbody>
</table>
{{else}}
<section class="card empty"><p>The list is empty.</p></section>
{{end}}
{{end}}{{end}}