import{_ as b,x as v,aB as x,r as F,cs as N,e as d,o as r,g as I,c as t,w as a,i as u,t as k,F as C,p as $,al as D,aq as V,bB as R,b as z,a as J,f as m,J as i,aC as Q,be as U,M as j,q as G,aw as H}from"./app-DNXD_-wA.js";import{P as g}from"./PaymentStatus--yEVc8lQ.js";import{S as M,b as K,a as L,M as W,O as X}from"./OrderDetails-DSBOwpnI.js";import{c as h}from"./cart-BwaMRFiZ.js";const Y=v({props:["order"],components:{EyeOutlined:x,StopOutlined:M,OrderStatus:K,PaymentStatus:g,OrderDetails:L},setup(){const{formatAmountCurrency:e}=h(),s=F(!1);return{visible:s,showModal:()=>{s.value=!0},columns:[{title:"#",dataIndex:"id"},{title:"Product",dataIndex:"product_id"},{title:"Quantity",dataIndex:"quantity"},{title:"Price",dataIndex:"unit_price"},{title:"Total",dataIndex:"subtotal"}],formatAmountCurrency:e,buildAddress:N}}});function Z(e,s,o,p,w,S){const _=d("eye-outlined"),f=$,l=d("OrderDetails"),y=D;return r(),I(C,null,[t(f,{onClick:e.showModal},{default:a(()=>[t(_),u(" "+k(e.$t("stock.view_order")),1)]),_:1},8,["onClick"]),t(y,{open:e.visible,"onUpdate:open":s[0]||(s[0]=O=>e.visible=O),width:"70%",footer:!1},{title:a(()=>[u(k(e.order.invoice_number),1)]),default:a(()=>[t(l,{order:e.order},null,8,["order"])]),_:1},8,["open"])],64)}const ee=b(Y,[["render",Z]]),te=v({props:["data"],emits:["reloadOrders"],components:{EyeOutlined:x,DeleteOutlined:V,MoreOutlined:W,StopOutlined:M,DownloadOutlined:R,PaymentStatus:g,OrderStatus:X,OrderDetailsModal:ee},setup(e,{emit:s}){const{t:o}=z(),{formatDateTime:p}=J(),{formatAmountCurrency:w}=h();return{columns:[{title:"Date",dataIndex:"order_date"},{title:"Total",dataIndex:"total"},{title:"Order Status",dataIndex:"order_status"},{title:"Payment Status",dataIndex:"payment_status"},{title:"Action",dataIndex:"action"}],cancelOrder:l=>{D.confirm({title:o("common.delete")+"?",icon:t(Q),content:o("stock.order_cancel_message"),centered:!0,okText:o("common.yes"),okType:"danger",cancelText:o("common.no"),onOk(){axiosFront.post(`front/self/cancel-order/${l}`).then(y=>{s("reloadOrders"),U.success({message:o("common.success"),description:o("stock.order_canceled"),placement:"bottomRight"})})},onCancel(){}})},downloadInvoice:l=>{window.location.href=window.config.path+"/api/v1/pdf/"+l},formatAmountCurrency:w,formatDateTime:p}}});function oe(e,s,o,p,w,S){const _=d("PaymentStatus"),f=d("OrderStatus"),l=d("OrderDetailsModal"),y=d("stop-outlined"),O=$,T=d("download-outlined"),P=j,q=d("more-outlined"),A=G,B=H;return r(),m(B,{columns:e.columns,"row-key":c=>c.id,"data-source":e.data,pagination:!1},{bodyCell:a(({column:c,record:n})=>[c.dataIndex==="order_date"?(r(),I(C,{key:0},[u(k(e.formatDateTime(n.order_date)),1)],64)):i("",!0),c.dataIndex==="total"?(r(),I(C,{key:1},[u(k(e.formatAmountCurrency(n.total)),1)],64)):i("",!0),c.dataIndex==="payment_status"?(r(),m(_,{key:2,paymentStatus:n.payment_status},null,8,["paymentStatus"])):i("",!0),c.dataIndex==="order_status"?(r(),m(f,{key:3,data:n},null,8,["data"])):i("",!0),c.dataIndex==="action"?(r(),m(A,{key:4,placement:"bottomRight"},{overlay:a(()=>[t(P,null,{default:a(()=>[t(l,{order:n},null,8,["order"]),n.order_status=="ordered"&&!n.cancelled?(r(),m(O,{key:0,onClick:E=>e.cancelOrder(n.unique_id)},{default:a(()=>[t(y),u(" Cancel Order ")]),_:2},1032,["onClick"])):i("",!0),t(O,{onClick:E=>e.downloadInvoice(n.unique_id)},{default:a(()=>[t(T),u(" Download Invoice ")]),_:2},1032,["onClick"])]),_:2},1024)]),default:a(()=>[t(q,{style:{fontSize:"16px"}})]),_:2},1024)):i("",!0)]),_:1},8,["columns","row-key","data-source"])}const de=b(te,[["render",oe]]);export{de as O};
