1import{j as e}from"./vendor-query-BVMb3S9f.js";import{r as d}from"./vendor-react-BmnyI7hj.js";import{V as j,e as y,d as g,W as v,X as N}from"./index-f89aq0IA.js";import{E as b}from"./EmptyState-lvHTNzZz.js";import{S as w}from"./SkeletonCard-4NI6jWYO.js";import"./vendor-ui-CGy3Dxhc.js";import"./vendor-supabase-cZ1AhKFM.js";import"./vendor-forms-DP4uz6ig.js";const _=[{value:"all",label:"All Calls"},{value:"waiting_on_them",label:"Waiting on them"},{value:"i_need_to_do",label:"I need to do"},{value:"follow_up_by",label:"Follow up scheduled"},{value:"done",label:"Done"}];function P(){const[t,n]=d.useState(null),[a,o]=d.useState("all"),{data:x,isLoading:i,error:u}=j(t||void 0),{data:p}=y(),m=g(s=>s.openQuickEntry),r=x?.filter(s=>a==="all"?!0:s.outcome===a),h=s=>{const l=new Date(s),f=new Date().getTime()-l.getTime(),c=Math.floor(f/(1e3*60*60*24));return c===0?"Today "+l.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"}):c===1?"Yesterday":c<7?l.toLocaleDateString("en-US",{weekday:"long"}):l.toLocaleDateString("en-US",{month:"short",day:"numeric"})};return e.jsxs("div",{className:"px-4 py-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h1",{className:"text-xl font-semibold text-text-primary",children:"Call Log"}),e.jsxs("button",{onClick:()=>m("call"),className:"flex items-center gap-2 px-4 py-2 bg-primary-600 text-white text-sm font-medium rounded-lg hover:bg-primary-700 transition-colors",children:[e.jsx("span",{children:"+"})," Log Call"]})]}),e.jsxs("div",{className:"flex flex-col md:flex-row gap-3 mb-6",children:[e.jsx("div",{className:"flex-1 md:max-w-xs",children:e.jsxs("select",{value:t||"",onChange:s=>n(s.target.value||null),className:"w-full px-3 py-2 border border-border rounded-md text-sm bg-white focus:outline-none focus:ring-2 focus:ring-primary-500",children:[e.jsx("option",{value:"",children:"All Projects"}),p?.map(s=>e.jsx("option",{value:s.id,children:s.name},s.id))]})}),e.jsx("div",{className:"md:w-48",children:e.jsx("select",{value:a,onChange:s=>o(s.target.value),className:"w-full px-3 py-2 border border-border rounded-md text-sm bg-white focus:outline-none focus:ring-2 focus:ring-primary-500",children:_.map(s=>e.jsx("option",{value:s.value,children:s.label},s.value))})})]}),u&&e.jsx("div",{className:"bg-red-50 text-red-600 p-4 rounded-lg mb-4",children:"Failed to load call logs. Please try again."}),i&&e.jsx(w,{count:5}),!i&&r&&r.length===0&&e.jsx(b,{icon:"ð",title:t||a!=="all"?"No calls found":"No calls logged yet",description:t||a!=="all"?"Try a different filter":"Log your first call to start tracking your communications.",actionLabel:t||a!=="all"?void 0:"Log Call",onAction:t||a!=="all"?void 0:()=>m("call")}),!i&&r&&r.length>0&&e.jsx("div",{className:"space-y-3",children:r.map(s=>e.jsx(L,{log:s,formatDate:h},s.id))})]})}function L({log:t,formatDate:n}){const[a,o]=d.useState(!1);return e.jsxs("div",{className:"bg-white rounded-lg border border-border p-4 hover:border-primary-200 transition-colors cursor-pointer",onClick:()=>o(!a),children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"font-medium text-text-primary truncate",children:t.contact_name}),t.project_name&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-text-secondary",children:"-"}),e.jsx("span",{className:"text-sm text-text-secondary truncate",children:t.project_name})]})]}),e.jsx("p",{className:`text-sm text-text-secondary ${a?"":"line-clamp-2"}`,children:t.note}),a&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-border space-y-2",children:[t.follow_up_date&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-text-secondary",children:"Follow up:"}),e.jsx("span",{className:"text-text-primary",children:new Date(t.follow_up_date).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})})]}),t.follow_up_task&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-text-secondary",children:"Task:"}),e.jsx("span",{className:"text-primary-600",children:t.follow_up_task})]}),t.duration_minutes&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("span",{className:"text-text-secondary",children:"Duration:"}),e.jsxs("span",{className:"text-text-primary",children:[t.duration_minutes," min"]})]})]})]}),e.jsxs("div",{className:"flex flex-col items-end gap-2 shrink-0",children:[e.jsx("span",{className:"text-xs text-text-secondary whitespace-nowrap",children:n(t.created_at)}),e.jsx("span",{className:`text-xs px-2 py-1 rounded whitespace-nowrap ${N(t.outcome)}`,children:v(t.outcome)})]})]}),e.jsx("div",{className:"flex justify-center mt-2",children:e.jsx("span",{className:"text-xs text-text-secondary",children:a?"â² Less":"â¼ More"})})]})}export{P as CallLogList};
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.