PageSourceSearch

https://boombam.app/assets/business-list-builder-DLeRKS-2.js

js boombam.app collected 2026-10-04 13:34:14 UTC 51,457 bytes, 8 lines download raw bytes

1import{K as Ks,N as ws,a5 as bs,r as c,a as He,a6 as v,j as e,aE as De,br as is,C as fe,b as Je,d as We,o as rs,e as ye,ab as h,$ as _,a0 as H,a1 as J,a2 as W,a3 as x,aF as N,B as d,a4 as ee,bS as Ss,bd as Fs,D as Qs,b$ as Rs,aY as Vs,bU as _s,af as ks,ag as Ls,ah as Ds,ai as Ze,aj as Ps,au as Ue,ak as Pe,al as $e,am as Ie,an as Ee,ao as Ge,aD as ds,ap as Ne,s as $,aq as Be,as as cs,av as os,aw as us,ax as ms,ay as hs,az as xs,aA as ps,aB as js,c2 as r,ac as fs,U as Hs,J as ns,v as Js,a8 as Ws,a9 as Us,aa as Zs,a7 as f}from"./index-CuSEeJFb.js";import{T as ys,a as Ns,b as Re,c as Ve}from"./tabs-CcPOXtvT.js";import{C as Gs}from"./calendar-B35CJklo.js";import{M as Ys}from"./map-pin-DOxfmRxb.js";import{a as Xs,F as Ye}from"./folder-XQRCjIoi.js";import{F as Cs}from"./folder-open-nDEnLPQX.js";import{E as et}from"./ellipsis-vertical-04pZ3iRl.js";import{C as st}from"./copy-Ctw93tQ7.js";import{f as ls}from"./format-hhvI2L0z.js";import"./subDays-Cl8kgx1y.js";import"./isSameDay-asvKFMkz.js";import"./en-US-BOoww7nS.js";import"./differenceInCalendarMonths-CdYt3YUn.js";import"./isSameMonth-GNceXh6W.js";import"./endOfWeek-COLolEil.js";import"./endOfMonth-DMtDxPW7.js";import"./isBefore-dQ65yIyQ.js";/**
2 * @license lucide-react v0.453.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const $s=Ks("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]),_e={not_contacted:{label:"Not Contacted",color:"bg-gray-100 text-gray-800"},interested:{label:"Interested",color:"bg-green-100 text-green-800"},not_interested:{label:"Not Interested",color:"bg-red-100 text-red-800"},needs_followup:{label:"Needs Follow-up",color:"bg-yellow-100 text-yellow-800"},callback_scheduled:{label:"Callback Scheduled",color:"bg-blue-100 text-blue-800"},closed_won:{label:"Closed Won",color:"bg-emerald-100 text-emerald-800"},closed_lost:{label:"Closed Lost",color:"bg-slate-100 text-slate-800"}},Is=i=>{if(!i)return null;const u=typeof i=="string"?parseFloat(i):i;return isNaN(u)?null:`${u.toFixed(1)} ⭐`},Es=i=>{if(!i)return"";const u=i.replace(/^[=+\s]+/,"").replace(/[^\d]/g,"");return u.length===11&&u.startsWith("1")?`1-${u.slice(1,4)}-${u.slice(4,7)}-${u.slice(7)}`:u.length===10?`${u.slice(0,3)}-${u.slice(3,6)}-${u.slice(6)}`:i};function yt(){var ge,ve,Qe;const{activeCompanyId:i}=ws(),u=bs(),[Xe,Ae]=c.useState("search"),[oe,se]=c.useState(!1),[p,F]=c.useState([]),[y,z]=c.useState([]),[Te,te]=c.useState(!1),[U,ue]=c.useState(""),[Ce,we]=c.useState(""),[ae,q]=c.useState("new"),[M,me]=c.useState(null),[I,he]=c.useState(""),[w,E]=c.useState({industry:"",customIndustry:"",location:"",radius:25,platform:"all",maxResults:50}),{data:es=[]}=He({queryKey:["/api/business-lists/industries"]}),{data:j=[],isLoading:ss}=He({queryKey:["/api/business-lists",i],queryFn:async()=>{const t=await fetch(`/api/business-lists?companyId=${i}`);if(!t.ok)throw new Error("Failed to fetch business lists");return t.json()},enabled:!!i}),[g,k]=c.useState("all"),[ze,O]=c.useState(!1),[ie,Z]=c.useState(""),[B,D]=c.useState(""),[ne,G]=c.useState(null),[qe,xe]=c.useState(!1),[A,le]=c.useState(null),{data:Me=[]}=He({queryKey:["/api/business-list-folders"],enabled:!!i}),K=v({mutationFn:async t=>await(await f("/api/business-list-folders",{method:"POST",body:JSON.stringify(t)})).json(),onSuccess:()=>{u.invalidateQueries({queryKey:["/api/business-list-folders"]}),O(!1),Z(""),D(""),G(null),r({title:"Folder created"})},onError:()=>{r({title:"Failed to create folder",variant:"destructive"})}}),Y=v({mutationFn:async t=>await(await f(`/api/business-list-folders/${t.id}`,{method:"PATCH",body:JSON.stringify({name:t.name,description:t.description})})).json(),onSuccess:()=>{u.invalidateQueries({queryKey:["/api/business-list-folders"]}),O(!1),Z(""),D(""),G(null),r({title:"Folder updated"})},onError:()=>{r({title:"Failed to update folder",variant:"destructive"})}}),be=v({mutationFn:async t=>{await f(`/api/business-list-folders/${t}`,{method:"DELETE"})},onSuccess:()=>
6{u.invalidateQueries({queryKey:["/api/business-list-folders"]}),u.invalidateQueries({queryKey:["/api/business-lists",i]}),xe(!1),le(null),g===(A==null?void 0:A.id)&&k("all"),r({title:"Folder deleted"})},onError:()=>{r({title:"Failed to delete folder",variant:"destructive"})}}),Q=g==="all"?j:g===null?j.filter(t=>!t.folderId):j.filter(t=>t.folderId===g),Se=()=>{ne?Y.mutate({id:ne.id,name:ie,description:B||void 0}):K.mutate({name:ie,description:B||void 0})},R=t=>{G(t),Z(t.name),D(t.description||""),O(!0)},re=()=>{G(null),Z(""),D(""),O(!0)},Oe=v({mutationFn:async t=>await(await f("/api/business-lists/search",{method:"POST",body:JSON.stringify({...t,companyId:i})})).json(),onSuccess:t=>{var n;console.log("🔧 Frontend - Search successful, data received:",t),console.log("🔧 Frontend - Businesses count:",(n=t.businesses)==null?void 0:n.length),console.log("🔧 Frontend - Setting searchResults to:",t.businesses),F(t.businesses),z([]),se(!1),r({title:"Search Complete",description:`Found ${t.totalFound} businesses matching your criteria`})},onError:t=>{se(!1),r({title:"Search Failed",description:t.message||"Failed to search for businesses",variant:"destructive"})}}),V=v({mutationFn:async t=>await(await f("/api/business-lists",{method:"POST",body:JSON.stringify({...t,companyId:i})})).json(),onSuccess:()=>{u.invalidateQueries({queryKey:["/api/business-lists",i]}),te(!1),ue(""),we(""),q("new"),me(null),z([]),r({title:"List Saved",description:"Business list has been saved successfully"})},onError:t=>{r({title:"Save Failed",description:t.message||"Failed to save business list",variant:"destructive"})}}),pe=v({mutationFn:async t=>await(await f(`/api/business-lists/${t.listId}/append`,{method:"POST",body:JSON.stringify({businesses:t.businesses})})).json(),onSuccess:t=>{u.invalidateQueries({queryKey:["/api/business-lists",i]}),te(!1),q("new"),me(null),z([]),r({title:"Businesses Added",description:`Added ${t.addedCount||"selected"} businesses to the existing list`})},onError:t=>{r({title:"Failed to Add",description:t.message||"Failed to add businesses to the list",variant:"destructive"})}}),de=v({mutationFn:async t=>await(await f(`/api/business-lists/${t}`,{method:"DELETE"})).json(),onSuccess:()=>{u.invalidateQueries({queryKey:["/api/business-lists",i]}),r({title:"List Deleted",description:"Business list has been deleted successfully"})},onError:t=>{r({title:"Delete Failed",description:t.message||"Failed to delete business list",variant:"destructive"})}}),b=v({mutationFn:async t=>await(await f(`/api/business-lists/${t.listId}`,{method:"PATCH",body:JSON.stringify({name:t.name,description:t.description,folderId:t.folderId})})).json(),onSuccess:()=>{u.invalidateQueries({queryKey:["/api/business-lists",i]}),r({title:"List Updated",description:"Business list has been updated successfully"})},onError:t=>{r({title:"Update Failed",description:t.message||"Failed to update business list",variant:"destructive"})}}),L=v({mutationFn:async t=>await(await f(`/api/business-lists/${t.listId}/convert-to-clients`,{method:"POST",body:JSON.stringify({businessIds:t.businessIds,companyId:i})})).json(),onSuccess:t=>{u.invalidateQueries({queryKey:["/api/business-lists",i]}),u.invalidateQueries({queryKey:["/api/companies"]}),r({title:"Conversion Complete",description:t.message||"Businesses converted to clients successfully"})},onError:t=>{r({title:"Conversion Failed",description:t.message||"Failed to convert businesses to clients",variant:"destructive"})}}),X=async()=>{var T;if(!i){r({title:"Company Required",description:"Please select a company before searching",variant:"destructive"});return}const t=((T=w.customIndustry)==null?void 0:T.trim())||w.industry;if(!t||!w.location){r({title:"Missing Information",description:"Please enter both industry (or custom industry) and location",variant:"destructive"});return}const n={...w,industry:t};console.log("🔧 Frontend - Starting search with params:",n),se(!0),Oe.mutate(n)},ts=()=>{if(!i){r({title:"Company Required",description:"Please select a company before saving",variant:"destructive"});return}const t=(p||[]).filter(n=>
6y.includes(n.id));if(ae==="existing"){if(!M){r({title:"Select a List",description:"Please select an existing list to add businesses to",variant:"destructive"});return}pe.mutate({listId:M,businesses:t})}else{if(!U.trim()){r({title:"Missing Name",description:"Please enter a name for your business list",variant:"destructive"});return}V.mutate({name:U.trim(),description:Ce.trim()||void 0,searchParams:w,businesses:t})}},je=t=>{z(n=>n.includes(t)?n.filter(T=>T!==t):[...n,t])},Ke=()=>{if(!p)return[];if(!I.trim())return p;const t=I.toLowerCase();return p.filter(n=>(n.name||"").toLowerCase().includes(t)||(n.address||"").toLowerCase().includes(t)||(n.city||"").toLowerCase().includes(t)||(n.phone||"").toLowerCase().includes(t)||(n.email||"").toLowerCase().includes(t)||(n.website||"").toLowerCase().includes(t))},as=()=>{const n=Ke().map(S=>S.id);n.every(S=>y.includes(S))&&n.length>0?z(S=>S.filter(Fe=>!n.includes(Fe))):z(S=>[...new Set([...S,...n])])};return e.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Business List Builder"}),e.jsx("p",{className:"text-muted-foreground",children:"Discover businesses by industry and location to build your client pipeline"})]})}),e.jsxs(ys,{value:Xe,onValueChange:Ae,children:[e.jsxs(Ns,{className:"grid w-full grid-cols-2",children:[e.jsxs(Re,{value:"search","data-testid":"tab-search",children:[e.jsx(De,{className:"w-4 h-4 mr-2"}),"Search Businesses"]}),e.jsxs(Re,{value:"saved-lists","data-testid":"tab-saved-lists",children:[e.jsx(is,{className:"w-4 h-4 mr-2"}),"Saved Lists (",j.length,")"]})]}),e.jsxs(Ve,{value:"search",className:"space-y-6",children:[e.jsxs(fe,{children:[e.jsxs(Je,{children:[e.jsx(We,{children:"Business Search"}),e.jsx(rs,{children:"Search for businesses by industry and location across multiple platforms"})]}),e.jsxs(ye,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"industry",children:"Industry"}),e.jsxs(_,{value:w.industry,onValueChange:t=>E(n=>({...n,industry:t,customIndustry:""})),children:[e.jsx(H,{"data-testid":"select-industry",children:e.jsx(J,{placeholder:"Select industry"})}),e.jsx(W,{children:es.map(t=>e.jsx(x,{value:t,children:t},t))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"customIndustry",children:"Custom Industry Search"}),e.jsx(N,{id:"customIndustry",placeholder:"e.g. landscaping, solar installation",value:w.customIndustry||"",onChange:t=>E(n=>({...n,customIndustry:t.target.value,industry:""})),"data-testid":"input-custom-industry"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Type any custom industry or leave blank to use dropdown"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"location",children:"Location"}),e.jsx(N,{id:"location",placeholder:"City, State or ZIP code",value:w.location,onChange:t=>E(n=>({...n,location:t.target.value})),"data-testid":"input-location"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"radius",children:"Search Radius"}),e.jsxs(_,{value:(ge=w.radius)==null?void 0:ge.toString(),onValueChange:t=>E(n=>({...n,radius:parseInt(t)})),children:[e.jsx(H,{"data-testid":"select-radius",children:e.jsx(J,{})}),e.jsxs(W,{children:[e.jsx(x,{value:"5",children:"5 miles"}),e.jsx(x,{value:"10",children:"10 miles"}),e.jsx(x,{value:"25",children:"25 miles"}),e.jsx(x,{value:"50",children:"50 miles"}),e.jsx(x,{value:"100",children:"100 miles"}),e.jsx(x,{value:"200",children:"200 miles"}),e.jsx(x,{value:"500",children:"500 miles"}),e.jsx(x,{value:"1000",children:"Statewide (~1000 miles)"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"maxResults",children:"Max Results"}),e.jsxs(_,{value:(ve=w.maxResults)==null?void 0:ve.toString(),onValueChange:t=>E(n=>({...n,maxResults:parseInt(t)})),children:[e.jsx(H,{"data-testid":"select-max-results",children:e.jsx(J,{})}),e.jsxs(W,{children:[e.jsx(x,{value:"25",children:"25 results"}),e.jsx(x,{value:"50",children:"50 results"}),e.jsx(x,{value:"100",children:"100 results"}),e.jsx(x,{value:"200",children:"200 results"})]})]})]})]}),e.jsx(d,{onClick:X,disabled:oe||!w.industry&&!((Qe=w.customIndustry)!=null&&Qe.trim())||!w.location,className:"w-full","data-testid":"button-search",children:oe?e.jsxs(e.Fragment,{children:[e.jsx(ee,{className:"w-4 h-4 mr-2 animate-spin"}),"Searching Businesses..."]}):e.jsxs(e.Fragment,{children:[e.jsx(De,{className:"w-4 h-4 mr-2"}),"Search Businesses"]})})]})]}),p&&p.length>0&&e.jsxs(fe,{children:[e.jsxs(Je,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsxs("div",{children:[e.jsxs(We,{children:["Search Results (",(p==null?void 0:p.length)||0,")"]}
6),e.jsx(rs,{children:"Select businesses to save or convert to clients"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(d,{variant:"outline",size:"sm",onClick:as,"data-testid":"button-select-all",children:(()=>{const n=Ke().map(S=>S.id);return n.length>0&&n.every(S=>y.includes(S))?"Deselect All":"Select All"})()}),y.length>0&&e.jsxs(d,{onClick:()=>te(!0),size:"sm","data-testid":"button-save-selected",children:[e.jsx(Ss,{className:"w-4 h-4 mr-2"}),"Save Selected (",y.length,")"]})]})]}),e.jsxs(ye,{children:[e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(De,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(N,{type:"text",placeholder:"Filter results by name, address, phone...",value:I,onChange:t=>he(t.target.value),className:"pl-8"})]}),I.trim()&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:["Showing ",(p==null?void 0:p.filter(t=>{const n=I.toLowerCase();return(t.name||"").toLowerCase().includes(n)||(t.address||"").toLowerCase().includes(n)||(t.city||"").toLowerCase().includes(n)||(t.phone||"").toLowerCase().includes(n)||(t.email||"").toLowerCase().includes(n)||(t.website||"").toLowerCase().includes(n)}).length)||0," of ",(p==null?void 0:p.length)||0," results"]})]}),e.jsx("div",{className:"space-y-4",children:p==null?void 0:p.filter(t=>{if(!I.trim())return!0;const n=I.toLowerCase();return(t.name||"").toLowerCase().includes(n)||(t.address||"").toLowerCase().includes(n)||(t.city||"").toLowerCase().includes(n)||(t.phone||"").toLowerCase().includes(n)||(t.email||"").toLowerCase().includes(n)||(t.website||"").toLowerCase().includes(n)}).map(t=>e.jsx("div",{className:`p-4 border rounded-lg cursor-pointer transition-colors ${y.includes(t.id)?"bg-primary/5 border-primary":"hover:bg-muted/50"}`,onClick:()=>je(t.id),"data-testid":`business-card-${t.id}`,children:e.jsx("div",{className:"flex items-start justify-between",children:e.jsxs("div",{className:"flex items-start space-x-3",children:[e.jsx(Fs,{checked:y.includes(t.id),onChange:()=>je(t.id),"data-testid":`checkbox-business-${t.id}`}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("h3",{className:"font-semibold",children:t.name}),t.rating&&e.jsxs("div",{className:"flex items-center text-sm text-muted-foreground",children:[e.jsx(Qs,{className:"w-3 h-3 mr-1 fill-yellow-400 text-yellow-400"}),Is(t.rating),t.reviewCount&&e.jsxs("span",{className:"ml-1",children:["(",t.reviewCount," reviews)"]})]})]}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:t.description}),e.jsxs("div",{className:"flex flex-wrap gap-4 text-sm text-muted-foreground",children:[t.address&&e.jsxs("div",{className:"flex items-center",children:[e.jsx(Ys,{className:"w-3 h-3 mr-1"}),t.address]}),t.phone&&e.jsxs("div",{className:"flex items-center",children:[e.jsx(Rs,{className:"w-3 h-3 mr-1"}),Es(t.phone)]}),t.website&&e.jsxs("div",{className:"flex items-center",children:[e.jsx(Vs,{className:"w-3 h-3 mr-1"}),e.jsxs("a",{href:t.website,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",onClick:n=>n.stopPropagation(),children:["Website",e.jsx(_s,{className:"w-3 h-3 ml-1 inline"})]})]})]})]})]})})},t.id))})]})]})]}),e.jsx(Ve,{value:"saved-lists",className:"space-y-6",children:ss?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(ee,{className:"w-8 h-8 animate-spin"})}):j.length===0?e.jsx(fe,{children:e.jsxs(ye,{className:"flex flex-col items-center justify-center h-64",children:[e.jsx(is,{className:"w-12 h-12 text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-lg font-medium mb-2",children:"No Saved Lists"}),e.jsx("p",{className:"text-muted-foreground text-center mb-4",children:"Create your first business list by searching and saving results"}),e.jsxs(d,{onClick:()=>Ae("search"),"data-testid":"button-start-search",children:[e.jsx(De,{className:"w-4 h-4 mr-2"}),"Start Searching"]})]})}):e.jsxs("div",{className:"flex gap-6",children:[e.jsx("div",{className:"w-64 shrink-0",children:e.jsxs(fe,{children:[e.jsx(Je,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(We,{className:"text-sm font-medium",children:"Folders"}),e.jsx(d,{variant:"ghost",size:"sm",onClick:re,children:e.jsx(Xs,{className:"w-4 h-4"})})]})}),e.jsxs(ye,{className:"space-y-1",children:[e.jsxs(d,{variant:g==="all"?"secondary":"ghost",className:"w-full justify-start",onClick:()=>k("all"),children:[e.jsx(Cs,{className:"w-4 h-4 mr-2"}),"All Lists (",j.length,")"]}),e.jsxs(d,{variant:g===null?"secondary":"ghost",className:"w-full justify-start",onClick:()=>k(null),children:[e.jsx(Ye,{className:"w-4 h-4 mr-2"}),"Unassigned (",j.filter(t=>!t.folderId).length,")"]}),Me.map(t=>e.jsxs("div",{className:"flex items-center group",children:[e.jsxs(d,{variant:g===t.id?"secondary":"ghost",className:"flex-1 justify-start",onClick:()=>k(t.id),children:[e.jsx(Ye,{className:"w-4 h-4 mr-2"}),e.jsx("span",{className:"truncate",children:t.name}),e.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:j.filter(n=>n.folderId===t.id).length})]}),e.jsxs(ks,{children:[e.jsx(Ls,{asChild:!0,children:e.jsx(d,{variant:"ghost",size:"sm",className:"opacity-0 group-hover:opacity-100 h-8 w-8 p-0",children:e.jsx(et,{className:"w-4 h-4"})})}),e.jsxs(Ds,{align:"end",children:[e.jsxs(Ze,{onClick:()=>R(t),children:[e.jsx($s,{className:"w-4 h-4 mr-2"}),"Rename"]}),e.jsx(Ps,{}),e.jsxs(Ze,{className:"text-destructive",onClick:()=>{le(t),xe(!0)},children:[e.jsx(Ue,{className:"w-4 h-4 mr-2"}),"Delete"]})]})]})]},t.id))]})]})}),e.jsx("div",{className:"flex-1 grid gap-6",children:Q.length===0?e.jsx(fe,{children:e.jsx(ye,{className:"flex flex-col items-center justify-center h-32",children:e.jsx("p",{className:"text-muted-foreground",children:"No lists in this folder"})})}):Q.map(t=>e.jsx(tt,{list:t,folders:Me,onConvertToClients:n=>L.mutate({listId:t.id,businessIds:n}),onDelete:n=>de.mutate(n),onUpdate:(n,T,S,Fe)=>b.mutate({listId:n,name:T,description:S,folderId:Fe})},t.id))})]})})]}),e.jsx(Pe,{open:Te,onOpenChange:t=>{te(t),t||(q("new"),me(null))},children:e.jsxs($e,{"data-testid":"dialog-save-list",className:"max-w-md",children:[e.jsxs(Ie,{children:[e.jsx(Ee,{children:"Save Businesses"}),e.jsxs(Ge,{children:["Save your selected businesses (",y.length,") to a list"]})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs(ys,{value:ae,onValueChange:t=>q(t),children:[e.jsxs(Ns,{className:"grid w-full grid-cols-2",children:[e.jsxs(Re,{value:"new","data-testid":"tab-create-new",children:[e.jsx(ds,{className:"w-4 h-4 mr-2"}),"Create New List"]}),e.jsxs(Re,{value:"existing","data-testid":"tab-add-existing",disabled:j.length===0,children:[e.jsx(Cs,{className:"w-4 h-4 mr-2"}),"Add to Existing"]})]}
6),e.jsxs(Ve,{value:"new",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"listName",children:"List Name"}),e.jsx(N,{id:"listName",placeholder:"e.g., Miami Restaurants, Denver Auto Shops",value:U,onChange:t=>ue(t.target.value),"data-testid":"input-list-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"listDescription",children:"Description (Optional)"}),e.jsx(Ne,{id:"listDescription",placeholder:"Add notes about this list...",value:Ce,onChange:t=>we(t.target.value),"data-testid":"textarea-list-description"})]})]}),e.jsxs(Ve,{value:"existing",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{children:"Select Existing List"}),e.jsxs(_,{value:(M==null?void 0:M.toString())||"",onValueChange:t=>me(parseInt(t)),children:[e.jsx(H,{"data-testid":"select-existing-list",children:e.jsx(J,{placeholder:"Choose a list..."})}),e.jsx(W,{children:j.map(t=>e.jsx(x,{value:t.id.toString(),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(is,{className:"w-4 h-4"}),e.jsx("span",{children:t.name}),e.jsxs($,{variant:"secondary",className:"ml-auto text-xs",children:[t.totalFound," businesses"]})]})},t.id))})]})]}),M&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[y.length," business(es) will be added to this list"]})]})]})}),e.jsxs(Be,{children:[e.jsx(d,{variant:"outline",onClick:()=>te(!1),children:"Cancel"}),e.jsx(d,{onClick:ts,disabled:V.isPending||pe.isPending,"data-testid":"button-save-list",children:V.isPending||pe.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ee,{className:"w-4 h-4 mr-2 animate-spin"}),ae==="existing"?"Adding...":"Saving..."]}):ae==="existing"?"Add to List":"Save List"})]})]})}),e.jsx(Pe,{open:ze,onOpenChange:O,children:e.jsxs($e,{children:[e.jsxs(Ie,{children:[e.jsx(Ee,{children:ne?"Rename Folder":"Create Folder"}),e.jsx(Ge,{children:ne?"Update the folder name":"Create a new folder to organize your business lists"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"folderName",children:"Folder Name"}),e.jsx(N,{id:"folderName",placeholder:"e.g., Q1 Prospects, High Priority",value:ie,onChange:t=>Z(t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{htmlFor:"folderDescription",children:"Description (Optional)"}),e.jsx(Ne,{id:"folderDescription",placeholder:"Add notes about this folder...",value:B,onChange:t=>D(t.target.value)})]})]}),e.jsxs(Be,{children:[e.jsx(d,{variant:"outline",onClick:()=>O(!1),children:"Cancel"}),e.jsxs(d,{onClick:Se,disabled:!ie.trim()||K.isPending||Y.isPending,children:[K.isPending||Y.isPending?e.jsx(ee,{className:"w-4 h-4 mr-2 animate-spin"}):null,ne?"Save":"Create"]})]})]})}),e.jsx(cs,{open:qe,onOpenChange:xe,children:e.jsxs(os,{children:[e.jsxs(us,{children:[e.jsx(ms,{children:"Delete Folder"}),e.jsxs(hs,{children:['Are you sure you want to delete "',A==null?void 0:A.name,`"? Lists in this folder will become unassigned but won't be deleted.`]})]}),e.jsxs(xs,{children:[e.jsx(ps,{children:"Cancel"}),e.jsx(js,{onClick:()=>A&&be.mutate(A.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function tt({list:i,folders:u=[],onConvertToClients:Xe,onDelete:Ae,onUpdate:oe}){var gs,vs;ws();const[se,p]=c.useState(!1),[F,y]=c.useState([]),[z,Te]=c.useState(!1),[te,U]=c.useState(!1),[ue,Ce]=c.useState(i.name),[we,ae]=c.useState(i.description||""),[q,M]=c.useState(i.folderId||null),[me,I]=c.useState(!1),[he,w]=c.useState("all"),[E,es]=c.useState("date_desc"),[j,ss]=c.useState(""),g=bs(),{data:k,isLoading:ze,isError:O}=He({queryKey:["/api/business-lists",i.id,he,E],queryFn:async()=>{const s=new URLSearchParams;he!=="all"&&s.set("status",he),E&&s.set("sort",E);const a=`/api/business-lists/${i.id}${s.toString()?`?${s.toString()}`:""}`,m=await fetch(a,{credentials:"include"});if(!m.ok)throw new Error("Failed to fetch list details");return m.json()},enabled:se,retry:2,staleTime:2e3});c.useEffect(()=>{if(i.emailScanStatus==="scanning"||i.emailScanStatus==="pending"||i.emailScanStatus==="queued"){const s=setInterval(()=>{g.invalidateQueries({queryKey:["/api/business-lists"]})},5e3);return()=>clearInterval(s)}},[i.emailScanStatus,g]);const ie=v({mutationFn:async()=>f(`/api/business-lists/${i.id}/scan/pause`,{method:"POST"}),onSuccess:()=>{r({title:"Scan paused",description:"Email scanning has been paused. You can resume it later."}),g.invalidateQueries({queryKey:["/api/business-lists"]})},onError:s=>{r({title:"Failed to pause scan",description:s.message,variant:"destructive"})}}),Z=v({mutationFn:async()=>f(`/api/business-lists/${i.id}/scan/resume`,{method:"POST"}),onSuccess:()=>{r({title:"Scan resumed",description:"Email scanning has been added back to the queue."}),g.invalidateQueries({queryKey:["/api/business-lists"]})},onError:s=>{r({title:"Failed to resume scan",description:s.message,variant:"destructive"})}}),B=v({mutationFn:async()=>f(`/api/business-lists/${i.id}/scan/cancel`,{method:"POST"}),onSuccess:()=>{r({title:"Scan canceled",description:"Email scanning has been stopped."}),g.invalidateQueries({queryKey:["/api/business-lists"]})},onError:s=>{r({title:"Failed to cancel scan",description:s.message,variant:"destructive"})}}),D=v({mutationFn:async()=>f(`/api/business-lists/${i.id}/scan/restart`,{method:"POST"}),onSuccess:()=>{r({title:"Scan restarted",description:"Email scanning will process any new businesses."}),g.invalidateQueries({queryKey:["/api/business-lists"]})},onError:s=>{r({title:"Failed to restart scan",description:s.message,variant:"destructive"})}}),[ne,G]=c.useState(null),[qe,xe]=c.useState(""),[A,le]=c.useState(!1),[Me,K]=c.useState(!1),[Y,be]=c.useState(null),[Q,Se]=c.useState(null),[R,re]=c.useState(void 0),[Oe,V]=c.useState("09:00"),[pe,de]=c.useState(""),[b,L]=c.useState({name:"",phone:"",email:"",website:"",address:"",city:"",state:"",zipCode:"",industry:((gs=i.searchParams)==null?void 0:gs.industry)||"",notes:""}),X=v({mutationFn:async({businessId:s,updates:a})=>f(`/api/discovered-businesses/${s}`,{method:"PATCH",body:JSON.stringify(a)}),onSuccess:()=>{g.invalidateQueries({queryKey:["/api/business-lists",i.id]}),g.invalidateQueries({queryKey:["/api/business-lists"]}),g.invalidateQueries({predicate:s=>Array.isArray(s.queryKey)&&s.queryKey[0]==="/api/marketing-calendar/events"}),r({title:"Business updated"})},onError:()=>{r({title:"Failed to update business",variant:"destructive"})}}),ts=v({mutationFn:async s=>f(`/api/discovered-businesses/${s}`,{method:"DELETE"}),onSuccess:()=>{g.invalidateQueries({queryKey:["/api/business-lists"]}
6),r({title:"Business removed from list"})},onError:()=>{r({title:"Failed to remove business",variant:"destructive"})}}),je=v({mutationFn:async s=>{const m=(await Promise.allSettled(s.map(l=>f(`/api/discovered-businesses/${l}`,{method:"DELETE"})))).filter(l=>l.status==="rejected").length;return{deleted:s.length-m,failed:m}},onSuccess:s=>{g.invalidateQueries({queryKey:["/api/business-lists"]}),y([]),r({title:`Deleted ${s.deleted} businesses${s.failed>0?` (${s.failed} failed)`:""}`})},onError:()=>{r({title:"Failed to delete businesses",variant:"destructive"})}}),Ke=v({mutationFn:async({businessIds:s,status:a})=>{const l=(await Promise.allSettled(s.map(o=>f(`/api/discovered-businesses/${o}`,{method:"PATCH",body:JSON.stringify({outreachStatus:a})})))).filter(o=>o.status==="rejected").length;return{updated:s.length-l,failed:l}},onSuccess:s=>{g.invalidateQueries({queryKey:["/api/business-lists"]}),y([]),r({title:`Updated ${s.updated} businesses${s.failed>0?` (${s.failed} failed)`:""}`})},onError:()=>{r({title:"Failed to update businesses",variant:"destructive"})}}),[as,ge]=c.useState(!1),ve=v({mutationFn:async s=>f(`/api/business-lists/${i.id}/businesses`,{method:"POST",body:JSON.stringify(s)}),onSuccess:()=>{var s;g.invalidateQueries({queryKey:["/api/business-lists"]}),r({title:"Business added to list"}),le(!1),L({name:"",phone:"",email:"",website:"",address:"",city:"",state:"",zipCode:"",industry:((s=i.searchParams)==null?void 0:s.industry)||"",notes:""})},onError:()=>{r({title:"Failed to add business",variant:"destructive"})}}),Qe=()=>{if(!b.name.trim()||!b.industry.trim()){r({title:"Name and industry are required",variant:"destructive"});return}ve.mutate(b)},t=(s,a)=>{X.mutate({businessId:s,updates:{outreachStatus:a}})},n=s=>{X.mutate({businessId:s,updates:{notes:qe}}),G(null)},T=(s,a,m,l)=>{if(be(s),Se(a),m){const o=new Date(m);re(o),V(o.toTimeString().slice(0,5))}else re(void 0),V("09:00");if(l)de(l);else{const o=[a.name,a.phone?`Phone: ${a.phone}`:null,a.email?`Email: ${a.email}`:null,a.website?`Website: ${a.website}`:null,a.address?`Address: ${a.address}${a.city?`, ${a.city}`:""}${a.state?`, ${a.state}`:""} ${a.zipCode||""}`.trim():null,a.industry?`Industry: ${a.industry}`:null,a.rating?`Rating: ${a.rating}${a.reviewCount?` (${a.reviewCount} reviews)`:""}`:null,a.notes?`Notes: ${a.notes}`:null].filter(Boolean).join(`
7`);de(o)}K(!0)},S=()=>{if(!Y||!R)return;const s=Oe.split(":").map(Number),a=s[0]||9,m=s[1]||0,l=new Date(R);l.setHours(a,m,0,0),X.mutate({businessId:Y,updates:{callbackDate:l.toISOString(),callbackNotes:pe,companyId:i.companyId||null}}),K(!1),be(null),Se(null),re(void 0),V("09:00"),de("")},Fe=()=>{Y&&(X.mutate({businessId:Y,updates:{callbackDate:null,callbackNotes:"",companyId:i.companyId||null}}),K(!1),be(null),Se(null),re(void 0),V("09:00"),de(""))},Bs=s=>{s.stopPropagation(),Ce(i.name),ae(i.description||""),M(i.folderId||null),U(!0)},As=()=>{oe(i.id,ue,we,q),U(!1)},Ts=s=>{s.stopPropagation(),I(!0)},zs=()=>{Ae(i.id),I(!1)},qs=async s=>{s.stopPropagation();try{const l=(await(await fetch(`/api/business-lists/${i.id}`)).json()).businesses||[];if(l.length===0){r({title:"No businesses to copy",variant:"destructive"});return}const o=C=>{if(!C)return"";let Le=C.replace(/^[=+\s]+/,"").replace(/[^\d-() ]/g,"");const P=Le.replace(/\D/g,"");return P.length===11&&P.startsWith("1")?`1-${P.slice(1,4)}-${P.slice(4,7)}-${P.slice(7)}`:P.length===10?`${P.slice(0,3)}-${P.slice(3,6)}-${P.slice(6)}`:Le||C},ce=["Business Name","Address","City","State","ZIP","Phone","Email","Website","Rating","Reviews"],ke=l.map(C=>{var Le,P;return[C.name||"",C.address||"",C.city||"",C.state||"",C.zipCode||"",o(C.phone||""),C.email||"",C.website||"",((Le=C.rating)==null?void 0:Le.toString())||"",((P=C.reviewCount)==null?void 0:P.toString())||""]}),Os=[ce.join("	"),...ke.map(C=>C.join("	"))].join(`
8`);await navigator.clipboard.writeText(Os),Te(!0),r({title:"Copied to clipboard!",description:"Paste into Excel or Google Sheets"}),setTimeout(()=>Te(!1),2e3)}catch{r({title:"Failed to copy",variant:"destructive"})}},Ms=()=>{F.length>0&&(Xe(F),y([]))};return e.jsxs(fe,{className:"w-full",children:[e.jsx(Je,{className:"cursor-pointer",onClick:()=>p(!se),children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(We,{className:"text-lg",children:i.name}),e.jsx(rs,{children:i.description||`${i.totalFound} businesses found`})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs($,{variant:"outline",children:[i.totalFound," businesses"]}),e.jsx($,{variant:"secondary",children:new Date(i.createdAt).toLocaleDateString()}),i.emailScanStatus==="scanning"&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs($,{variant:"default",className:"bg-blue-500 animate-pulse",children:["📧 Scanning... (",
8i.emailsScanned||0,"/",i.totalFound,")"]}),e.jsx(d,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:s=>{s.stopPropagation(),ie.mutate()},disabled:ie.isPending,children:"⏸ Pause"}),e.jsx(d,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs text-red-600",onClick:s=>{s.stopPropagation(),B.mutate()},disabled:B.isPending,children:"✕ Stop"})]}),i.emailScanStatus==="queued"&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs($,{variant:"outline",className:"bg-yellow-100 text-yellow-800",children:["⏳ Queued",i.scanQueuePosition?` (#${i.scanQueuePosition})`:""]}),e.jsx(d,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs text-red-600",onClick:s=>{s.stopPropagation(),B.mutate()},disabled:B.isPending,children:"✕ Cancel"})]}),i.emailScanStatus==="paused"&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs($,{variant:"outline",className:"bg-orange-100 text-orange-800",children:["⏸ Paused (",i.emailsScanned||0,"/",i.totalFound,")"]}),e.jsx(d,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs text-green-600",onClick:s=>{s.stopPropagation(),Z.mutate()},disabled:Z.isPending,children:"▶ Resume"}),e.jsx(d,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs text-red-600",onClick:s=>{s.stopPropagation(),B.mutate()},disabled:B.isPending,children:"✕ Stop"})]}),i.emailScanStatus==="canceled"&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs($,{variant:"outline",className:"bg-gray-100 text-gray-600",children:["⏹ Scan stopped (",i.emailsFound||0," found)"]}),e.jsx(d,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:s=>{s.stopPropagation(),D.mutate()},disabled:D.isPending,children:"🔄 Restart"})]}),i.emailScanStatus==="complete"&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs($,{variant:"default",className:"bg-green-500",children:["✅ ",i.emailsFound||0," emails found"]}),e.jsx(d,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:s=>{s.stopPropagation(),D.mutate()},disabled:D.isPending,children:"🔄 Rescan"})]}),i.emailScanStatus==="error"&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx($,{variant:"destructive",children:"❌ Scan error"}),e.jsx(d,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:s=>{s.stopPropagation(),D.mutate()},disabled:D.isPending,children:"🔄 Retry"})]}),i.emailScanStatus==="pending"&&e.jsx($,{variant:"outline",className:"text-muted-foreground",children:"📧 Email scan pending"}),u.length>0&&e.jsxs(ks,{children:[e.jsx(Ls,{asChild:!0,onClick:s=>s.stopPropagation(),children:e.jsxs(d,{variant:"outline",size:"sm",children:[e.jsx(Ye,{className:"w-4 h-4 mr-1"}),i.folderId?((vs=u.find(s=>s.id===i.folderId))==null?void 0:vs.name)||"Folder":"Move to..."]})}),e.jsxs(Ds,{align:"end",onClick:s=>s.stopPropagation(),children:[i.folderId&&e.jsxs(e.Fragment,{children:[e.jsx(Ze,{onClick:()=>oe(i.id,void 0,void 0,null),children:"Remove from folder"}),e.jsx(Ps,{})]}),u.filter(s=>s.id!==i.folderId).map(s=>e.jsxs(Ze,{onClick:()=>oe(i.id,void 0,void 0,s.id),children:[e.jsx(Ye,{className:"w-4 h-4 mr-2"}),s.name]},s.id))]})]}),e.jsxs(d,{variant:"outline",size:"sm",onClick:qs,"data-testid":`button-copy-${i.id}`,children:[z?e.jsx(fs,{className:"w-4 h-4 mr-1"}):e.jsx(st,{className:"w-4 h-4 mr-1"}),z?"Copied!":"Copy"]}),e.jsxs(d,{variant:"outline",size:"sm",onClick:s=>{s.stopPropagation(),window.location.href=`/api/business-lists/${i.id}/export`},"data-testid":`button-export-${i.id}`,children:[e.jsx(Ss,{className:"w-4 h-4 mr-1"}),"Export"]}),e.jsx(d,{variant:"outline",size:"sm",onClick:Bs,"data-testid":`button-edit-${i.id}`,children:e.jsx($s,{className:"w-4 h-4"})}),e.jsx(d,{variant:"outline",size:"sm",onClick:Ts,className:"text-red-600 hover:text-red-700","data-testid":`button-delete-${i.id}`,children:e.jsx(Ue,{className:"w-4 h-4"})})]})]})}),e.jsx(Pe,{open:te,onOpenChange:U,children:e.jsxs($e,{onClick:s=>s.stopPropagation(),children:[e.jsx(Ie,{children:e.jsx(Ee,{children:"Edit List"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(h,{children:"List Name"}),e.jsx(N,{value:ue,onChange:s=>Ce(s.target.value),placeholder:"Enter list name"})]}),e.jsxs("div",{children:[e.jsx(h,{children:"Description (optional)"}),e.jsx(Ne,{value:we,onChange:s=>ae(s.target.value),placeholder:"Add a description"})]}),e.jsxs("div",{children:[e.jsx(h,{children:"Folder"}),e.jsxs(_,{value:(q==null?void 0:q.toString())||"none",onValueChange:s=>M(s==="none"?null:Number(s)),children:[e.jsx(H,{children:e.jsx(J,{placeholder:"Select a folder"})}),e.jsxs(W,{children:[e.jsx(x,{value:"none",children:"No folder"}),u.map(s=>e.jsx(x,{value:s.id.toString(),children:s.name},s.id))]})]}),u.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Create folders in the sidebar to organize lists"})]})]}),e.jsxs(Be,{children:[e.jsx(d,{variant:"outline",onClick:()=>U(!1),children:"Cancel"}),e.jsx(d,{onClick:As,disabled:!ue.trim(),children:"Save Changes"})]})]})}),e.jsx(cs,{open:me,onOpenChange:I,children:e.jsxs(os,{onClick:s=>s.stopPropagation(),children:[e.jsxs(us,{children:[e.jsx(ms,{children:"Delete Business List?"}),e.jsxs(hs,{children:['This will permanently delete "',i.name,'" and all ',i.totalFound," businesses in it. This action cannot be undone."]})]}),e.jsxs(xs,{children:[e.jsx(ps,{children:"Cancel"}),e.jsx(js,{onClick:zs,className:"bg-red-600 hover:bg-red-700",children:"Delete"})]})]})}),e.jsx(cs,{open:as,onOpenChange:ge,children:e.jsxs(os,{onClick:s=>
8s.stopPropagation(),children:[e.jsxs(us,{children:[e.jsxs(ms,{children:["Delete ",F.length," Businesses?"]}),e.jsxs(hs,{children:["This will permanently remove ",F.length," selected businesses from this list. This action cannot be undone."]})]}),e.jsxs(xs,{children:[e.jsx(ps,{children:"Cancel"}),e.jsx(js,{onClick:()=>{je.mutate(F),ge(!1)},className:"bg-red-600 hover:bg-red-700",children:je.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ee,{className:"w-4 h-4 mr-2 animate-spin"}),"Deleting..."]}):"Delete All"})]})]})}),e.jsx(Pe,{open:A,onOpenChange:le,children:e.jsxs($e,{onClick:s=>s.stopPropagation(),className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(Ie,{children:[e.jsx(Ee,{children:"Add Business Manually"}),e.jsx(Ge,{children:"Add a business to this list that wasn't found in search results."})]}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx(h,{htmlFor:"business-name",children:"Business Name *"}),e.jsx(N,{id:"business-name",value:b.name,onChange:s=>L(a=>({...a,name:s.target.value})),placeholder:"Enter business name"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(h,{htmlFor:"business-industry",children:"Industry *"}),e.jsx(N,{id:"business-industry",value:b.industry,onChange:s=>L(a=>({...a,industry:s.target.value})),placeholder:"e.g., Plumber, Electrician"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"business-phone",children:"Phone"}),e.jsx(N,{id:"business-phone",value:b.phone,onChange:s=>L(a=>({...a,phone:s.target.value})),placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"business-email",children:"Email"}),e.jsx(N,{id:"business-email",type:"email",value:b.email,onChange:s=>L(a=>({...a,email:s.target.value})),placeholder:"[email protected]"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(h,{htmlFor:"business-website",children:"Website"}),e.jsx(N,{id:"business-website",value:b.website,onChange:s=>L(a=>({...a,website:s.target.value})),placeholder:"https://example.com"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(h,{htmlFor:"business-address",children:"Address"}),e.jsx(N,{id:"business-address",value:b.address,onChange:s=>L(a=>({...a,address:s.target.value})),placeholder:"123 Main St"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"business-city",children:"City"}),e.jsx(N,{id:"business-city",value:b.city,onChange:s=>L(a=>({...a,city:s.target.value})),placeholder:"City"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"business-state",children:"State"}),e.jsx(N,{id:"business-state",value:b.state,onChange:s=>L(a=>({...a,state:s.target.value})),placeholder:"WI"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"business-zip",children:"ZIP"}),e.jsx(N,{id:"business-zip",value:b.zipCode,onChange:s=>L(a=>({...a,zipCode:s.target.value})),placeholder:"12345"})]})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(h,{htmlFor:"business-notes",children:"Notes"}),e.jsx(Ne,{id:"business-notes",value:b.notes,onChange:s=>L(a=>({...a,notes:s.target.value})),placeholder:"Any additional notes about this business...",className:"min-h-[80px]"})]})]})}),e.jsxs(Be,{children:[e.jsx(d,{variant:"outline",onClick:()=>le(!1),children:"Cancel"}),e.jsx(d,{onClick:Qe,disabled:ve.isPending,children:ve.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ee,{className:"w-4 h-4 mr-2 animate-spin"}),"Adding..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ds,{className:"w-4 h-4 mr-2"}),"Add Business"]})})]})]})}),se&&e.jsxs(ye,{children:[ze&&e.jsxs("div",{className:"flex items-center justify-center py-8",children:[e.jsx(ee,{className:"w-6 h-6 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading businesses..."})]}),O&&e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"Unable to load business details. Please try again."}),e.jsx(d,{variant:"outline",size:"sm",className:"mt-2",onClick:()=>p(!1),children:"Close"})]}),k&&!ze&&!O&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[e.jsx("h4",{className:"font-medium",children:"Businesses in this list"}),e.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:F.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs(d,{onClick:Ms,size:"sm","data-testid":`button-convert-${i.id}`,children:[e.jsx(Hs,{className:"w-4 h-4 mr-2"}),"Convert (",F.length,")"]}),e.jsxs(_,{onValueChange:s=>{Ke.mutate({businessIds:F,status:s})},children:[e.jsx(H,{className:"w-[140px] h-8 text-xs",children:e.jsx(J,{placeholder:"Change Status"})}),e.jsx(W,{children:Object.entries(_e).map(([s,{label:a,color:m}])=>e.jsx(x,{value:s,children:e.jsx("span",{className:`px-2 py-0.5 rounded text-xs ${m}`,children:a})},s))})]}),e.jsxs(d,{variant:"destructive",size:"sm",onClick:()=>ge(!0),disabled:je.isPending,children:[e.jsx(Ue,{className:"w-4 h-4 mr-1"}),"Delete (",F.length,")"]})]})})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("div",{className:"relative",children:[e.jsx(De,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(N,{type:"text",placeholder:"Search businesses...",value:j,onChange:s=>ss(s.target.value),className:"w-[200px] h-8 pl-8 text-sm"})]}),e.jsxs(_,{value:he,onValueChange:w,children:[e.jsx(H,{className:"w-[160px] h-8",children:e.jsx(J,{placeholder:"Filter by status"})}),e.jsxs(W,{children:[e.jsx(x,{value:"all",children:"All Statuses"}
8),Object.entries(_e).map(([s,{label:a}])=>e.jsx(x,{value:s,children:a},s))]})]}),e.jsxs(_,{value:E,onValueChange:es,children:[e.jsx(H,{className:"w-[150px] h-8",children:e.jsx(J,{placeholder:"Sort by"})}),e.jsxs(W,{children:[e.jsx(x,{value:"date_desc",children:"Newest First"}),e.jsx(x,{value:"date_asc",children:"Oldest First"}),e.jsx(x,{value:"name_asc",children:"Name A-Z"}),e.jsx(x,{value:"name_desc",children:"Name Z-A"}),e.jsx(x,{value:"rating_desc",children:"Highest Rated"}),e.jsx(x,{value:"status",children:"By Status"})]})]}),e.jsx(d,{variant:"outline",size:"sm",className:"h-8",onClick:()=>{const a=((k==null?void 0:k.businesses)||[]).filter(l=>{if(!j.trim())return!0;const o=j.toLowerCase();return(l.name||"").toLowerCase().includes(o)||(l.address||"").toLowerCase().includes(o)||(l.city||"").toLowerCase().includes(o)||(l.state||"").toLowerCase().includes(o)||(l.phone||"").toLowerCase().includes(o)||(l.email||"").toLowerCase().includes(o)||(l.website||"").toLowerCase().includes(o)||(l.notes||"").toLowerCase().includes(o)}).map(l=>typeof l.id=="number"?l.id:Number(l.id)).filter(l=>!isNaN(l)),m=a.every(l=>F.includes(l));y(m?[]:a)},children:(()=>{const a=((k==null?void 0:k.businesses)||[]).filter(l=>{if(!j.trim())return!0;const o=j.toLowerCase();return(l.name||"").toLowerCase().includes(o)||(l.address||"").toLowerCase().includes(o)||(l.city||"").toLowerCase().includes(o)||(l.state||"").toLowerCase().includes(o)||(l.phone||"").toLowerCase().includes(o)||(l.email||"").toLowerCase().includes(o)||(l.website||"").toLowerCase().includes(o)||(l.notes||"").toLowerCase().includes(o)}).map(l=>typeof l.id=="number"?l.id:Number(l.id)).filter(l=>!isNaN(l));return a.length>0&&a.every(l=>F.includes(l))?"Deselect All":"Select All"})()}),e.jsxs(d,{variant:"outline",size:"sm",className:"h-8",onClick:()=>le(!0),children:[e.jsx(ds,{className:"w-4 h-4 mr-1"}),"Add Business"]}),e.jsx("span",{className:"text-sm text-muted-foreground ml-auto",children:(()=>{const s=k.businesses||[],a=j.trim()?s.filter(m=>{const l=j.toLowerCase();return(m.name||"").toLowerCase().includes(l)||(m.address||"").toLowerCase().includes(l)||(m.city||"").toLowerCase().includes(l)||(m.state||"").toLowerCase().includes(l)||(m.phone||"").toLowerCase().includes(l)||(m.email||"").toLowerCase().includes(l)||(m.website||"").toLowerCase().includes(l)||(m.notes||"").toLowerCase().includes(l)}).length:s.length;return j.trim()?`${a} of ${s.length} businesses`:`${s.length} businesses`})()})]})]}),e.jsx("div",{className:"space-y-2",children:(k.businesses||[]).filter(s=>{if(!j.trim())return!0;const a=j.toLowerCase();return(s.name||"").toLowerCase().includes(a)||(s.address||"").toLowerCase().includes(a)||(s.city||"").toLowerCase().includes(a)||(s.state||"").toLowerCase().includes(a)||(s.phone||"").toLowerCase().includes(a)||(s.email||"").toLowerCase().includes(a)||(s.website||"").toLowerCase().includes(a)||(s.notes||"").toLowerCase().includes(a)}).map(s=>{const a=typeof s.id=="number"?s.id:Number(s.id);if(!s||isNaN(a))return null;const m=s.outreachStatus||"not_contacted",l=_e[m];return e.jsxs("div",{className:"p-3 border rounded space-y-2","data-testid":`list-business-${a}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex items-start space-x-3 flex-1",children:[e.jsx(Fs,{className:"mt-1",checked:F.includes(a),onCheckedChange:o=>{y(o?ce=>[...ce,a]:ce=>ce.filter(ke=>ke!==a))},disabled:s.isConverted,"data-testid":`checkbox-convert-${a}`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium",children:s.name||"Unknown Business"}),s.addedManually&&e.jsx($,{variant:"secondary",className:"text-xs",children:"Manual"}),s.isConverted&&e.jsx($,{variant:"outline",className:"text-green-600",children:"Already Client"}),s.rating&&e.jsx("span",{className:"text-sm text-yellow-600",children:Is(s.rating)})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[s.address||"",s.city&&`, ${s.city}`,s.state&&`, ${s.state}`,s.zipCode&&` ${s.zipCode}`]}),e.jsxs("div",{className:"text-sm text-muted-foreground flex flex-wrap gap-2 mt-1",children:[s.phone&&e.jsxs("span",{children:["📞 ",Es(s.phone)]}),s.email&&e.jsxs("a",{href:`mailto:${s.email}`,className:"text-blue-600 hover:underline",children:["✉️ ",s.email]}),s.website&&e.jsx("a",{href:String(s.website).startsWith("http")?s.website:`https://${s.website}`,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline",children:"🌐 Website"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs(d,{variant:s.callbackDate?"secondary":"outline",size:"sm",className:`h-8 gap-1 text-xs ${s.callbackDate?"bg-blue-100 hover:bg-blue-200":""}`,onClick:()=>T(a,s,s.callbackDate,s.callbackNotes),children:[e.jsx(ns,{className:"w-3 h-3"}),s.callbackDate?ls(new Date(s.callbackDate),"MMM d"):"Callback"]}),e.jsxs(_,{value:m,onValueChange:o=>t(a,o),children:[e.jsx(H,{className:"w-[160px] h-8 text-xs",children:e.jsx(J,{children:e.jsx("span",{className:`px-2 py-0.5 rounded text-xs ${l.color}`,children:l.label})})}),e.jsx(W,{children:Object.entries(_e).map(([o,{label:ce,color:ke}])=>e.jsx(x,{value:o,children:e.jsx("span",{className:`px-2 py-0.5 rounded text-xs ${ke}`,children:ce})},o))})]}),e.jsx(d,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-muted-foreground hover:text-destructive",onClick:()=>ts.mutate(a),children:e.jsx(Ue,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"pl-8",children:ne===a?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ne,{value:qe,onChange:o=>xe(o.target.value),placeholder:"Add notes about this business...",className:"text-sm min-h-[60
8px]"}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(d,{size:"sm",onClick:()=>n(a),children:e.jsx(fs,{className:"w-4 h-4"})}),e.jsx(d,{size:"sm",variant:"outline",onClick:()=>G(null),children:"Cancel"})]})]}):e.jsx("div",{className:"text-sm text-muted-foreground cursor-pointer hover:bg-muted/50 p-2 rounded border border-dashed border-muted-foreground/30",onClick:()=>{G(a),xe(s.notes||"")},children:s.notes||"Click to add notes..."})}),s.callbackDate&&e.jsx("div",{className:"pl-8 text-sm",children:e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-blue-50 rounded border border-blue-200",children:[e.jsx(Js,{className:"w-4 h-4 text-blue-600"}),e.jsxs("span",{className:"text-blue-800 font-medium",children:["Callback: ",ls(new Date(s.callbackDate),"MMM d, yyyy h:mm a")]})]})})]},a)})})]}),e.jsx(Pe,{open:Me,onOpenChange:K,children:e.jsxs($e,{className:"max-w-md",children:[e.jsxs(Ie,{children:[e.jsxs(Ee,{className:"flex items-center gap-2",children:[e.jsx(ns,{className:"w-5 h-5"}),"Schedule Callback"]}),e.jsx(Ge,{children:"Set a callback date and it will appear in your marketing calendar"})]}),e.jsxs("div",{className:"space-y-4",children:[Q&&e.jsxs("div",{className:"p-3 bg-gray-50 rounded-lg border text-sm",children:[e.jsx("div",{className:"font-medium text-gray-900",children:Q.name}),Q.phone&&e.jsx("div",{className:"text-gray-600",children:Q.phone}),Q.industry&&e.jsx("div",{className:"text-gray-500",children:Q.industry})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{children:"Callback Date"}),e.jsxs(Ws,{children:[e.jsx(Us,{asChild:!0,children:e.jsxs(d,{variant:"outline",className:"w-full justify-start text-left font-normal",children:[e.jsx(ns,{className:"mr-2 h-4 w-4"}),R?ls(R,"MMM d, yyyy"):"Pick date"]})}),e.jsx(Zs,{className:"w-auto p-0",align:"start",children:e.jsx(Gs,{mode:"single",selected:R,onSelect:re,initialFocus:!0,disabled:s=>s<new Date(new Date().setHours(0,0,0,0))})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{children:"Time"}),e.jsx(N,{type:"time",value:Oe,onChange:s=>V(s.target.value),className:"h-10"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{children:"Business Details & Notes"}),e.jsx(Ne,{placeholder:"Business info and callback notes...",value:pe,onChange:s=>de(s.target.value),className:"min-h-[150px] text-sm"})]})]}),e.jsxs(Be,{className:"flex justify-between",children:[e.jsx("div",{children:R&&e.jsx(d,{variant:"ghost",onClick:Fe,className:"text-destructive hover:text-destructive",children:"Clear Callback"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(d,{variant:"outline",onClick:()=>K(!1),children:"Cancel"}),e.jsx(d,{onClick:S,disabled:!R||X.isPending,children:X.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ee,{className:"w-4 h-4 mr-2 animate-spin"}),"Saving..."]}):"Save Callback"})]})]})]})})]})]})}export{yt as default};

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.