import{_ as C}from"./Button.8c8352d3.js";import N from"./Icon.1464d3c9.js";import{_ as q}from"./Badge.73ba16f1.js";import{_ as S}from"./Table.e164c81e.js";import{_ as $}from"./Pagination.967f26ab.js";import{_ as w}from"./Input.7105798b.js";import{_ as R}from"./Textarea.7637503b.js";import{_ as T,a as A}from"./Modal.5478da99.js";import{u as F}from"./useToast.95f42666.js";import{bq as D,aL as m,o as h,y as V,w as v,b as i,a as B,t as M,ah as y,ba as u,bD as z,bF as E,bE as L,c as P,d as j,T as I,F as G}from"./entry.816e6e91.js";const H={class:"flex items-center justify-between"},J={class:"text-base font-semibold leading-6 text-gray-900 dark:text-white mb-0"},K={__name:"Update",props:{orderData:{type:Object},isOpen:{type:Boolean,default:!1}},emits:["close-modal"],setup(p,{emit:n}){const d=p,k=n;D(()=>d.isOpen,e=>{e&&(r.value.shipping_cost="",r.value.note=""),t.value=d.isOpen});let t=m(!1);D(()=>t.value,e=>{e===!1&&k("close-modal")});const x=F();let r=m({shipping_cost:"",note:"",_method:"put"});const o=m(!1),U=async()=>{var l,_,b,f,g;o.value=!0;const{data:e,pending:a}=await z({url:`orders/update/${(l=d.orderData)==null?void 0:l.id}`,method:"post"},{body:{...r.value}});o.value=a.value,(_=e==null?void 0:e.value)!=null&&_.status?(t.value=!1,x.add({title:(b=e==null?void 0:e.value)==null?void 0:b.message})):((f=e==null?void 0:e.value)==null?void 0:f.status)===0&&x.add({title:(g=e==null?void 0:e.value)==null?void 0:g.message,color:"red"})};return(e,a)=>{const l=C,_=w,b=R,f=T,g=A;return h(),V(g,{modelValue:u(t),"onUpdate:modelValue":a[3]||(a[3]=s=>y(t)?t.value=s:t=s),class:"ui__card"},{default:v(()=>[i(f,{ui:{ring:"",divide:"divide-y divide-gray-100 dark:divide-gray-800"}},{header:v(()=>{var s;return[B("div",H,[B("h3",J,"Update "+M((s=p.orderData)==null?void 0:s.customer_username)+" Order",1),i(l,{color:"gray",variant:"ghost",icon:"i-heroicons-x-mark-20-solid",class:"-my-1",onClick:a[0]||(a[0]=O=>y(t)?t.value=!1:t=!1)})])]}),footer:v(()=>[i(l,{label:"Submit",variant:"solid",size:"lg",disabled:u(o),onClick:U},null,8,["disabled"])]),default:v(()=>[i(_,{class:"mb-3",label:"Shipping Cost",placeholder:"Shipping Cost",modelValue:u(r).shipping_cost,"onUpdate:modelValue":a[1]||(a[1]=s=>u(r).shipping_cost=s)},null,8,["modelValue"]),i(b,{label:"Note",placeholder:"Note",modelValue:u(r).note,"onUpdate:modelValue":a[2]||(a[2]=s=>u(r).note=s)},null,8,["modelValue"])]),_:1})]),_:1},8,["modelValue"])}}},ne={__name:"List",props:{pending:{type:Boolean,default:!0},data:{type:Array,default:()=>[]},page:{type:Number,default:1},total:{type:Number,default:1}},setup(p){let n=m(!1),d=m({});const k=E(),t=L(),x=p,r=[{key:"id",label:"ID",sortable:!0},{key:"customer_username",label:"Username",sortable:!0},{key:"customer_mobile_number",label:"Phone"},{key:"physical_address",label:"Address"},{key:"shipping_cost",label:"Shipping"},{key:"total",label:"Total",sortable:!0},{key:"status",label:"Status",sortable:!0},{key:"action",label:"Action"}];let o=m();o.value=x.page;let U=m(""),e=m("");return D(()=>k.query,()=>{U.value=t.currentRoute.value.query.status,e.value=t.currentRoute.value.query.search,o.value=+k.query.page||x.page},{immediate:!0}),D(o,()=>{t.push({query:{page:o.value,search:e.value,status:U.value}})}),(a,l)=>{const _=C,b=N,f=q,g=S,s=$,O=K;return h(),P(G,null,[i(g,{columns:r,rows:p.data,loading:p.pending,"loading-state":{label:"Loading..."}},{"action-data":v(({row:c})=>[c.status=="inProgress"?(h(),V(_,{key:0,size:"xs",icon:"i-heroicons-pencil-square",label:"Edit",color:"sky",variant:"soft",onClick:Q=>(y(n)?n.value=!0:n=!0,y(d)?d.value=c:d=c)},null,8,["onClick"])):(h(),V(f,{key:1,size:"xs",color:"red",variant:"soft"},{default:v(()=>[i(b,{name:"i-heroicons-no-symbol",class:"me-1"}),j(" No actions")]),_:1}))]),_:1},8,["rows","loading","loading-state"]),i(s,{modelValue:u(o),"onUpdate:modelValue":l[0]||(l[0]=c=>y(o)?o.value=c:o=c),"page-count":10,total:p.total},null,8,["modelValue","total"]),(h(),V(I,{to:"body"},[i(O,{isOpen:u(n),orderData:u(d),onCloseModal:l[1]||(l[1]=c=>y(n)?n.value=!1:n=!1)},null,8,["isOpen","orderData"])]))],64)}}};export{ne as _};
