PageSourceSearch

https://luxurypickletravel.com/assets/PartnerPipelinePage-geRtzMVu.js

js luxurypickletravel.com collected 2026-10-04 23:46:43 UTC 32,653 bytes, 6 lines download raw bytes

1import{l as Je,r as C,c as Xe,n as Ze,m as et,o as tt,p as O,j as e,B as f,ab as Te,I as y,M as at,L as je,ae as nt,D as re,t as ie,v as se,w as oe,A as le,$ as ce,s as rt}from"./index-BtgOf3Tb.js";import{A as it,a as st,b as ot,c as lt,d as ct,e as dt,f as mt,g as ut}from"./alert-dialog-Be1YTd2J.js";import{B as Me}from"./badge-CaVOQWHq.js";import{C as W,a as pt,b as ht,d as gt,c as me}from"./card-DK9lVuyV.js";import{C as Le}from"./checkbox-AUUl_DcP.js";import{L as j}from"./label-BUfYQ1iF.js";import{C as ft}from"./ContactSearchPicker-DQtzzQlj.js";import{j as xt,e as Y,n as Be}from"./entityTagging-Bcy5J7DP.js";import{i as _e,a as yt,n as jt,f as vt}from"./taggedContacts-fvmcUbj5.js";import{p as de,a as Ct}from"./partnerReferrals-TjtkwQAx.js";import{B as wt}from"./building-2-CsBi8bGe.js";import{S as _t}from"./search-CZr9pdxd.js";import{T as Pt}from"./trash-2-BKpiQMJj.js";import{S as ze}from"./square-pen-D1eK_sNa.js";import{E as De}from"./external-link-ClCUyBi7.js";import{L as bt}from"./link-2-DrzE-G38.js";import{C as Nt}from"./copy-D762G1HJ.js";import"./command--VceFZhb.js";import"./extends-CF3RwP-h.js";import"./popover-Bl7j6can.js";import"./useContacts-zaRJ-UFD.js";import"./trackAction-DkLH4oim.js";import"./chevrons-up-down-C-0A1tuu.js";import"./useClientGroups-Dv7C9dZB.js";/**
2 * @license lucide-react v0.515.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 kt=[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Oe=Je("earth",kt),p=rt,ve=yt,G={full_name:"",email:"",phone:"",company_name:"",company_website:"",company_industry:"",company_email:"",company_phone:""},we=jt,L=_=>{const F=new Map;for(const q of _||[]){const A=Be(String(q||""));if(!A)continue;const J=A.toLowerCase();F.has(J)||F.set(J,A)}return Array.from(F.values()).sort((q,A)=>q.localeCompare(A))},V=_=>we(_).some(F=>_e(F)),Ke=_=>_.toLowerCase()==="agent"?"default":_e(_)||_.toLowerCase().includes("partner")?"secondary":"outline",Xt=()=>{const[_,F]=C.useState(""),[q,A]=C.useState(new Set),[J,Pe]=C.useState(!1),[P,K]=C.useState(null),[X,Z]=C.useState(null),[be,ee]=C.useState(!1),[H,$]=C.useState({full_name:"",email:"",phone:""}),[Qe,te]=C.useState(!1),[N,k]=C.useState(G),[U,ae]=C.useState(null),[S,T]=C.useState(G),{toast:v}=Xe(),g=Ze(),{currentOrg:h}=et(),{data:Ie,isLoading:$e,error:Ne}=tt({queryKey:["partners-directory"],queryFn:async()=>{const[t,a,o,i,r,s]=await Promise.all([p.from("companies").select("id, name, industry, website, email, phone, city, state, country, relationship_type, tags, custom_fields").order("name",{ascending:!0}),vt(ve),p.from("commissions").select("user_id").not("user_id","is",null),p.from("entity_tag_assignments").select("entity_id, tag_id").eq("entity_type","company"),p.from("tags").select("id, name, slug").eq("is_active",!0),p.from("partner_referral_profiles").select("id, contact_id, slug, is_active")]);if(t.error)throw t.error;if(o.error)throw o.error;if(i.error)throw i.error;if(r.error)throw r.error;if(s.error)throw s.error;const l=new Map;(r.data||[]).forEach(n=>{n.id&&l.set(n.id,Be(String(n.name||n.slug||"")))});const c=new Map;(i.data||[]).forEach(n=>{const x=l.get(n.tag_id);if(!n.entity_id||!x)return;const I=c.get(n.entity_id)||[];I.push(x),c.set(n.entity_id,I)});const d=t.data||[],u=d.map(n=>({...n,tags:L([...n.tags||[],...c.get(n.id)||[]])})).filter(n=>V(n.tags)),m=a.filter(n=>{const x=n.normalized_tags||we(n.tags);return V(x)}),w=new Set((o.data||[]).map(n=>n.user_id).filter(Boolean)),M=new Map(d.map(n=>[n.id,n])),z=new Map(u.map(n=>[n.id,n])),R=new Map((s.data||[]).filter(n=>n.contact_id).map(n=>[n.contact_id,n])),D=new Set,b=m.map(n=>{n.company_id&&D.add(n.company_id);const x=n.company_id&&M.get(n.company_id)||null,I=x?{...x,tags:L([...x.tags||[],...c.get(x.id)||[]])}:null,Ae=L([...n.normalized_tags||[],...n.tags||[]]);return{id:`contact-${n.id}`,company:I,contact:n,tags:L([...(I==null?void 0:I.tags)||[],...Ae,...n.user_id&&w.has(n.user_id
6)?["Commission Recipient"]:[]]),contactTags:Ae,hasCommission:!!(n.user_id&&w.has(n.user_id)),referralProfile:R.get(n.id)||null}}),Q=u.filter(n=>!D.has(n.id)).map(n=>({id:`company-${n.id}`,company:z.get(n.id)||n,contact:null,tags:L(n.tags),contactTags:[],hasCommission:!1,referralProfile:null}));return[...b,...Q]}}),ke=O({mutationFn:async t=>{if(!h)throw new Error("No organization selected");const a=L([...t.tags||[],"Agent","Partner"]),{error:o}=await p.from("contacts").update({tags:a,custom_fields:{...t.custom_fields||{},is_agent:!0,agent_designated_at:new Date().toISOString()}}).eq("id",t.id);if(o)throw o;await Y(h.id,"contact",t.id,"Agent",{method:"partner-page",entityName:t.full_name||t.email||"Contact"}),await Y(h.id,"contact",t.id,"Partner",{method:"partner-page",entityName:t.full_name||t.email||"Contact"})},onSuccess:()=>{g.invalidateQueries({queryKey:["partners-directory"]}),g.invalidateQueries({queryKey:["partner-performance-summary"]}),v({title:"Contact marked as agent"})},onError:t=>{v({title:"Could not mark contact as agent",description:t.message||"Please try again.",variant:"destructive"})}}),Se=O({mutationFn:async({contact:t,slugOverride:a})=>{if(!h)throw new Error("No organization selected");const o=a||Ct(t.full_name,t.email),i=t.full_name||t.email||"LPT Partner",{error:r}=await p.from("partner_referral_profiles").upsert({org_id:h.id,contact_id:t.id,slug:o,display_name:i,public_email:t.email,headline:`Luxury pickleball travel, introduced by ${i}`,bio:"Explore curated Luxury Pickle Travel weeks through this partner link. Every inquiry submitted here is routed back to the partner who introduced you.",is_active:!0,updated_at:new Date().toISOString()},{onConflict:"org_id,slug"});if(r)throw r;return o},onSuccess:t=>{g.invalidateQueries({queryKey:["partners-directory"]}),v({title:"Partner page is active",description:de(t)})},onError:t=>{v({title:"Could not activate partner page",description:t.message||"Please try again.",variant:"destructive"})}}),Ee=async t=>{if(!h)throw new Error("No organization selected");const a=L([...t.tags||[],"Partner"]),{error:o}=await p.from("contacts").update({tags:a}).eq("id",t.id);if(o)throw o;await Y(h.id,"contact",t.id,"Partner",{method:"partner-page",entityName:t.full_name||t.email||"Contact"})},ue=O({mutationFn:async({company:t,contactId:a})=>{if(!h)throw new Error("No organization selected");const{data:o,error:i}=await p.from("contacts").select("id, full_name, email, phone, mobile, job_title, company_id, user_id, tags, custom_fields").eq("id",a).single();if(i)throw i;const{error:r}=await p.from("contacts").update({company_id:t.id}).eq("id",a);if(r)throw r;return await Ee({...o,company_id:t.id}),o},onSuccess:()=>{g.invalidateQueries({queryKey:["partners-directory"]}),g.invalidateQueries({queryKey:["contacts"]}),g.invalidateQueries({queryKey:["company-contacts"]}),K(null),Z(null),v({title:"Contact linked",description:"Partner company now has a contact."})},onError:t=>{v({title:"Could not link contact",description:t.message||"Please try again.",variant:"destructive"})}}),pe=O({mutationFn:async({company:t,full_name:a,email:o,phone:i})=>{if(!h)throw new Error("No organization selected");const r=a.trim()||t.name||"Partner contact",s=r.split(/\s+/),l=s[0]||r,c=s.slice(1).join(" ")||"",{data:d,error:u}=await p.from("contacts").insert({org_id:h.id,full_name:r,first_name:l,last_name:c||null,email:o.trim()||t.email||null,mobile:i.trim()||t.phone||null,company_id:t.id,contact_type:"partner",tags:["Partner"]}).select("id, full_name, email, phone, mobile, job_title, company_id, user_id, tags, custom_fields").single();if(u)throw u;return await Y(h.id,"contact",d.id,"Partner",{method:"partner-page",entityName:d.full_name||d.email||"Contact"}),d},onSuccess:()=>{g.invalidateQueries({queryKey:["partners-directory"]}),g.invalidateQueries({queryKey:["contacts"]}),g.invalidateQueries({queryKey:["company-contacts"]}),ee(!1),K(null),$({full_name:"",email:"",phone:""}),v({title:"Partner contact created",description:"Company is no longer “Needs contact”."})},onError:t=>{v({title:"Could not create contact",description:t.message||"Please try again.",variant:"destructive"})}}),he=O({mutationFn:async({full_name:t,email:a,phone:o,company_name:i,company_website:r,company_industry:s,company_email:l,company_phone:c})=>{if(!h)throw new Error("No organization selected");const d=t.trim();if(!d)throw new Error("Full name is required");let u=null;const m=i.trim();if(m){const{data:b,error:Q}=await p.from("companies").select("id, name, tags").eq("org_id",h.id).ilike("name",m).limit(1).maybeSingle();if(Q)throw Q;if(b){u=b.id;const n={};if(V(b.tags)||(n.tags=L([...b.tags||[],"Partner"])),r!=null&&r.trim()&&(n.website=r.trim()),s!=null&&s.trim()&&(n.industry=s.trim()),l!=null&&l.trim()&&(n.email=l.trim()),c!=null&&c.trim()&&(n.phone=c.trim()),Object.keys(n).length>0){const{error:x}=await p.from("companies").update(n).eq("id",b.id);if(x)throw x}}else{const{data:n,error:x}=await p.from("companies").insert({org_id:h.id,name:m,tags:["Partner"],website:(r==null?void 0:r.trim())||null,industry:(s==null?void 0:s.trim())||null,email:(l==null?void 0:l.trim())||null,phone:(c==null?void 0:c.trim())||null}).select("id").single();if(x)throw x;u=n.id}}const w=d.split(/\s+/),M=w[0]||d,z=w.slice(1).join(" ")||"",{data:R,error:D}=await p.from("contacts").insert({org_id:h.id,full_name:d,first_name:M,last_name:z||null,email:a.trim()||null,mobile:o.trim()||null,company_id:u,contact_type:"partner",tags:["Partner"]}).select("id, full_name, email, phone, mobile, job_title, company_id, user_id, tags, custom_fields").single();if(D)throw D;return await Y(h.id,"contact",R.id,"Partner",{method:"partner-page",entityName:R.full_name||R.email||"Contact"}),R},onSuccess:()=>{g.invalidateQueries({queryKey:["partners-directory"]}),g.invalidateQueries({queryKey:["contacts"]}),g.invalidateQueries({queryKey:["company-contacts"]}),g.invalidateQueries({queryKey:["companies"]}),te(!1),k(G),v({title:"Partner added",description:"New contact created and tagged Partner."})},onError:t=>{v({title:"Could not add partner",description:t.message||"Please try again.",variant:"destructive"})}}),ge=O({mutationFn:async({contact:t,full_name:a,email:o,phone:i,company_name:r,company_website:s,company_industry:l,company_email:c,company_phone:d})=>{if(!h)throw new Error("No organization selected");const u=a.trim();if(!u)throw new Error("Full name is required");let m=t.company_id;const w=r.trim();if(w){const{data:b,error:Q}=await p.from("companies").select("id, name, tags").eq("org_id",h.id).ilike("name",w).limit(1).maybeSingle();if(Q)throw Q;if(b){m=b.id;const n={};if(V(b.tags)||(n.tags=L([...b.tags||[],"Partner"])),s!=null&&s.trim()&&(n.website=s.trim()),l!=null&&l.trim()&&(n.industry=l.trim()),c!=null&&c.trim()&&(n.email=c.trim()),d!=null&&d.trim()&&(n.phone=d.trim()),Object.keys(n).length>0){const{error:x}=await p.from("companies").update(n).eq("id",b.id);if(x)throw x}}else{const{data:n,error:x}=await p.from("companies").insert({org_id:h.id,name:w,tags:["Partner"],website:(s==null?void 0:s.trim())||null,industry:(l==null?void 0:l.trim())||null,email:(c==null?void 0:c.trim())||null,phone:(d==null?void 0:d.trim())||null}).select("id").single();if(x)throw x;m=n.id}}else m=null;const M=u.split(/\s+/),z=M[0]||u,R=M.slice(1).join(" ")||"",{error:D}=await p.from("contacts").update({full_name:u,first_name:z,last_name:R||null,email:o.trim()||null,mobile:i.trim()||null,company_id:m}).eq("id",t.id);if(D)throw D},onSuccess:()=>{g.invalidateQueries({queryKey:["partners-directory"]}),g.invalidateQueries({queryKey:["contacts"]}),g.invalidateQueries({queryKey:["company-contacts"]}),g.invalidateQueries({queryKey:["companies"]}),ae(null),v({title:"Partner updated"})},onError:t=>{v({title:"Could not update partner",description:t.message||"Please try again.",variant:"destructive"})}}),fe=O({mutationFn:async()=>
6{if(!h)throw new Error("No organization selected");let t=null;const a=await p.from("contacts").select("id, full_name, email, phone, mobile, job_title, company_id, user_id, tags, custom_fields").or("email.ilike.%rem@goexchange%,email.ilike.%rem.reynolds%,email.ilike.rem@%").limit(5);if(a.error)throw a.error;if(t=(a.data||[]).find(i=>/rem/i.test(String(i.full_name||""))||/rem@/i.test(String(i.email||"")))||(a.data||[])[0]||null,!t){const i=await p.from("contacts").select("id, full_name, email, phone, mobile, job_title, company_id, user_id, tags, custom_fields").ilike("full_name","%Rem Reynolds%").limit(1).maybeSingle();if(i.error)throw i.error;t=i.data}if(!t){const{data:i,error:r}=await p.from("contacts").insert({org_id:h.id,full_name:"Rem Reynolds",first_name:"Rem",last_name:"Reynolds",email:"[email protected]",contact_type:"partner",tags:["Partner"]}).select("id, full_name, email, phone, mobile, job_title, company_id, user_id, tags, custom_fields").single();if(r)throw r;t=i}await Ee(t);const{error:o}=await p.from("partner_referral_profiles").upsert({org_id:h.id,contact_id:t.id,slug:"rem",display_name:t.full_name||"Rem Reynolds",public_email:t.email,headline:`Luxury pickleball travel, introduced by ${t.full_name||"Rem Reynolds"}`,bio:"Explore curated Luxury Pickle Travel weeks through this partner link. Every inquiry submitted here is routed back to the partner who introduced you.",is_active:!0,updated_at:new Date().toISOString()},{onConflict:"org_id,slug"});if(o)throw o;return{contact:t,slug:"rem"}},onSuccess:({slug:t})=>{g.invalidateQueries({queryKey:["partners-directory"]}),v({title:"Rem partner page ready",description:`${window.location.origin}${de(t)}`})},onError:t=>{v({title:"Could not activate Rem’s page",description:t.message||"Please try again.",variant:"destructive"})}}),Re=O({mutationFn:async t=>{if(t.length===0)return;const{data:a,error:o}=await p.from("tags").select("id, name, slug").in("slug",Array.from(ve));if(o)throw o;const i=(a||[]).map(r=>r.id).filter(Boolean);if(i.length>0){const{error:r}=await p.from("contact_tag_assignments").delete().in("contact_id",t).in("tag_id",i);if(r)throw r}await Promise.all(t.map(async r=>{var d;const s=xe.find(u=>{var m;return((m=u.contact)==null?void 0:m.id)===r}),l=we((d=s==null?void 0:s.contact)==null?void 0:d.tags).filter(u=>!_e(u)),{error:c}=await p.from("contacts").update({tags:l}).eq("id",r);if(c)throw c;h&&await Promise.all(Array.from(ve).map(u=>xt(h.id,"contact",r,u,{method:"partner-page"})))}))},onSuccess:(t,a)=>{A(new Set),g.invalidateQueries({queryKey:["partners-directory"]}),g.invalidateQueries({queryKey:["contacts"]}),g.invalidateQueries({queryKey:["contact-tag-assignments"]}),g.invalidateQueries({queryKey:["contact-tag-assignments-bulk"]}),v({title:`Removed partner tags from ${a.length} contact${a.length===1?"":"s"}`})},onError:t=>{v({title:"Could not remove partner tags",description:t.message||"Please try again.",variant:"destructive"})}}),xe=Ie||[],E=C.useMemo(()=>{const t=_.trim().toLowerCase();return xe.filter(a=>{var o;return a.contact?V(a.contactTags):V((o=a.company)==null?void 0:o.tags)}).filter(a=>{var i,r,s,l,c,d,u,m,w;return t?[(i=a.company)==null?void 0:i.name,(r=a.company)==null?void 0:r.industry,(s=a.company)==null?void 0:s.city,(l=a.company)==null?void 0:l.state,(c=a.contact)==null?void 0:c.full_name,(d=a.contact)==null?void 0:d.email,(u=a.contact)==null?void 0:u.phone,(m=a.contact)==null?void 0:m.mobile,(w=a.contact)==null?void 0:w.job_title,a.tags.join(" ")].filter(Boolean).join(" ").toLowerCase().includes(t):!0})},[xe,_]),Fe=C.useMemo(()=>{const t=new Map,a=[];E.forEach(i=>{if(i.company){const r=`company-${i.company.id}`;t.has(r)||t.set(r,{key:r,company:i.company,contactRows:[]}),i.contact&&t.get(r).contactRows.push(i)}else i.contact&&a.push(i)});const o=Array.from(t.values()).sort((i,r)=>{var s,l;return(((s=i.company)==null?void 0:s.name)||"").localeCompare(((l=r.company)==null?void 0:l.name)||"")});return a.length>0&&o.push({key:"no-company",company:null,contactRows:a}),o},[E]),ye=C.useMemo(()=>{const t=E.filter(i=>i.contact).length,a=new Set(E.map(i=>{var r;return(r=i.company)==null?void 0:r.id}
6).filter(Boolean)).size,o=E.filter(i=>i.tags.some(r=>r.toLowerCase()==="agent")).length;return{companies:a,contacts:t,agents:o}},[E]),B=C.useMemo(()=>E.filter(t=>t.contact&&q.has(t.contact.id)),[q,E]),qe=C.useMemo(()=>Array.from(new Set(B.map(t=>{var a;return(a=t.contact)==null?void 0:a.email}).filter(Boolean))),[B]),ne=C.useMemo(()=>E.map(t=>{var a;return(a=t.contact)==null?void 0:a.id}).filter(Boolean),[E]),Ue=ne.length>0&&ne.every(t=>q.has(t)),Ve=ne.some(t=>q.has(t)),He=(t,a)=>{A(o=>{const i=new Set(o);return a?i.add(t):i.delete(t),i})},Ye=t=>{A(a=>{const o=new Set(a);return ne.forEach(i=>{t?o.add(i):o.delete(i)}),o})},Ge=()=>{if(qe.length===0){v({title:"No email addresses selected",description:"Select partner contacts with email addresses first."});return}window.location.href=`mailto:?bcc=${encodeURIComponent(qe.join(","))}`},We=async t=>{const a=`${window.location.origin}${de(t)}`;await window.navigator.clipboard.writeText(a),v({title:"Partner link copied",description:a})};return $e?e.jsx("div",{className:"p-6 text-sm text-muted-foreground",children:"Loading partners..."}):Ne?e.jsx("div",{className:"p-6",children:e.jsx(W,{children:e.jsxs(pt,{children:[e.jsx(ht,{children:"Partners could not load"}),e.jsx(gt,{children:Ne.message})]})})}):e.jsxs("div",{className:"container mx-auto space-y-5 py-6",children:[e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(wt,{className:"h-8 w-8 text-primary"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Partners"}),e.jsxs("p",{className:"text-muted-foreground",children:["Only companies and contacts tagged"," ",e.jsx("span",{className:"font-medium text-foreground",children:"Partner"})," appear here."]})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(f,{variant:"default",onClick:()=>{k(G),te(!0)},children:[e.jsx(Te,{className:"mr-2 h-4 w-4"}),"Add Partner"]}),e.jsxs(f,{variant:"outline",disabled:fe.isPending,onClick:()=>fe.mutate(),children:[e.jsx(Oe,{className:"mr-2 h-4 w-4"}),fe.isPending?"Activating Rem…":"Activate Rem’s page"]})]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsx(Ce,{label:"Companies",value:ye.companies.toString()}),e.jsx(Ce,{label:"Contacts",value:ye.contacts.toString()}),e.jsx(Ce,{label:"Agents",value:ye.agents.toString()})]}),e.jsx(W,{children:e.jsx(me,{className:"p-4",children:e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"relative w-full lg:max-w-md",children:[e.jsx(_t,{className:"pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(y,{value:_,onChange:t=>F(t.target.value),placeholder:"Search company, contact, email, or tag",className:"pl-9"})]}),B.length>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[B.length," selected"]}),e.jsxs(f,{variant:"outline",size:"sm",onClick:Ge,children:[e.jsx(at,{className:"mr-2 h-4 w-4"}),"Bulk Email"]}),e.jsxs(f,{variant:"destructive",size:"sm",onClick:()=>Pe(!0),disabled:Re.isPending,children:[e.jsx(Pt,{className:"mr-2 h-4 w-4"}),"Remove from Partners"]})]})]})})}),E.length>0&&e.jsxs("div",{className:"flex items-center gap-2 px-1",children:[e.jsx(Le,{checked:Ue||Ve&&"indeterminate",onCheckedChange:t=>Ye(t===!0),"aria-label":"Select all visible partner contacts"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Select all visible contacts"})]}),e.jsx("div",{className:"space-y-4",children:Fe.length===0?e.jsx(W,{children:e.jsx(me,{className:"py-10 text-center text-sm text-muted-foreground",children:"No partner-tagged companies or contacts found."})}):Fe.map(t=>{var a,o,i;return e.jsx(W,{children:e.jsxs(me,{className:"space-y-4 p-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 border-b pb-3 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-base font-semibold",children:((a=t.company)==null?void 0:a.name)||"Individual partners (no company)"}),(i=(o=t.company)==null?void 0:o.tags)==null?void 0:i.map(r=>e.jsx(Me,{variant:Ke(r),children:r},r)),t.company&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.contactRows.length," contact",t.contactRows.length===1?"":"s"]})]}),t.company&&e.jsx("div",{className:"text-xs text-muted-foreground",children:[t.company.industry,t.company.city,t.company.state||t.company.country].filter(
6Boolean).join(" • ")||"CRM company"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.company&&e.jsxs(f,{size:"sm",variant:"outline",onClick:()=>{var r,s;K(t.company),$({full_name:"",email:((r=t.company)==null?void 0:r.email)||"",phone:((s=t.company)==null?void 0:s.phone)||""}),ee(!0)},children:[e.jsx(Te,{className:"mr-1 h-3.5 w-3.5"}),"Add contact"]}),t.company&&e.jsx(f,{asChild:!0,size:"sm",variant:"outline",children:e.jsxs(je,{to:`/admin/crm-companies/${t.company.id}?edit=true`,children:[e.jsx(ze,{className:"mr-1 h-3.5 w-3.5"}),"Edit company"]})}),t.company&&e.jsx(f,{asChild:!0,size:"sm",variant:"outline",children:e.jsxs(je,{to:`/admin/crm-companies/${t.company.id}`,children:["Company",e.jsx(De,{className:"ml-1 h-3.5 w-3.5"})]})})]})]}),t.contactRows.length===0?e.jsxs("div",{className:"flex flex-col items-start gap-2 text-sm text-muted-foreground",children:[e.jsx("span",{children:"No partner contact linked yet."}),e.jsxs(f,{size:"sm",variant:"outline",onClick:()=>{K(t.company),Z(null)},children:[e.jsx(bt,{className:"mr-1 h-3.5 w-3.5"}),"Link existing contact"]})]}):e.jsx("div",{className:"space-y-3",children:t.contactRows.map(r=>{var u;const s=r.contact,l=r.contactTags.some(m=>m.toLowerCase()==="agent"),c=s.email||s.phone||s.mobile||"No contact info",d=[...r.contactTags,...r.hasCommission?["Commission Recipient"]:[]];return e.jsxs("div",{className:"flex flex-col gap-3 rounded-md border p-3 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Le,{checked:q.has(s.id),onCheckedChange:m=>He(s.id,m===!0),"aria-label":`Select ${s.full_name||"partner contact"}`,className:"mt-1"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:s.full_name||"Unnamed contact"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s.job_title||"Contact"}),e.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:c}),e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:(d.length?d:["untagged"]).map(m=>e.jsx(Me,{variant:Ke(m),children:m},m))})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[(u=r.referralProfile)!=null&&u.slug?e.jsxs(e.Fragment,{children:[e.jsx(f,{asChild:!0,size:"sm",variant:"outline",children:e.jsxs("a",{href:de(r.referralProfile.slug),target:"_blank",rel:"noreferrer",children:[e.jsx(Oe,{className:"mr-1 h-3.5 w-3.5"}),"Page"]})}),e.jsxs(f,{size:"sm",variant:"outline",onClick:()=>We(r.referralProfile.slug),children:[e.jsx(Nt,{className:"mr-1 h-3.5 w-3.5"}),"Copy"]})]}):e.jsx(f,{size:"sm",variant:"outline",disabled:Se.isPending,onClick:()=>Se.mutate({contact:s}),children:"Activate Page"}),e.jsxs(f,{size:"sm",variant:"outline",onClick:()=>{var m,w,M,z,R;T({full_name:s.full_name||"",email:s.email||"",phone:s.phone||s.mobile||"",company_name:((m=t.company)==null?void 0:m.name)||"",company_website:((w=t.company)==null?void 0:w.website)||"",company_industry:((M=t.company)==null?void 0:M.industry)||"",company_email:((z=t.company)==null?void 0:z.email)||"",company_phone:((R=t.company)==null?void 0:R.phone)||""}),ae(s)},children:[e.jsx(ze,{className:"mr-1 h-3.5 w-3.5"}),"Edit"]}),e.jsx(f,{asChild:!0,size:"sm",variant:"outline",children:e.jsxs(je,{to:`/admin/contacts/${s.id}`,children:["Contact",e.jsx(De,{className:"ml-1 h-3.5 w-3.5"})]})}),e.jsxs(f,{size:"sm",variant:l?"secondary":"default",disabled:l||ke.isPending,onClick:()=>ke.mutate(s),children:[e.jsx(nt,{className:"mr-1 h-3.5 w-3.5"}),l?"Agent":"Make Agent"]})]})]},r.id)})})]})},t.key)})}),e.jsx(it,{open:J,onOpenChange:Pe,children:e.jsxs(st,{children:[e.jsxs(ot,{children:[e.jsx(lt,{children:"Remove selected contacts from Partners?"}),e.jsxs(ct,{children:["This removes the partner tag from ",B.length," selected contact",B.length===1?"":"s",". It will not delete the contacts."]})]}),e.jsxs(dt,{children:[e.jsx(mt,{children:"Cancel"}),e.jsx(ut,{onClick:()=>Re.mutate(B.map(t=>t.contact.id)),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove Tags"})]})]})}),e.jsx(re,{open:!!P&&!be,onOpenChange:t=>{t||(K(null),Z(null))},children:e.jsxs(ie,{children:[e.jsxs(se,{children:[e.jsxs(oe,{children:["Link contact to ",(P==null?void 0:P.name)||"partner"]}),e.jsx(le,{children:"Pick an existing CRM contact. They’ll be tagged Partner and attached to this company."})]}),e.jsx(ft,{value:X,onChange:t=>Z(t),placeholder:"Search by name or email..."}),e.jsxs(ce,{children:[e.jsx(f,{variant:"outline",onClick:()=>K(null),children:"Cancel"}),e.jsx(f,{disabled:!X||!P||ue.isPending,onClick:()=>{!P||!X||ue.mutate({company:P,contactId:X})},children:ue.isPending?"Linking…":"Link contact"})]})]})}),e.jsx(re,{open:be,onOpenChange:t=>
6{ee(t),t||(K(null),$({full_name:"",email:"",phone:""}))},children:e.jsxs(ie,{children:[e.jsxs(se,{children:[e.jsxs(oe,{children:["Add contact for ",(P==null?void 0:P.name)||"partner"]}),e.jsx(le,{children:"Creates a Partner-tagged contact on this company so the row leaves “Needs contact.”"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(j,{htmlFor:"partner-contact-name",children:"Full name"}),e.jsx(y,{id:"partner-contact-name",value:H.full_name,onChange:t=>$(a=>({...a,full_name:t.target.value})),placeholder:"Primary contact name"})]}),e.jsxs("div",{children:[e.jsx(j,{htmlFor:"partner-contact-email",children:"Email"}),e.jsx(y,{id:"partner-contact-email",type:"email",value:H.email,onChange:t=>$(a=>({...a,email:t.target.value})),placeholder:"[email protected]"})]}),e.jsxs("div",{children:[e.jsx(j,{htmlFor:"partner-contact-phone",children:"Phone"}),e.jsx(y,{id:"partner-contact-phone",value:H.phone,onChange:t=>$(a=>({...a,phone:t.target.value})),placeholder:"Optional"})]})]}),e.jsxs(ce,{children:[e.jsx(f,{variant:"outline",onClick:()=>ee(!1),children:"Cancel"}),e.jsx(f,{disabled:!P||pe.isPending||!H.full_name.trim(),onClick:()=>{P&&pe.mutate({company:P,...H})},children:pe.isPending?"Creating…":"Create contact"})]})]})}),e.jsx(re,{open:Qe,onOpenChange:t=>{te(t),t||k(G)},children:e.jsxs(ie,{children:[e.jsxs(se,{children:[e.jsx(oe,{children:"Add Partner"}),e.jsxs(le,{children:["Creates a new contact tagged ",e.jsx("span",{className:"font-medium text-foreground",children:"Partner"})," so they show up in this directory right away. Company is optional — leave it blank for an individual partner, or enter one to link (or create) their company."]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(j,{htmlFor:"add-partner-name",children:"Full name"}),e.jsx(y,{id:"add-partner-name",value:N.full_name,onChange:t=>k(a=>({...a,full_name:t.target.value})),placeholder:"Partner's name"})]}),e.jsxs("div",{children:[e.jsx(j,{htmlFor:"add-partner-email",children:"Email"}),e.jsx(y,{id:"add-partner-email",type:"email",value:N.email,onChange:t=>k(a=>({...a,email:t.target.value})),placeholder:"[email protected]"})]}),e.jsxs("div",{children:[e.jsx(j,{htmlFor:"add-partner-phone",children:"Phone"}),e.jsx(y,{id:"add-partner-phone",value:N.phone,onChange:t=>k(a=>({...a,phone:t.target.value})),placeholder:"Optional"})]}),e.jsxs("div",{children:[e.jsx(j,{htmlFor:"add-partner-company",children:"Company (optional)"}),e.jsx(y,{id:"add-partner-company",value:N.company_name,onChange:t=>k(a=>({...a,company_name:t.target.value})),placeholder:"Existing or new company name"})]}),N.company_name.trim()&&e.jsxs("div",{className:"grid gap-3 rounded-md border p-3 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(j,{htmlFor:"add-partner-company-website",children:"Company website"}),e.jsx(y,{id:"add-partner-company-website",value:N.company_website,onChange:t=>k(a=>({...a,company_website:t.target.value})),placeholder:"https://..."})]}),e.jsxs("div",{children:[e.jsx(j,{htmlFor:"add-partner-company-industry",children:"Industry"}),e.jsx(y,{id:"add-partner-company-industry",value:N.company_industry,onChange:t=>k(a=>({...a,company_industry:t.target.value})),placeholder:"e.g. Country Club"})]}),e.jsxs("div",{children:[e.jsx(j,{htmlFor:"add-partner-company-email",children:"Company email"}),e.jsx(y,{id:"add-partner-company-email",type:"email",value:N.company_email,onChange:t=>k(a=>({...a,company_email:t.target.value})),placeholder:"[email protected]"})]}),e.jsxs("div",{children:[e.jsx(j,{htmlFor:"add-partner-company-phone",children:"Company phone"}),e.jsx(y,{id:"add-partner-company-phone",value:N.company_phone,onChange:t=>k(a=>({...a,company_phone:t.target.value})),placeholder:"Optional"})]})]})]}),e.jsxs(ce,{children:[e.jsx(f,{variant:"outline",onClick:()=>te(!1),children:"Cancel"}),e.jsx(f,{disabled:he.isPending||!N.full_name.trim(),onClick:()=>he.mutate(N),children:he.isPending?"Adding…":"Add Partner"})]})]})}),e.jsx(re,{open:!!U,onOpenChange:t=>{t||ae(null)},children:e.jsxs(ie,{children:[e.jsxs(se,{children:[e.jsxs(oe,{children:["Edit ",(U==null?void 0:U.full_name)||"partner"]}),e.jsx(le,{children:"Updates the contact's details. Change the company name to move them to a different (or brand-new) company."})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(j,{htmlFor:"edit-partner-name",children:"Full name"}),e.jsx(y,{id:"edit-partner-name",value:S.full_name,onChange:t=>T(a=>({...a,full_name:t.target.value})),placeholder:"Partner's name"})]}),e.jsxs("div",{children:[e.jsx(j,{htmlFor:"edit-partner-email",children:"Email"}),e.jsx(y,{id:"edit-partner-email",type:"email",value:S.email,onChange:t=>T(a=>({...a,email:t.target.value})),placeholder:"[email protected]"})]}),e.jsxs("div",{children:[e.jsx(j,{htmlFor:"edit-partner-phone",children:"Phone"}),e.jsx(y,{id:"edit-partner-phone",value:S.phone,onChange:t=>T(a=>({...a,phone:t.target.value})),placeholder:"Optional"})]}),e.jsxs("div",{children:[e.jsx(j,{htmlFor:"edit-partner-company",children:"Company (optional)"}),e.jsx(y,{id:"edit-partner-company",value:S.company_name,onChange:t=>T(a=>({...a,company_name:t.target.value})),placeholder:"Existing or new company name"})]}),S.company_name.trim()&&e.jsxs("div",{className:"grid gap-3 rounded-md border p-3 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx(j,{htmlFor:"edit-partner-company-website",children:"Company website"}),e.jsx(y,{id:"edit-partner-company-website",value:S.company_website,onChange:t=>T(a=>({...a,company_website:t.target.value})),placeholder:"https://..."})]}),e.jsxs("div",{children:[e.jsx(j,{htmlFor:"edit-partner-company-industry",children:"Industry"}),e.jsx(y,{id:"edit-partner-company-industry",value:S.company_industry,onChange:t=>T(a=>({...a,company_industry:t.target.value})),placeholder:"e.g. Country Club"})]}),e.jsxs("div",{children:[e.jsx(j,{htmlFor:"edit-partner-company-email",children:"Company email"}),e.jsx(y,{id:"edit-partner-company-email",type:"email",value:S.company_email,onChange:t=>T(a=>({...a,company_email:t.target.value})),placeholder:"[email protected]"})]}),e.jsxs("div",{children:[e.jsx(j,{htmlFor:"edit-partner-company-phone",children:"Company phone"}),e.jsx(y,{id:"edit-partner-company-phone",value:S.company_phone,onChange:t=>T(a=>({...a,company_phone:t.target.value})),placeholder:"Optional"})]})]})]}),e.jsxs(ce,{children:[e.jsx(f,{variant:"outline",onClick:()=>ae(null),children:"Cancel"}),e.jsx(f,{disabled:ge.isPending||!S.full_name.trim(),onClick:()=>{U&&ge.mutate({contact:U,...S})},children:ge.isPending?"Saving…":"Save changes"})]})]})})]})},Ce=({label:_,value:F})=>e.jsx(W,{children:e.jsxs(me,{className:"p-4",children:[e.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:_}),e.jsx("div",{className:"mt-2 text-2xl font-bold",children:F})]})});export{Xt 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.