PageSourceSearch

https://trybrain.io/assets/_authenticated.lead-duplicates-CjOu-gU4.js

js trybrain.io collected 2026-09-24 15:05:27 UTC 4,590 bytes, 1 lines download raw bytes

1import{z as x,D as g,E as j,f as y,P as E,e as u,au as q,r as k,K as N,al as i,j as e,L as I,N as b,C as v,d as _,a as $,b as B,k as P,B as p}from"./index-DHwBXtP2.js";const A=x({method:"GET"}).middleware([g]).handler(j("src_lib_lead-duplicates_functions_ts--listLeadDuplicates_createServerFn_handler")),M=x({method:"POST"}).middleware([g]).handler(j("src_lib_lead-duplicates_functions_ts--mergeLeadDuplicates_createServerFn_handler")),R=x({method:"POST"}).middleware([g]).handler(j("src_lib_lead-duplicates_functions_ts--unmergeLeadDuplicate_createServerFn_handler"));function h(n){return n?new Date(n).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}):"—"}function z(){const{data:n}=y({queryKey:["workspaces"],queryFn:()=>E()}),t=n?.[0]?.id??"",F=u(A),L=u(M),w=u(R),f=q(),{data:d,isLoading:C}=y({queryKey:["lead-duplicates",t],queryFn:()=>F({data:{workspaceId:t}}),enabled:!!t}),[D,S]=k.useState({}),c=N({mutationFn:s=>L({data:{workspaceId:t,...s}}),onSuccess:s=>{const r=s.copiedFields?.length?` · copied ${Array.from(new Set(s.copiedFields)).join(", ")} onto the record you kept`:"";i.success(`Merged ${s.merged} extra record${s.merged===1?"":"s"}${r}`),f.invalidateQueries({queryKey:["lead-duplicates",t]})},onError:s=>i.error(s.message)}),K=N({mutationFn:s=>w({data:{workspaceId:t,leadId:s}}),onSuccess:()=>{i.success("Record restored to the call list"),f.invalidateQueries({queryKey:["lead-duplicates",t]})},onError:s=>i.error(s.message)}),l=k.useMemo(()=>d?.groups??[],[d]);return e.jsxs("div",{className:"mx-auto w-full max-w-4xl space-y-4 p-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Duplicate contacts"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"These phone numbers appear on more than one lead record. Because the dialer rests each record separately, the same person can come back around again and again. Pick the record to keep and the rest stop being called — nothing is deleted, and you can undo it any time."}),e.jsx("p",{className:"mt-2 text-sm",children:e.jsx(I,{to:"/dialer",className:"underline underline-offset-2",children:"Back to the dialer"})})]}),C?e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{className:"h-24 w-full"}),e.jsx(b,{className:"h-24 w-full"})]}):l.length===0?e.jsx(v,{children:e.jsx(_,{className:"p-6 text-sm text-muted-foreground",children:"No repeated phone numbers left. Every person appears once."})}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:[d?.totalExtraRecords??0," extra record",(d?.totalExtraRecords??0)===1?"":"s"," across"," ",l.length," phone number",l.length===1?"":"s","."]}),l.map(s=>{const r=D[s.phone]??s.suggestedKeepId,o=s.leads.filter(a=>a.id!==r).map(a=>a.id);return e.jsxs(v,{children:[e.jsx($,{className:"pb-2",children:e.jsxs(B,{className:"text-sm",children:[s.leads[0]?.name," · ",s.leads[0]?.phone??s.phone,e.jsxs("span",{className:"ml-2 font-normal text-muted-foreground",children:[s.leads.length," records"]})]})}),e.jsxs(_,{className:"space-y-2",children:[s.leads.map(a=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-3 rounded-md border border-border p-2 text-sm",children:[e.jsx("input",{type:"radio",name:`keep-${s.phone}`,checked:r===a.id,onChange:()=>S(m=>({...m,[s.phone]:a.id}
1)),"aria-label":`Keep record from ${h(a.occurredAt)}`}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"font-medium",children:a.name}),e.jsxs("span",{className:"ml-2 text-muted-foreground",children:["added ",h(a.occurredAt),a.stage?` · ${a.stage}`:""," · ",a.attempts," call",a.attempts===1?"":"s",a.lastCallAt?`, last ${h(a.lastCallAt)}`:""]})]}),a.isDuplicate?e.jsxs(e.Fragment,{children:[e.jsx(P,{variant:"outline",className:"shrink-0 text-[10px]",children:"not called"}),e.jsx(p,{size:"sm",variant:"ghost",onClick:m=>{m.preventDefault(),K.mutate(a.id)},children:"Undo"})]}):null]},a.id)),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[e.jsx(p,{size:"sm",disabled:o.length===0||c.isPending,onClick:()=>c.mutate({keepLeadId:r,duplicateLeadIds:o,combineDetails:!0}),children:"Merge"}),e.jsx(p,{size:"sm",variant:"outline",disabled:o.length===0||c.isPending,onClick:()=>c.mutate({keepLeadId:r,duplicateLeadIds:o}),children:"Keep selected"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Merge copies any missing name, email or phone onto the record you picked, then stops calling the rest. Keep selected only stops the calls."})]})]})]},s.phone)})]})]})}export{z as component};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.