1import{r as n,j as e}from"./vendor-react-DK_MHVKo.js";import{u as w,b as y}from"./index-Djo5SZyv.js";import{f as b,a as N,O as f,C}from"./components-B8SiwIzS.js";import{ac as k,V as o,aH as g,N as _,c as $}from"./vendor-icons-Dr_X1Hjo.js";import"./vendor-query-Ceg45NlR.js";function F(){const{t}=w(),[i,x]=n.useState([]),[l,m]=n.useState(0),[r,h]=n.useState(0),[v,u]=n.useState(!0),[p,d]=n.useState(null),c=20;return n.useEffect(()=>{u(!0),y.get(`/inbound/calls?skip=${r*c}&limit=${c}`).then(s=>{var j;const a=((j=s.data)==null?void 0:j.data)||s.data;x((a==null?void 0:a.calls)||[]),m((a==null?void 0:a.total)||0)}).catch(()=>{x([]),m(0)}).finally(()=>u(!1))},[r]),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h1",{className:"text-2xl font-bold text-white",children:t("inbound.calls.title")}),l>0&&e.jsxs("span",{className:"text-sm text-slate-400",children:[l," ",l>1?t("inbound.calls.callsPlural"):t("inbound.calls.callSingular")]})]}),v?e.jsx("div",{className:"flex items-center justify-center h-40",children:e.jsx(k,{className:"w-6 h-6 text-emerald-400 animate-spin"})}):i.length===0?e.jsxs("div",{className:"bg-slate-800/50 border border-slate-700 rounded-xl p-12 text-center",children:[e.jsx(o,{className:"w-12 h-12 mx-auto mb-3 text-slate-600"}),e.jsx("p",{className:"text-slate-400",children:t("inbound.calls.noCalls")}),e.jsx("p",{className:"text-sm text-slate-500 mt-1",children:t("inbound.calls.noCallsDesc")})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden lg:block bg-slate-800/50 border border-slate-700 rounded-xl overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-slate-700 text-slate-400 text-left",children:[e.jsx("th",{className:"px-4 py-3",children:t("inbound.calls.caller")}),e.jsx("th",{className:"px-4 py-3",children:t("inbound.calls.date")}),e.jsx("th",{className:"px-4 py-3",children:t("inbound.calls.duration")}),e.jsx("th",{className:"px-4 py-3 text-center",children:t("inbound.calls.audio")}),e.jsx("th",{className:"px-4 py-3",children:t("inbound.calls.outcome")})]})}),e.jsx("tbody",{className:"divide-y divide-slate-700/50",children:i.map(s=>e.jsxs("tr",{onClick:()=>d(s),className:"hover:bg-slate-800/30 cursor-pointer transition-colors",children:[e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:`w-7 h-7 rounded-full flex items-center justify-center flex-shrink-0 ${s.status==="completed"?"bg-emerald-500/20":"bg-slate-700"}`,children:e.jsx(o,{className:`w-3.5 h-3.5 ${s.status==="completed"?"text-emerald-400":"text-slate-400"}`})}),e.jsx("span",{className:"text-white",children:s.caller_phone?e.jsx("a",{href:`tel:${s.caller_phone}`,onClick:a=>a.stopPropagation(),className:"hover:underline",children:s.caller_phone}):t("inbound.calls.hidden")})]})}),e.jsx("td",{className:"px-4 py-3 text-slate-300",children:b(s.started_at)}),e.jsx("td",{className:"px-4 py-3 text-slate-300",children:N(s.duration)}),e.jsx("td",{className:"px-4 py-3 text-center",children:s.recording_url?e.jsx(g,{className:"w-4 h-4 text-emerald-400 inline-block",title:t("inbound.calls.recordingAvailable")}):e.jsx("span",{className:"text-slate-600",children:"â"})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx(f,{outcome:s.outcome,status:s.status})})]},s.id))})]})}),e.jsx("div",{className:"lg:hidden space-y-2",children:i.map(s=>e.jsx("button",{onClick:()=>d(s),className:"w-full text-left bg-slate-800/50 border border-slate-700 rounded-xl p-3 active:bg-slate-800 transition-colors",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-9 h-9 rounded-full flex items-center justify-center flex-shrink-0 ${s.status==="completed"?"bg-emerald-500/20":"bg-slate-700"}`,children:e.jsx(o,{className:`w-4 h-4 ${s.status==="completed"?"text-emerald-400":"text-slate-400"}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-white text-sm font-medium truncate",children:s.caller_phone?e.jsx("a",{href:`tel:${s.caller_phone}`,onClick:a=>a.stopPropagation(),className:"hover:underline",children:s.caller_phone}):t("inbound.calls.hidden")}),e.jsx(f,{outcome:s.outcome,status:s.status})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-400 mt-1",children:[e.jsx("span",{className:"whitespace-nowrap",children:b(s.started_at)}),e.jsx("span",{className:"text-slate-600",children:"·"}),e.jsx("span",{className:"whitespace-nowrap",children:N(s.duration)}),s.recording_url&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-slate-600",children:"·"}),e.jsx(g,{className:"w-3.5 h-3.5 text-emerald-400"})]})]})]})]})},s.id))}),l>c&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-sm text-slate-400",children:[t("inbound.calls.page")," ",r+1," / ",Math.ceil(l/c)]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>h(s=>Math.max(0,s-1)),disabled:r===0,className:"p-2 rounded-lg bg-slate-800 border border-slate-700 text-slate-400 hover:text-white disabled:opacity-30",children:e.jsx(_,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>h(s=>s+1),disabled:(r+1)*c>=l,className:"p-2 rounded-lg bg-slate-800 border border-slate-700 text-slate-400 hover:text-white disabled:opacity-30",children:e.jsx($,{className:"w-4 h-4"})})]})]})]}),p&&e.jsx(C,{call:p,onClose:()=>d(null)})]})}export{F 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.