PageSourceSearch

https://cerqle.ai/build/assets/Index-xQCX1kI5.js

js cerqle.ai collected 2026-10-05 11:55:43 UTC 16,412 bytes, 6 lines download raw bytes

1import{e as V,b as N,c as O,r as u,u as W,j as e,H as G,L as k,a as f}from"./app-C2EXg79X.js";import{C as J}from"./ClientLayout-Rikb5f-W.js";import{E as K}from"./EmptyState-CQMKQZ9N.js";import{U as Q}from"./upload-B9BAZEf2.js";import{D as $}from"./download-D4b8w62Y.js";import{T as Y}from"./useFlashToasts-qve_Ng0h.js";import{U as Z}from"./user-plus-C1UCq9DQ.js";import{S as ee}from"./search-D94AJfjT.js";import{T as D}from"./trash-2-BcRxS7eI.js";import{X as te}from"./x-CCAds7AG.js";import{S as E}from"./square-check-big-Bi7gzlkE.js";import{S as X}from"./square-KgnIT_Zy.js";import{U as ae}from"./users-CpdnU2pt.js";import{E as re}from"./eye-CxtfrLu8.js";import"./Topbar-D1JgOXq_.js";import"./Tabs-DPCAuzT1.js";import"./Modal-BYHVy4BV.js";import"./portal-B6nW1NMC.js";import"./sparkles-BSpl0NtD.js";import"./external-link-DIVMSVNg.js";import"./useNotificationAvailability-Y3UEq2GE.js";import"./triangle-alert-DOwHTwJM.js";import"./BrandIcons-JOYc0ZIt.js";import"./smartphone-Bf-RXnLl.js";import"./book-open-B1AacFrb.js";import"./shield-check-BL7E9bMH.js";import"./layers-BcuYRQZI.js";import"./file-text-BUr5YtOA.js";import"./image-CHFGJP7p.js";import"./messages-square-YnsIe9t0.js";import"./inbox-B7ukJlNF.js";import"./mail-DccjYMzJ.js";import"./message-circle-C8QVWdnu.js";import"./bot-BsEKmhqv.js";import"./zap-By2deb2h.js";import"./message-square-BSlOAL5q.js";import"./plus-Bn2Dy_Be.js";import"./chevron-down-DSTLwlaI.js";/**
2 * @license lucide-react v0.575.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 se=[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]],ne=V("table-2",se);function le({contact:s,size:o=8}){const{t:x}=N(),a=`${s.first_name??""} ${s.last_name??""}`.trim(),i=a?a.split(" ").map(d=>d[0]).slice(0,2).join("").toUpperCase():"?";return s.avatar_url?e.jsx("img",{src:s.avatar_url,alt:a||x("contacts_page.contact_alt"),className:`h-${o} w-${o} rounded-full object-cover flex-shrink-0`,onError:d=>{d.target.style.display="none",d.target.nextSibling.style.display="flex"}}):e.jsx("div",{className:`h-${o} w-${o} rounded-full bg-brand-100 dark:bg-brand-900/40 text-brand-700 dark:text-brand-300 flex items-center justify-center text-xs font-semibold flex-shrink-0`,children:i})}function oe({contact:s,selected:o,onToggle:x,onDelete:a}){var d;const{t:i}=N();return e.jsxs("tr",{className:`hover:bg-neutral-50 dark:hover:bg-neutral-800/50 ${o?"bg-brand-50 dark:bg-brand-900/10":""}`,children:[e.jsx("td",{className:"px-4 py-3",children:e.jsx("button",{type:"button",onClick:()=>x(s.uuid),className:"text-neutral-400 hover:text-brand-600 transition",children:o?e.jsx(E,{className:"h-4 w-4 text-brand-600"}):e.jsx(X,{className:"h-4 w-4"})})}),e.jsx("td",{className:"px-4 py-3 text-sm text-neutral-900 dark:text-neutral-100",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(le,{contact:s,size:8}),e.jsx("span",{children:s.first_name||s.last_name?`${s.first_name??""} ${s.last_name??""}`.trim():e.jsx("span",{className:"text-neutral-400",children:"—"})})]})}
6),e.jsx("td",{className:"px-4 py-3 text-sm text-neutral-600 dark:text-neutral-400",children:s.phone_e164||"—"}),e.jsx("td",{className:"px-4 py-3 text-sm text-neutral-600 dark:text-neutral-400",children:s.email||"—"}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("div",{className:"flex flex-wrap gap-1",children:(d=s.tags)==null?void 0:d.map(c=>e.jsx("span",{className:"rounded-full px-2 py-0.5 text-xs font-medium",style:{backgroundColor:c.color+"33",color:c.color},children:c.name},c.id))})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-1",children:[s.opt_in_whatsapp&&e.jsx("span",{className:"text-xs bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300 rounded px-1",children:i("contacts_page.channel_wa")}),s.opt_in_sms&&e.jsx("span",{className:"text-xs bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300 rounded px-1",children:i("contacts_page.channel_sms")}),s.opt_in_email&&e.jsx("span",{className:"text-xs bg-purple-100 text-purple-700 dark:bg-purple-900/40 dark:text-purple-300 rounded px-1",children:i("contacts_page.channel_email")})]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{href:route("client.contacts.show",s.uuid),className:"text-neutral-400 hover:text-brand-600 transition",children:e.jsx(re,{className:"h-4 w-4"})}),e.jsx("button",{type:"button",onClick:()=>a(s.uuid),className:"text-neutral-400 hover:text-red-500 transition",children:e.jsx(D,{className:"h-4 w-4"})})]})})]})}function Oe({contacts:s,filters:o,segments:x=[]}){const{t:a}=N(),{props:i}=O(),d=i.flash??{},[c,U]=u.useState(o.search??""),[T,b]=u.useState(!1),[m,g]=u.useState(new Set),v=u.useRef(),{data:l,setData:p,post:A,processing:y,reset:L}=W({first_name:"",last_name:"",phone_e164:"",email:"",opt_in_whatsapp:!0,opt_in_sms:!0,opt_in_email:!0,segment_ids:[]}),h=s.data.map(t=>t.uuid),_=h.length>0&&h.every(t=>m.has(t)),w=m.size>0,M=u.useCallback(()=>{g(_?t=>{const r=new Set(t);return h.forEach(n=>r.delete(n)),r}:t=>new Set([...t,...h]))},[_,h]),H=u.useCallback(t=>{g(r=>{const n=new Set(r);return n.has(t)?n.delete(t):n.add(t),n})},[]),S=()=>g(new Set),I=t=>{t.preventDefault(),f.get(route("client.contacts.index"),{search:c},{preserveState:!0,replace:!0})},P=t=>{confirm(a("contacts_page.confirm_delete_one"))&&f.delete(route("client.contacts.destroy",t),{preserveScroll:!0})},R=()=>{confirm(a("contacts_page.confirm_delete_selected",{count:m.size}))&&f.delete(route("client.contacts.bulk-destroy"),{data:{uuids:[...m]},preserveScroll:!0,onSuccess:()=>S()})},C=(t=!1)=>{const r=new URLSearchParams;t&&w?r.set("uuids",[...m].join(",")):o.search&&r.set("search",o.search),window.location.href=route("client.contacts.export")+(r.toString()?"?"+r.toString():"")},q=t=>{const r=t.target.files[0];if(!r)return;const n=new FormData;n.append("file",r),f.post(route("client.contacts.import"),n,{preserveScroll:!0})},z=t=>{p(r=>({...r,phone_e164:t,opt_in_whatsapp:t.trim()?r.opt_in_whatsapp:!1,opt_in_sms:t.trim()?r.opt_in_sms:!1}))},B=t=>{p(r=>({...r,email:t,opt_in_email:t.trim()?r.opt_in_email:!1}))},F=t=>{if(t.preventDefault(),!l.phone_e164.trim()&&!l.email.trim()){alert(a("contacts_page.alert_phone_or_email"));return}A(route("client.contacts.store"),{onSuccess:()=>{L(),b(!1)}})};return e.jsxs(J,{title:a("contacts_page.title"),children:[e.jsx(G,{title:a("contacts_page.title")}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("h2",{className:"text-xl font-semibold text-neutral-900 dark:text-neutral-100",children:a("contacts_page.title")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(k,{href:route("client.contacts.bulk-import"),className:"flex items-center gap-1.5 rounded-lg border border-neutral-300 dark:border-neutral-600 px-3 py-2 text-sm text-neutral-700 dark:text-neutral-300 hover:bg-neutral-50 dark:hover:bg-neutral-800 transition",children:[e.jsx(ne,{className:"h-4 w-4"})," ",a("contacts_page.bulk_import")]}),e.jsxs("button",{type:"button",onClick:()=>{var t;return(t=v.current)==null?void 0:t.click()},className:"flex items-center gap-1.5 rounded-lg border border-neutral-300 dark:border-neutral-600 px-3 py-2 text-sm text-neutral-700 dark:text-neutral-300 hover:bg-neutral-50 dark:hover:bg-neutral-800 transition",children:[e.jsx(Q,{className:"h-4 w-4"})," ",a("contacts_page.import_csv")]}),e.jsx("input",{ref:v,type:"file",accept:".csv,.txt",className:"hidden",onChange:q}),e.jsxs("button",{type:"button",onClick:()=>C(!1),className:"flex items-center gap-1.5 rounded-lg border border-neutral-300 dark:border-neutral-600 px-3 py-2 text-sm text-neutral-700 dark:text-neutral-300 hover:bg-neutral-50 dark:hover:bg-neutral-800 transition",children:[e.jsx($,{className:"h-4 w-4"})," ",a("contacts_page.export_csv")]}),e.jsxs(k,{href:route("client.segments.index"),className:"flex items-center gap-1.5 rounded-lg border border-neutral-300 dark:border-neutral-600 px-3 py-2 text-sm text-neutral-700 dark:text-neutral-300 hover:bg-neutral-50 dark:hover:bg-neutral-800 transition",children:[e.jsx(Y,{className:"h-4 w-4"})," ",a("contacts_page.segments")]}),e.jsxs("button",{type:"button",onClick:()=>b(!0),className:"flex items-center gap-1.5 rounded-lg bg-brand-600 px-3 py-2 text-sm font-medium text-white hover:bg-brand-700 transition",children:[e.jsx(Z,{className:"h-4 w-4"})," ",a("contacts_page.add_contact")]})]})]}),d.success&&e.jsx("div",{className:"rounded-lg bg-green-50 dark:bg-green-900/30 text-green-800 dark:text-green-200 px-4 py-2 text-sm",children:d.success}),e.jsxs("form",{onSubmit:I,className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ee,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-neutral-400"}),e.jsx("input",{type:"text",value:c,onChange:t=>U(t.target.value),placeholder:a("contacts_page.search_placeholder"),className:"w-full rounded-lg border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-neutral-800 pl-9 pr-3 py-2 text-sm text-neutral-900 dark:text-neutral-100 focus:outline-none focus:ring-2 focus:ring-brand-500"})]}),e.jsx("button",{type:"submit",className:"rounded-lg bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700 transition",children:a("common.search")})]}),w&&e.jsxs("div",{className:"flex items-center gap-3 rounded-lg bg-brand-50 dark:bg-brand-900/20 border border-brand-200 dark:border-brand-700 px-4 py-2.5",children:[e.jsx("span",{className:"text-sm font-medium text-brand-700 dark:text-brand-300",children:a("contacts_page.n_selected",{count:m.size})}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[e.jsxs("button",{type:"button",onClick:()=>C(!0),className:"flex items-center gap-1.5 rounded-lg border border-brand-300 dark:border-brand-600 px-3 py-1.5 text-xs font-medium text-brand-700 dark:text-brand-300 hover:bg-brand-100 dark:hover:bg-brand-900/40 transition",children:[e.jsx($,{className:"h-3.5 w-3.5"})," ",a("contacts_page.export_selected")]}),e.jsxs("button",{type:"button",onClick:R,className:"flex items-center gap-1.5 rounded-lg border border-red-300 dark:border-red-700 px-3 py-1.5 text-xs font-medium text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 transition",children:[e.jsx(D,{className:"h-3.5 w-3.5"})," ",a("contacts_page.delete_selected")]}),e.jsx("button",{type:"button",onClick:S,className:"text-neutral-400 hover:text-neutral-600 dar
6k:hover:text-neutral-200 transition",children:e.jsx(te,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"overflow-x-auto rounded-xl border border-neutral-200 dark:border-neutral-700 bg-white dark:bg-neutral-900",children:e.jsxs("table",{className:"min-w-full divide-y divide-neutral-200 dark:divide-neutral-700 text-sm",children:[e.jsx("thead",{className:"bg-neutral-50 dark:bg-neutral-800",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 w-10",children:e.jsx("button",{type:"button",onClick:M,className:"text-neutral-400 hover:text-brand-600 transition",children:_?e.jsx(E,{className:"h-4 w-4 text-brand-600"}):e.jsx(X,{className:"h-4 w-4"})})}),[a("common.name"),a("contacts_page.col_phone"),a("common.email"),a("contacts_page.col_tags"),a("contacts_page.col_optins"),""].map(t=>e.jsx("th",{className:"px-4 py-3 text-left text-xs font-semibold uppercase tracking-wider text-neutral-500 dark:text-neutral-400",children:t},t))]})}),e.jsxs("tbody",{className:"divide-y divide-neutral-100 dark:divide-neutral-800",children:[s.data.map(t=>e.jsx(oe,{contact:t,selected:m.has(t.uuid),onToggle:H,onDelete:P},t.id)),s.data.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,children:e.jsx(K,{icon:e.jsx(ae,{className:"h-8 w-8"}),title:a("contacts_page.empty_title"),description:a("contacts_page.empty_description"),action:{label:a("contacts_page.add_contact"),onClick:()=>b(!0)},secondaryAction:{label:a("contacts_page.bulk_import"),href:route("client.contacts.bulk-import")}})})})]})]})}),s.last_page>1&&e.jsx("div",{className:"flex gap-1",children:s.links.map((t,r)=>e.jsx("a",{href:t.url??"#",className:`px-3 py-1.5 rounded text-sm border ${t.active?"bg-brand-600 text-white border-brand-600":"border-neutral-300 dark:border-neutral-600 text-neutral-700 dark:text-neutral-300 hover:bg-neutral-50 dark:hover:bg-neutral-800"} ${t.url?"":"opacity-40 pointer-events-none"}`,dangerouslySetInnerHTML:{__html:t.label}},r))})]}),T&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",children:e.jsxs("div",{className:"w-full max-w-md rounded-xl bg-white dark:bg-neutral-900 p-6 shadow-xl space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-neutral-900 dark:text-neutral-100",children:a("contacts_page.add_contact")}),e.jsxs("form",{onSubmit:F,className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-neutral-500 dark:text-neutral-400",children:a("contacts_page.first_name")}),e.jsx("input",{type:"text",value:l.first_name,onChange:t=>p("first_name",t.target.value),className:"mt-1 w-full rounded border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-neutral-800 px-3 py-1.5 text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-neutral-500 dark:text-neutral-400",children:a("contacts_page.last_name")}),e.jsx("input",{type:"text",value:l.last_name,onChange:t=>p("last_name",t.target.value),className:"mt-1 w-full rounded border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-neutral-800 px-3 py-1.5 text-sm"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-neutral-500 dark:text-neutral-400",children:a("contacts_page.phone_e164")}),e.jsx("input",{type:"text",value:l.phone_e164,onChange:t=>z(t.target.value),placeholder:"+8801XXXXXXXXX",className:"mt-1 w-full rounded border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-neutral-800 px-3 py-1.5 text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-neutral-500 dark:text-neutral-400",children:a("common.email")}),e.jsx("input",{type:"email",value:l.email,onChange:t=>B(t.target.value),className:"mt-1 w-full rounded border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-neutral-800 px-3 py-1.5 text-sm"})]}),e.jsx("div",{className:"flex gap-4",children:[["opt_in_whatsapp","WhatsApp",!l.phone_e164.trim()],["opt_in_sms",a("contacts_page.channel_sms"),!l.phone_e164.trim()],["opt_in_email",a("common.email"),!l.email.trim()]].map(([t,r,n])=>e.jsxs("label",{className:`flex items-center gap-1.5 text-sm ${n?"opacity-40 cursor-not-allowed":"cursor-pointer"}`,children:[e.jsx("input",{type:"checkbox",checked:l[t],onChange:j=>p(t,j.target.checked),disabled:n,className:"rounded"}),r]},t))}),x.length>0&&e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-neutral-500 dark:text-neutral-400",children:a("contacts_page.add_to_segments")}),e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-2",children:x.map(t=>{const r=l.segment_ids.includes(t.id);return e.jsxs("label",{className:`flex items-center gap-1.5 rounded-full border px-3 py-1 text-xs cursor-pointer transition ${r?"border-brand-500 bg-brand-50 dark:bg-brand-900/30 text-brand-700 dark:text-brand-300":"border-neutral-300 dark:border-neutral-600 text-neutral-600 dar
6k:text-neutral-400 hover:border-brand-400"}`,children:[e.jsx("input",{type:"checkbox",className:"sr-only",checked:r,onChange:()=>{const n=r?l.segment_ids.filter(j=>j!==t.id):[...l.segment_ids,t.id];p("segment_ids",n)}}),t.name]},t.id)})})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx("button",{type:"submit",disabled:y,className:"flex-1 rounded-lg bg-brand-600 py-2 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-60 transition",children:a(y?"common.saving":"common.save")}),e.jsx("button",{type:"button",onClick:()=>b(!1),className:"rounded-lg border border-neutral-300 dark:border-neutral-600 px-4 py-2 text-sm text-neutral-700 dark:text-neutral-300 hover:bg-neutral-50 dark:hover:bg-neutral-800 transition",children:a("common.cancel")})]})]})]})})]})}export{Oe 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.