import{i as I,v as G,x as H,r as u,k as D,l,w as t,m as n,o as S,p as V,u as o,y as i,t as s,F as J,z as K,A as N,B as O}from"./entry.b3b9f8ed.js";import{a as W}from"./axios.4a32a752.js";const X={class:"d-flex align-center flex-column"},Y=s("thead",null,[s("tr",null,[s("th",{class:"text-left"},"Medicine"),s("th",{class:"text-left"},"Quantity"),s("th",{class:"text-left"},"Details")])],-1),Z=s("br",null,null,-1),$=s("br",null,null,-1),tl={__name:"index",setup(h){const R=I(),F=G(),L=H();let M=u([]),b=u(0),y=u(""),x=u(""),_=u(""),f=u(0),p=u(""),m=u(!1),g=u("");u(!1),u();let Q=new Date,C=u(Q.toDateString());function T(v,a,k){M.value.push({medicinename:v,quantity:a,details:k}),_.value="",f.value="",p.value="",m.value=!1}async function E(){try{let v={data:{slipdate:C.value,clientname:`${x.value}, ${y.value}`,availability:b.value,slipmeta:M.value,description:g.value}};const a=await W.post(`${R.CMS_BASE_URL}/api/slips`,v);a&&(L.success("Successfully Created Medicine Slip"),F.push({path:`/create/${a.data.data.attributes.publicid}`}))}catch(v){console.log(v)}}return(v,a)=>{const k=n("v-card-title"),r=n("v-text-field"),d=n("v-col"),c=n("v-row"),w=n("v-divider"),P=n("v-table"),U=n("v-btn"),A=n("v-card-text"),q=n("v-card-actions"),B=n("v-card"),j=n("v-dialog"),z=n("v-textarea");return S(),D("div",X,[l(B,{width:"800"},{default:t(()=>[l(k,null,{default:t(()=>[V("Create New Medical Slip")]),_:1}),l(A,null,{default:t(()=>[l(c,{justify:"end"},{default:t(()=>[l(d,{cols:"12",sm:"6"},{default:t(()=>[l(r,{label:"Date",modelValue:o(C),"onUpdate:modelValue":a[0]||(a[0]=e=>i(C)?C.value=e:C=e)},null,8,["modelValue"])]),_:1}),l(d,{cols:"12",sm:"6"},{default:t(()=>[l(r,{label:"Usage Count",modelValue:o(b),"onUpdate:modelValue":a[1]||(a[1]=e=>i(b)?b.value=e:b=e)},null,8,["modelValue"])]),_:1})]),_:1}),l(c,null,{default:t(()=>[l(d,{cols:"12",sm:"6"},{default:t(()=>[l(r,{modelValue:o(x),"onUpdate:modelValue":a[2]||(a[2]=e=>i(x)?x.value=e:x=e),label:"Family Name"},null,8,["modelValue"])]),_:1}),l(d,{cols:"12",sm:"6"},{default:t(()=>[l(r,{modelValue:o(y),"onUpdate:modelValue":a[3]||(a[3]=e=>i(y)?y.value=e:y=e),label:"First Name"},null,8,["modelValue"])]),_:1}),l(w)]),_:1}),l(c,null,{default:t(()=>[l(d,null,{default:t(()=>[l(P,null,{default:t(()=>[Y,s("tbody",null,[(S(!0),D(J,null,K(o(M),e=>(S(),D("tr",{key:e.medicinename},[s("td",null,N(e.medicinename),1),s("td",null,N(e.quantity),1),s("td",null,N(e.details),1)]))),128))])]),_:1}),Z,$,l(c,null,{default:t(()=>[l(j,{modelValue:o(m),"onUpdate:modelValue":a[9]||(a[9]=e=>i(m)?m.value=e:m=e),width:"600",height:"600",persistent:""},{activator:t(({props:e})=>[l(U,O({block:"",color:"blue"},e),{default:t(()=>[V("Add Medicine")]),_:2},1040)]),default:t(()=>[l(B,null,{default:t(()=>[l(k,null,{default:t(()=>[V("Add Medicine")]),_:1}),l(w),l(A,null,{default:t(()=>[l(c,null,{default:t(()=>[l(d,{cols:"12",md:"4"},{default:t(()=>[l(r,{modelValue:o(_),"onUpdate:modelValue":a[4]||(a[4]=e=>i(_)?_.value=e:_=e),label:"Medicine Name",required:""},null,8,["modelValue"])]),_:1}),l(d,{cols:"12",md:"4"},{default:t(()=>[l(r,{modelValue:o(f),"onUpdate:modelValue":a[5]||(a[5]=e=>i(f)?f.value=e:f=e),label:"Quantity",required:""},null,8,["modelValue"])]),_:1}),l(d,{cols:"12",md:"4"},{default:t(()=>[l(r,{modelValue:o(p),"onUpdate:modelValue":a[6]||(a[6]=e=>i(p)?p.value=e:p=e),label:"Details",required:""},null,8,["modelValue"])]),_:1})]),_:1})]),_:1}),l(q,null,{default:t(()=>[l(c,null,{default:t(()=>[l(d,{cols:"12",md:"6"},{default:t(()=>[l(U,{block:"",color:"error",onClick:a[7]||(a[7]=e=>i(m)?m.value=!1:m=!1)},{default:t(()=>[V("Close Dialog")]),_:1})]),_:1}),l(d,{cols:"12",md:"6"},{default:t(()=>[l(U,{block:"",color:"success",onClick:a[8]||(a[8]=e=>T(o(_),o(f),o(p)))},{default:t(()=>[V("Add")]),_:1})]),_:1})]),_:1})]),_:1})]),_:1})]),_:1},8,["modelValue"])]),_:1})]),_:1}),l(w)]),_:1}),l(c,null,{default:t(()=>[l(d,null,{default:t(()=>[l(z,{label:"Additional Instructions",modelValue:o(g),"onUpdate:modelValue":a[10]||(a[10]=e=>i(g)?g.value=e:g=e)},null,8,["modelValue"])]),_:1})]),_:1})]),_:1}),l(q,null,{default:t(()=>[l(U,{block:"",variant:"tonal",color:"green",onClick:E},{default:t(()=>[V("Save")]),_:1})]),_:1})]),_:1})])}}};export{tl as default};
