import{_ as b,f as i,o as D,g as k,i as n,t as d,h as s,w as l,p as _}from"./app-ff872a97.js";const w={data:()=>({cancelOrderID:null,dialog:!1,currentPage:1,lastPage:1,assignedDeliveries:[]}),computed:{headers(){return[{title:this.$i18n.t("code"),align:"start",sortable:!1,value:"code"},{title:this.$i18n.t("amount"),sortable:!1,align:"start",value:"grand_total"},{title:this.$i18n.t("delivery_status"),sortable:!1,align:"start",value:"delivery_status"},{title:this.$i18n.t("payment_status"),sortable:!1,align:"start",value:"payment_status"},{title:this.$i18n.t("delivered"),sortable:!1,align:"center",value:"delivered"},{title:this.$i18n.t("options"),sortable:!1,align:"center",value:"options"}]}},methods:{async getOnTheWayDeliveries(e){this.loading=!0;const t=await this.call_api("get",`delivery-boy/on-the-way-deliveries?page=${e}`);t.status==200?(this.assignedDeliveries=t.data.data.data,this.lastPage=t.data.data.last_page,this.currentPage=t.data.data.current_page):this.snack({message:this.$i18n.t("something_went_wrong"),color:"red"}),this.loading=!1},openOrderDetails(e){this.$router.push({name:"DeliveryboyOrderDetails",params:{code:e.code}})},async updateOrderStatus(e){const t=await this.call_api("post","delivery-boy/update-delivery-status",{status:"delivered",order_id:e});this.snack({message:t.data.message,color:"green"}),this.getOnTheWayDeliveries()},async caneclRequest(){this.dialog=!1;const e=await this.call_api("post","delivery-boy/cancel-request",{order_id:this.cancelOrderID});this.snack({message:e.data.message,color:"green"}),this.getOnTheWayDeliveries()}},created(){let e=this.$route.query.page||this.currentPage;this.getOnTheWayDeliveries(e)}},$={class:"ps-lg-7 pt-4"},O={class:"fs-24 fw-700 opacity-80 mb-5 mt-3"},C={class:"d-block fw-600"},V=["onClick"],P=n("i",{class:"las la-times text-danger"},null,-1),T=[P],W=["onClick"],q=n("i",{class:"las la-bars"},null,-1),x=[q],B={class:"w-100 text-center mb-4"},I={class:"text-start"};function N(e,t,S,U,R,o){const c=i("v-btn"),u=i("v-switch"),v=i("v-card-title"),g=i("v-card-text"),h=i("v-card-actions"),p=i("v-card"),m=i("v-dialog"),f=i("v-data-table"),y=i("v-pagination");return D(),k("div",$,[n("h1",O,d(e.$t("on_the_way_delivery")),1),n("div",null,[s(f,{headers:o.headers,items:e.assignedDeliveries,class:"border px-4 pt-3","hide-default-footer":"","item-class":"c-pointer"},{"item.code":l(({item:a})=>[s(c,{onClick:r=>o.openOrderDetails(a.combined_order),variant:"flat",small:"",class:"px-2 text-primary"},{default:l(()=>[_(d(a.combined_order.code),1)]),_:2},1032,["onClick"])]),"item.grand_total":l(({item:a})=>[n("span",C,d(e.format_price(a.grand_total)),1)]),"item.delivered":l(({item:a})=>[s(u,{color:"success",value:"success","hide-details":"",onClick:r=>o.updateOrderStatus(a.id)},null,8,["onClick"])]),"item.options":l(({item:a})=>[n("a",{onClick:r=>(e.dialog=!0,e.cancelOrderID=a.id),class:"btn btn-soft-danger btn-icon btn-circle btn-sm mr-2"},T,8,V),n("a",{onClick:r=>o.openOrderDetails(a.combined_order),small:"",class:"px-2 btn btn-soft-info btn-icon btn-circle btn-sm hov-svg-white"},x,8,W),s(m,{modelValue:e.dialog,"onUpdate:modelValue":t[1]||(t[1]=r=>e.dialog=r),width:"auto"},{default:l(()=>[s(p,null,{default:l(()=>[s(v),s(g,null,{default:l(()=>[n("p",null,d(e.$t("are_you_sure_you_want_to_cancel_this_order")),1)]),_:1}),s(h,null,{default:l(()=>[n("div",B,[s(c,{class:"mx-1",color:"primary",variant:"text",onClick:o.caneclRequest},{default:l(()=>[_(d(e.$t("yes")),1)]),_:1},8,["onClick"]),s(c,{variant:"text",onClick:t[0]||(t[0]=r=>e.dialog=!1),class:"danger"},{default:l(()=>[_(d(e.$t("no")),1)]),_:1})])]),_:1})]),_:1})]),_:1},8,["modelValue"])]),_:2},1032,["headers","items"])]),n("div",I,[s(y,{modelValue:e.currentPage,"onUpdate:modelValue":[t[2]||(t[2]=a=>e.currentPage=a),o.getOnTheWayDeliveries],length:e.lastPage,"prev-icon":"las la-angle-left","next-icon":"las la-angle-right","total-visible":7,elevation:"0",class:"my-4"},null,8,["modelValue","onUpdate:modelValue","length"])])])}const j=b(w,[["render",N]]);export{j as default};
