1import{f as P,Z as B,r,N as l,j as e,o as c,bu as $,n as D,cL as E,e as Y,i4 as G,s as I,i5 as R}from"./index-BiR4tHPa.js";import{s as n,C as z}from"./ContactsTab-tlyTdJNi.js";import{U as V}from"./UserProfile-XzwiiujQ.js";import W from"./MaterialUiDatePicker-vRODdoO2.js";import Z from"./MaterialUiTimePicker-DcoRf5gv.js";import"./style-g158jnvn.js";import"./index-1AQ0BBpp.js";import"./Skeleton-DfThc6Vk.js";import"./useMobilePicker-ChVQmibs.js";import"./useThemeProps-Bm86sZ3E.js";import"./AdapterDayjs-C_KT9Vl8.js";import"./dateViewRenderers-BEc2yG4Q.js";import"./timeViewRenderers-BFKL0iIh.js";const ne=()=>{var M,F;const{t:o}=P(["common","contact"]),k=B(),[t,h]=r.useState((M=k.state)==null?void 0:M.contact);console.log(t,"data");const T=t==null?void 0:t._id,a=t==null?void 0:t.follow_ups,[j,d]=r.useState(!1),[i,m]=r.useState(""),[u,f]=r.useState(""),[b,p]=r.useState(""),[v,g]=r.useState(""),[w,y]=r.useState(!1),C=[{label:o("contact:followUpStatus.pending"),value:"Pending"},{label:o("contact:followUpStatus.completed"),value:"Completed"}],S=()=>{d(!1)},H=async()=>{if(!u){Y("Please provide status!");return}y(!0);try{const s=i?l(i):l(),x={status:u,date:s.format("DD, MMMM YYYY"),time:b?l(b,"HH:mm").format("HH:mm:ss"):s.format("HH:mm:ss"),note:v},U={...t,follow_ups:x,updated_at:l().format("DD, MMMM YYYY HH:mm")};await G(t._id,U),h(_=>({..._,follow_ups:x})),console.log(t,"fl"),d(!1),m(""),f(""),p(""),g(""),I("Follow-up added successfully!")}catch(s){console.error("Failed to update follow-up:",s),Y("Something went wrong while saving follow-up.")}finally{y(!1)}},L=async()=>{try{const x=(await R(T)).data.document[0];h(x)}catch(s){console.log(s)}};r.useEffect(()=>{t!=null&&t._id&&L()},[]),r.useEffect(()=>{if(j&&(t!=null&&t.follow_ups)){const s=t.follow_ups;g(s.note||""),f(s.status||""),s.date?m(l(s.date,"DD, MMMM YYYY")):m(l()),s.time?p(l(s.time,"HH:mm:ss")):p(null)}},[j,t]);const N=(a==null?void 0:a.date)||(a==null?void 0:a.status);return e.jsxs("div",{className:"d-flex align-items-start gap-4 mb-3 flex-wrap",children:[e.jsx("div",{className:n.profileCardWrapper,children:e.jsx(V,{contactDetails:t,setContactDetails:h})}),e.jsxs("div",{className:n.contactDetailsContainer,children:[e.jsx(z,{}),e.jsxs("div",{className:"d-flex align-items-center justify-content-between",children:[e.jsxs("h3",{className:n.sectionTitle,children:[o("contact:followupfor")," ",e.jsx("span",{className:n.contactName,children:t==null?void 0:t.name})]}),!N&&e.jsx("button",{className:`${n.button} btn btn-primary`,onClick:()=>d(!0),children:o("common:add")}),N&&e.jsx("button",{className:`${n.button} btn btn-primary`,onClick:()=>d(!0),children:o("common:edit")})]}),e.jsx("div",{className:n.tabContent,children:N?e.jsxs("div",{className:n.followupcard,children:[e.jsxs("div",{style:{marginBottom:"0.5rem",marginTop:"0.5rem",display:"flex",alignItems:"center",gap:"6rem"},children:[e.jsx("span",{className:`${n.noteBadge}`,children:(a==null?void 0:a.note)||"Note not provided"}),e.jsx("span",{className:`${n.statusBadge} ${n[(F=a==null?void 0:a.status)==null?void 0:F.toLowerCase()]}`,children:a==null?void 0:a.status})]}),e.jsx("div",{children:e.jsxs("p",{className:n.updated,children:[o("contact:lastupdated"),": ",a==null?void 0:a.date]})})]}):e.jsx("p",{style:{color:"#6b7280",fontSize:"15px"},children:o("contact:nofollowup")})}),j&&e.jsx("div",{className:"modal show d-block",tabIndex:"-1",role:"dialog",style:{backgroundColor:"rgba(0,0,0,0.5)"},children:e.jsx("div",{className:"modal-dialog",role:"document",children:e.jsxs("div",{className:"modal-content",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h5",{className:"modal-title",children:o("contact:followup")}),e.jsx("button",{type:"button",className:"btn-close",onClick:S})]}),e.jsx("div",{className:"modal-body",children:e.jsxs(c,{children:[e.jsxs(c.Group,{className:"mb-3",children:[e.jsx(c.Label,{children:e.jsx("strong",{children:o("contact:note")})}),e.jsx(c.Control,{type:"text",placeholder:o("contact:enternote"),style:{backgroundColor:"#21252908"},value:v,onChange:s=>g(s.target.value)})]}),e.jsxs(c.Group,{className:"mb-3",children:[e.jsx(c.Label,{children:e.jsx("strong",{children:o("contact:status")})}),e.jsx($,{className:"custom-react-select",classNamePrefix:"react-select",options:C,value:u?C.find(s=>s.value===u):null,onChange:s=>
1f((s==null?void 0:s.value)||""),placeholder:o("selectstatus"),styles:{control:s=>({...s,backgroundColor:"#21252908"})}})]}),e.jsxs(c.Group,{className:"mb-3",children:[e.jsx(c.Label,{children:e.jsx("strong",{children:o("contact:date")})}),e.jsx("div",{children:e.jsx(W,{selectedValue:i||l(),minDate:l(),dateSelect:s=>m(s)})})]}),e.jsxs(c.Group,{className:"mb-3",children:[e.jsx(c.Label,{children:e.jsx("strong",{children:o("contact:time")})}),e.jsx("div",{children:e.jsx(Z,{timeSelect:s=>p(s),selectedValue:b,style:{minWidth:"10rem"},ampm:!1,minTime:i&&l(i).isSame(l(),"day")?l():null})})]})]})}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{type:"button",className:"btn btn-secondary",onClick:S,children:o("common:cancel")}),e.jsx(D,{variant:"primary",onClick:H,disabled:w,children:w?e.jsx(E,{as:"span",animation:"border",size:"sm",role:"status","aria-hidden":"true"}):o("common:save")})]})]})})})]})]})};export{ne 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.