import{k as x,b as a,C as g,B as n,j as t,ae as C,S as h,q as s,E as p,G as i,Q as u,F as f,X as y,a6 as w,a0 as U}from"./index-ktJf6c6X.js";import{d as D}from"./EventNoteOutlined-AvhiScoR.js";import{u as I}from"./FollowUpApi-SyVT7toO.js";const c=r=>r?y(r).format("DD MMM YYYY, hh:mm A"):"—",b=(r,e)=>r!=null&&e!=null?`${r.toFixed(6)}, ${e.toFixed(6)}`:"—",d=r=>r?r.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase()):"—",o=r=>r==null||r===""?"—":String(r),F=r=>{switch((r||"").toUpperCase()){case"COMPLETED":return"success";case"SCHEDULED":case"RESCHEDULED":return"info";case"CANCELLED":case"MISSED":return"error";case"CLOSED":return"default";default:return"warning"}},l=({label:r,value:e,md:m=4})=>t(i,{item:!0,xs:12,sm:6,md:m,children:[a(s,{variant:"caption",color:"text.secondary",sx:{display:"block",mb:.25},children:r}),a(s,{variant:"body2",fontWeight:500,sx:{wordBreak:"break-word"},children:e??"—"})]}),L=()=>{const{id:r}=x(),{data:e,isLoading:m,isError:v}=I(Number(r),{skip:r==null});if(m)return a(n,{display:"flex",justifyContent:"center",alignItems:"center",minHeight:320,children:a(g,{})});if(v||!e)return a(n,{p:3,children:t(U,{variant:"outlined",sx:{p:4,textAlign:"center",borderRadius:2},children:[a(s,{color:"error",variant:"h6",children:"Follow-up not found"}),a(s,{color:"text.secondary",variant:"body2",children:"It may have been removed, or you may not have access to it."})]})});const k=e.customerName||e.leadName||e.prospectName||"—";return t(n,{p:{xs:1.5,md:2},position:"relative",children:[a(C,{}),t(h,{direction:"row",spacing:1.5,alignItems:"center",mb:2,pr:5,flexWrap:"wrap",useFlexGap:!0,children:[a(D,{color:"primary"}),t(s,{variant:"h5",fontWeight:700,children:["Follow-Up ",e.followUpNumber?`#${e.followUpNumber}`:""]}),e.followUpStatus&&a(p,{size:"small",label:d(e.followUpStatus),color:F(e.followUpStatus)}),e.manualVisit&&a(p,{size:"small",variant:"outlined",label:"Manual Visit"}),e.priority&&a(p,{size:"small",variant:"outlined",label:`Priority: ${d(e.priority)}`})]}),t(i,{container:!0,spacing:2,children:[a(i,{item:!0,xs:12,children:a(u,{title:"Overview",children:t(i,{container:!0,spacing:2,p:1,children:[a(l,{label:"Follow-up Number",value:o(e.followUpNumber)}),a(l,{label:"Type",value:d(e.followUpType)}),a(l,{label:"Lead",value:o(e.leadNumber||e.leadName)}),a(l,{label:"Customer / Prospect",value:k}),a(l,{label:"Sales Person",value:o(e.salesPersonName||e.salesPerson)}),a(l,{label:"Lead Stage",value:d(e.leadStage)}),e.manualVisit&&t(f,{children:[a(l,{label:"Visit Type",value:d(e.visitType)}),a(l,{label:"Prospect Mobile",value:o(e.prospectMobile)}),a(l,{label:"Prospect Address",value:o(e.prospectAddress),md:8})]})]})})}),a(i,{item:!0,xs:12,md:6,children:a(u,{title:"Schedule",children:t(i,{container:!0,spacing:2,p:1,children:[a(l,{label:"Follow-up Date & Time",value:c(e.followUpDate),md:6}),a(l,{label:"Next Follow-up Date & Time",value:c(e.nextFollowUpDate),md:6}),e.reminderRequired!=null&&a(l,{label:"Reminder",value:e.reminderRequired?`Yes${e.reminderAt?` · ${c(e.reminderAt)}`:""}`:"No",md:6})]})})}),a(i,{item:!0,xs:12,md:6,children:a(u,{title:"Outcome",children:t(i,{container:!0,spacing:2,p:1,children:[a(l,{label:"Discussion Points",value:o(e.discussionPoints),md:12}),a(l,{label:"Customer Feedback",value:o(e.customerFeedback),md:12}),a(l,{label:"Remarks",value:o(e.remarks),md:12})]})})}),a(i,{item:!0,xs:12,children:a(u,{title:"Visit & Location",children:t(i,{container:!0,spacing:2,p:1,children:[a(l,{label:"Check-in Time",value:c(e.checkInTime)}),a(l,{label:"Check-out Time",value:c(e.checkOutTime)}),a(l,{label:"Visit Duration",value:e.visitDurationMinutes!=null?`${e.visitDurationMinutes} min`:"—"}),a(l,{label:"Check-in Address",value:o(e.checkInAddress),md:6}),a(l,{label:"Check-out Address",value:o(e.checkOutAddress),md:6}),a(l,{label:"Check-in Coordinates",value:b(e.checkInLatitude,e.checkInLongitude)}),a(l,{label:"Check-out Coordinates",value:b(e.checkOutLatitude,e.checkOutLongitude)}),(e.checkInImageUrl||e.checkOutImageUrl)&&t(i,{item:!0,xs:12,children:[a(w,{sx:{my:1}}),t(h,{direction:"row",spacing:2,flexWrap:"wrap",useFlexGap:!0,children:[e.checkInImageUrl&&t(n,{children:[a(s,{variant:"caption",color:"text.secondary",display:"block",children:"Check-in Photo"}),a(n,{component:"img",src:e.checkInImageUrl,alt:"Check-in",sx:{maxWidth:220,maxHeight:220,borderRadius:1,mt:.5}})]}),e.checkOutImageUrl&&t(n,{children:[a(s,{variant:"caption",color:"text.secondary",display:"block",children:"Check-out Photo"}),a(n,{component:"img",src:e.checkOutImageUrl,alt:"Check-out",sx:{maxWidth:220,maxHeight:220,borderRadius:1,mt:.5}})]})]})]})]})})})]})]})};export{L as default};
