1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6507],{56507:(e,t,s)=>{s.d(t,{C:()=>f});var a=s(95155),l=s(12115),r=s(66889),c=s(84267),i=s(91902),n=s(51719),d=s(1466),o=s(66462),m=s(63348),x=s(61594),h=s(26764),g=s(43831),u=s(99271),p=s(45471);s(13768),s(45686),s(35765);let b=e=>({"Lead Created":{icon:d.A,color:"bg-blue-500",textColor:"text-blue-700",bgColor:"bg-blue-50"},Email:{icon:o.A,color:"bg-purple-500",textColor:"text-purple-700",bgColor:"bg-purple-50"},SMS:{icon:m.A,color:"bg-green-500",textColor:"text-green-700",bgColor:"bg-green-50"},"Status Changed":{icon:x.A,color:"bg-yellow-500",textColor:"text-yellow-700",bgColor:"bg-yellow-50"},"Details Changed":{icon:h.A,color:"bg-gray-500",textColor:"text-gray-700",bgColor:"bg-gray-50"},Call:{icon:g.A,color:"bg-indigo-500",textColor:"text-indigo-700",bgColor:"bg-indigo-50"},WhatsApp:{icon:u.A,color:"bg-emerald-500",textColor:"text-emerald-700",bgColor:"bg-emerald-50"}})[e]||{icon:p.A,color:"bg-gray-500",textColor:"text-gray-700",bgColor:"bg-gray-50"},y=e=>{let t=Math.floor(e/60);return"".concat(t,":").concat((e%60).toString().padStart(2,"0"))},j=e=>{let{entry:t,isLast:s}=e,[c,d]=(0,l.useState)(!1),[o,m]=(0,l.useState)(!1),x=b(t.category),h=x.icon;return(0,a.jsxs)("div",{className:"relative pl-12 group",children:[(0,a.jsx)("div",{className:"absolute left-0 -translate-x-1/2 p-1 rounded-full bg-white",style:{zIndex:0},children:(0,a.jsx)("div",{className:"rounded-full p-2 ".concat(x.color," transform transition-transform group-hover:scale-110"),children:(0,a.jsx)(h,{className:"h-4 w-4 text-white"})})}),(0,a.jsx)("div",{className:"".concat(x.bgColor," rounded-lg shadow-sm hover:shadow-md transition-all duration-200 w-full relative"),style:{zIndex:0},children:(0,a.jsxs)("div",{className:"p-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ".concat(x.textColor," bg-white shadow-sm"),children:t.category}),(0,a.jsx)("span",{className:"text-sm text-gray-500",children:new Date(t.createdAt).toLocaleTimeString()})]}),(0,a.jsx)("div",{className:"relative",children:(0,a.jsx)("button",{onClick:()=>m(!o),className:"p-1 hover:bg-gray-100 rounded-full transition-colors",children:o?(0,a.jsx)(i.A,{className:"h-5 w-5 text-gray-400"}):(0,a.jsx)(n.A,{className:"h-5 w-5 text-gray-400"})})})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("div",{className:"text-sm text-gray-700",children:(()=>{let e=t.description;switch(t.category){case"Lead Created":return"Lead created by ".concat(e.createdBy);case"Email":case"SMS":case"WhatsApp":return(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("p",{className:"font-medium",children:["From: ",e.createdBy]}),e.subject&&(0,a.jsxs)("p",{className:"text-gray-700",children:["Subject: ",e.subject]}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("p",{className:"text-gray-600 ".concat(!c&&"line-clamp-2"),children:e.content}),e.content&&e.content.length>100&&(0,a.jsx)("button",{onClick:()=>d(!c),className:"text-blue-600 hover:text-blue-700 text-sm font-medium mt-1",children:c?"Show less":"Show more"})]})]});case"Status Changed":return(0,a.jsx)("div",{className:"space-y-1",children:(0,a.jsxs)("p",{children:["Status updated from ",(0,a.jsx)("span",{className:"font-medium",children:e.before?e.before:"NA"})," to ",(0,a.jsx)("span",{className:"font-medium",children:e.after?e.after:"NA"})]})});case"Details Changed":return Object.entries(e).map(e=>{let[t,s]=e;return"createdBy"!==t?(0,a.jsx)("div",{className:"space-y-1",children:(0,a.jsxs)("p",{className:"capitalize",children:[t," changed from ",(0,a.jsx)("span",{className:"font-medium",children:s.from?s.from:"NA"})," to ",(0,a.jsx)("span",{className:"font-medium",children:s.to?s.to:"NA"})]})},t):null});case"Call":return(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("p",{className:"font-medium",children:["Call by ",e.createdBy]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(r.A,{className:"h-4 w-4 text-gray-400"}),(0,a.jsxs)("span",{children:["Duration: ",y(e.duration)]})]})]});default:return JSON.stringify(e)}})()}),t.comment&&(0,a.jsxs)("div",{className:"mt-3 pt-3 border-t border-gray-200",children:[(0,a.jsx)("p",{className:"text-xs font-medium text-gray-500 mb-1",children:"Comment"}),(0,a.jsx)("p",{className:"text-sm text-gray-600",children:t.comment})]})]})]})})]})};var N=s(10287),v=s(50521);let f=e=>{let{leadId:t,isExpanded:s}=e,{hasPermission:d}=(0,v.S)(),[o,m]=(0,l.useState)([]),[x,h]=(0,l.useState)(new Set),[g,u]=(0,l.useState)(!1),[p,b]=(0,l.useState)(null),[y,f]=(0,l.useState)(!1),[w,C]=(0,l.useState)(!1),[S,A]=(0,l.useState)(new Set);(0,l.useEffect)(()=>{f(!0)},[]),(0,l.useEffect)(()=>{(async()=>
1{if(d("view_lead_history")&&s&&y){u(!0),b(null);try{let e=(await N.F.get("/leads/viewhistory/".concat(t))).data;if(!e.history||!Array.isArray(e.history)){m([]);return}if(m(e.history),e.history.length>0){let t=new Date(e.history[0].createdAt).toLocaleDateString();h(new Set([t]))}}catch(t){var e;if((null==t?void 0:null===(e=t.response)||void 0===e?void 0:e.status)===403){m([]);return}b("Unable to load activity history")}finally{u(!1)}}})()},[t,s,y,d]);let k=e=>{h(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})},D=e=>{A(t=>{let s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})},z=o.filter(e=>0===S.size||S.has(e.category));if(!s||!d("view_lead_history"))return null;if(g)return(0,a.jsx)("div",{className:"mx-auto w-[90%] p-6 space-y-4",children:[1,2,3].map(e=>(0,a.jsxs)("div",{className:"animate-pulse",children:[(0,a.jsx)("div",{className:"h-4 bg-gray-200 rounded w-1/4 mb-4"}),(0,a.jsx)("div",{className:"space-y-3",children:(0,a.jsx)("div",{className:"h-20 bg-gray-100 rounded"})})]},e))});if(p)return(0,a.jsx)("div",{className:"mx-auto w-[90%] p-4",children:(0,a.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4",children:(0,a.jsx)("p",{className:"text-red-700",children:p})})});if(0===o.length)return null;let E=(e=>{let t={};return e.sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime()).forEach(e=>{let s=new Date(e.createdAt).toLocaleDateString();t[s]||(t[s]=[]),t[s].push(e)}),t})(z);return(0,a.jsxs)("div",{className:"relative mx-auto w-[90%] px-4 py-6",children:[(0,a.jsx)("div",{className:"pt-2 pb-",style:{zIndex:1},children:(0,a.jsxs)("div",{className:"flex items-center justify-between border-b border-gray-200 pb-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-4",children:[(0,a.jsxs)("h2",{className:"text-xl font-semibold flex items-center gap-2 bg-white text-black",children:[(0,a.jsx)(r.A,{className:"h-5 w-5 text-gray-500"}),"Activity Timeline"]}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsxs)("button",{onClick:()=>C(!w),className:"flex items-center gap-2 px-3 py-1.5 bg-white rounded-full shadow-sm hover:shadow transition-shadow text-sm text-gray-600 z-2",children:[(0,a.jsx)(c.A,{className:"h-4 w-4"}),"Filter",S.size>0&&(0,a.jsx)("span",{className:"bg-blue-100 text-blue-600 px-2 py-0.5 rounded-full text-xs",children:S.size})]}),w&&(0,a.jsx)("div",{className:"absolute left-0 mt-2 w-56 rounded-lg bg-white shadow-lg ring-1 ring-black ring-opacity-5",style:{zIndex:2},children:(0,a.jsx)("div",{className:"p-2",children:["Lead Created","Email","SMS","Status Changed","Details Changed","Call","WhatsApp"].map(e=>(0,a.jsxs)("label",{className:"flex items-center px-3 py-2 hover:bg-gray-50 rounded-md cursor-pointer",children:[(0,a.jsx)("input",{type:"checkbox",checked:S.has(e),onChange:()=>D(e),className:"h-4 w-4 text-blue-600 rounded border-gray-300"}),(0,a.jsx)("span",{className:"ml-3 text-sm text-gray-700",children:e})]},e))})})]})]}),(0,a.jsxs)("span",{className:"bg-white shadow-sm text-gray-700 px-3 py-1.5 rounded-full text-sm",children:[z.length," Activities"]})]})}),(0,a.jsxs)("div",{className:"relative mt-6",children:[(0,a.jsx)("div",{className:"absolute left-6 top-0 bottom-0 w-px bg-gray-200",style:{zIndex:0}}),Object.entries(E).map((e,t)=>{let[s,l]=e;return(0,a.jsxs)("div",{className:"mb-6",children:[(0,a.jsx)("div",{className:"flex items-center cursor-pointer mb-4 relative",onClick:()=>k(s),children:(0,a.jsxs)("div",{className:"flex items-center bg-white shadow-sm rounded-lg px-4 py-3 hover:bg-gray-50 transition-colors w-full",children:[(0,a.jsx)("span",{className:"text-gray-900 font-medium",children:s}),(0,a.jsxs)("span",{className:"text-gray-500 text-sm ml-2",children:["(",l.length," ",1===l.length?"activity":"activities",")"]}),(0,a.jsx)("div",{className:"ml-auto",children:x.has(s)?(0,a.jsx)(i.A,{className:"h-5 w-5 text-gray-400"}):(0,a.jsx)(n.A,{className:"h-5 w-5 text-gray-400"})})]})}),x.has(s)&&(0,a.jsx)("div",{className:"space-y-4",children:l.map((e,t)=>(0,a.jsx)(j,{entry:e,isLast:t===l.length-1},t))})]},s)})]})]})}}}]);
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.