1import{r as s,j as a,P as G,G as M,H as A,I as v,L as B,bU as k,c6 as z,o as H,n as I,cL as O,f6 as U,c1 as $,iG as q,s as J,e as K}from"./index-BiR4tHPa.js";import{s as Q}from"./addEditPatient.module-DDGDyjuN.js";const ne=()=>{const[n,i]=s.useState({database_name:"yb_db",collection_name:"notification_details",new_data:{}}),[x,W]=s.useState([{name:"Select",value:""},{name:"patient_name",value:"patient_name"},{name:"doctor_name",value:"doctor_name"},{name:"date",value:"date"},{name:"time",value:"time"},{name:"follow_up_date",value:"follow_up_date"},{name:"status",value:"status"},{name:"patient_type",value:"patient_type"},{name:"language_used",value:"language_used"}]),[r,b]=s.useState([{name:"Select",value:""}]),[X,_]=s.useState([]),[h,w]=s.useState([]);s.useState([]);const[m,l]=s.useState(),[d,j]=s.useState(""),[y,S]=s.useState(""),[L,Y]=s.useState(""),[N,T]=s.useState(""),[D,Z]=s.useState(!1),[ee,V]=s.useState({}),[ae,F]=s.useState(""),C=async()=>{var e;l(!0);try{const t=await U("APPROVED","","");console.log(t,"get template response"),b([...r,...(e=t==null?void 0:t.data)==null?void 0:e.document]),l(!1)}catch(t){console.log(t,"get template error"),l(!1)}},E=async()=>{try{const e=await $();let t=e.data.document;_([...t]),t.some(o=>{o.notification_type==="google_review"&&(T(o._id),i({...n,new_data:{...o}}))}),console.log(e,"get notification response")}catch(e){console.log(e,"get notification error")}},P=async()=>{l(!0);try{const e=await q(N,n.new_data);console.log(e,"post response"),J(e.data.message),l(!1)}catch(e){console.log(e,"post error"),K("Something went wrong !"),l(!1)}},R=(e,t)=>{const o=[...n.new_data.variables];o[t]=e,i({...n,new_data:{...n.new_data,variables:[...o]}})};return s.useEffect(()=>{r.some(e=>{var t,o,c,p,g,f;if(e.name===d){S(e.language);let u=[];(o=(t=e==null?void 0:e.components[0])==null?void 0:t.example)!=null&&o.body_text&&(w([...(p=(c=e==null?void 0:e.components[0])==null?void 0:c.example)==null?void 0:p.body_text[0]]),(f=(g=e==null?void 0:e.components[0])==null?void 0:g.example)==null||f.body_text[0].map(()=>{u=[...u,""]})),i({...n,new_data:{...n.new_data,template_name:e.name,language:e.language,variables:[...u]}})}})},[d]),s.useEffect(()=>{C(),E()},[]),s.useEffect(()=>{var t;const e=r.find(o=>o.name===n.new_data.template_name);e&&(V(e),F((t=e==null?void 0:e.components[0])==null?void 0:t.text))},[n,r]),console.log(d,"selectedTemplate"),console.log(y,"selectedLanguage"),console.log(h,"variables"),console.log(L,"selectedVariasbles"),console.log(n,"post data"),a.jsxs("div",{children:[a.jsx(G,{activeMenu:"Google Review",motherMenu:"Notification"}),a.jsx(M,{children:a.jsx(A,{children:a.jsx(v,{children:a.jsx(v.Body,{children:D?a.jsx(B,{}):a.jsxs(k,{responsive:!0,children:[a.jsxs("div",{className:`${Q["patient-grid-container"]}`,children:[a.jsxs("div",{className:"form-group mt-4",children:[a.jsx("label",{htmlFor:"",style:{color:"#000000"},children:"Template Name"}),a.jsx(z,{setValue:j,selectedValue:n.new_data.template_name,optionData:r})]}),a.jsxs("div",{className:"form-group mt-4",children:[a.jsx("label",{htmlFor:"",style:{color:"#000000"},className:"mb-1",children:"Language"}),a.jsx("input",{type:"text",className:"form-control input-default",placeholder:"",value:n.new_data.language,style:{height:"37px",marginBottom:"0.2rem",backgroundColor:"#F6F5F5"}})]}),n.new_data.variables&&n.new_data.variables.map((e,t)=>a.jsxs("div",{className:"form-group",children:[a.jsxs("label",{htmlFor:"",style:{color:"#000000"},className:"mb-1",children:["Variable ",t+1]}),a.jsx(H.Select,{"aria-label":"Default select example",value:e,onChange:o=>{R(o.target.value,t)},children:x.map((o,c)=>a.jsx("option",{value:o.value,children:o.name},c))})]}))]}),a.jsx("div",{className:"mt-3 d-flex justify-content-start",children:a.jsx(I,{type:"submit",onClick:P,className:"d-flex align-items-center justify-content-center",disabled:m,style:{transition:"transform 0.3s ease"},onMouseEnter:e=>e.target.style.transform="scale(1.1)",onMouseLeave:e=>e.target.style.transform="scale(1)",children:m?a.jsx(O,{as:"span",animation:"border",size:"sm",role:"status","aria-hidden":"true"}):"Save & Submit"})})]})})})})})]})};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.