{{define "content"}}{{with .Data}}{{$tab := .Tab}}{{$matches := .Matches}}{{$d := .}}
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 the CRM queue. Each one keeps where and when it was found.
{{if .Signals}} {{end}} {{if and (eq $tab "new") (or .Companies .Loose)}}{{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}}
{{end}} {{range .Companies}}{{$c := .}}{{.}}
{{end}} {{template "signal-tag" dict "Kind" "company" "ID" .ID "SignalID" .SignalID "D" $d}} {{with index $matches (printf "company:%d" .ID)}}{{template "crm-matches" .}}{{end}} {{if .Contacts}}Nothing to review. Add a prospect by hand; finding them for you comes next.
{{else if eq $tab "accepted"}}Nothing accepted yet.
{{else}}Nothing set aside.
{{end}}Already in your CRM: {{range $i, $r := .}}{{if $i}}, {{end}}{{$r.Entity}} {{$r.Name}}{{with $r.Email}} ({{.}}){{end}}{{end}}.
{{end}} {{define "crm-state"}} {{if eq .CRM.Status "done"}}{{if eq .CRM.Outcome "existing"}}already in the CRM{{else}}in the CRM{{end}} {{else if eq .CRM.Status "failed"}}failed CRM queue {{else if eq .CRM.Status "cancelled"}}cancelled {{else if eq .CRM.Status "claimed"}}with Hermes {{else if .CRM.Status}}waiting for Hermes {{else}}accepted{{end}} {{end}} {{define "signal-tag"}}{{$d := .D}}{{$cur := .SignalID}} {{if $d.Signals}} {{end}} {{end}} {{define "outcomes"}}{{$d := .D}}{{$subject := printf "%s:%d" .Kind .ID}} {{with index $d.Events $subject}}