import{_ as e}from"./Iog--8e0.js";import{b as a,g as s,a as r,h as l,f as t,i as o,l as d,_ as i}from"./CFjCYvyP.js";import{_ as c}from"./B_j9Rk0k.js";import{c as n,w as u,A as p,L as m,M as v,$ as _,a2 as x,u as b,G as f,O as g,_ as h,a7 as y,ay as $,x as k,a8 as T,H as E,P as F,a5 as S,W as w}from"./DOfEu912.js";import{c as L,a as z}from"./CEGPHBTU.js";const j={class:"container"},D={"data-aos":"fade-right",class:"my-10 max-w-[992px] mx-auto"},I={class:"font-bold text-xl sm:text-2xl mb-6 pb-6 border-b border-[#D1D1D6]"},C={key:0,class:"p-4 lg:p-8 bg-[#F9F9F9]"},A={class:"font-bold text-xl sm:text-2xl mb-6 pb-6 border-b border-[#D1D1D6]"},U={class:"flex justify-between mb-8 font-medium text-lg items-center gap-4 flex-wrap"},V={key:0,class:"space-y-8"},q=["name","id","value"],O=["onClick"],R={class:"flex-1 flex items-center gap-5"},B=["src","alt"],N={class:"space-y-6"},P={class:"text-primary font-medium line-clamp-1"},G={class:"flex text-[#797979] text-lg items-center gap-2"},H={class:"font-bold text-xl text-primary"},M={key:0},W={key:1,class:"flex items-center gap-2"},X={class:"line-through text-desc"},J={class:"flex-shrink-0 lg:ms-auto"},K={class:"px-8 py-2 bg-[#F5F5F5] text-center text-2xl font-medium"},Q={class:"my-8"},Y={class:"mb-8"},Z=["disabled","loading"],ee={__name:"return",setup(ee){const{t:ae}=a(),se=s(),re=r().$axios,le=l(),te=t(),{data:oe,status:de,refresh:ie}=o("order-details",(()=>re(`orders/${le.params.slug}`).then((e=>e.data.data)).catch((e=>e.response.data)))),ce=n([]);u((()=>oe.value),(e=>{var a;(null==(a=null==e?void 0:e.products)?void 0:a.length)&&(ce.value=e.products.map((e=>e.product_order_id)))}),{immediate:!0,deep:!0});const ne=e=>{ce.value.includes(e)?ce.value=ce.value.filter((a=>a!==e)):ce.value.push(e)},ue=n(L().shape({reason:z().required(ae("ERRORS.reason"))})),pe=n({reason:null}),me=n(!1),ve=async e=>{const a=new FormData;a.append("reason",e.reason),ce.value.map(((e,s)=>{a.append(`order_product_ids[${s}]`,e)})),me.value=!0;try{const e=await re.post(`orders/${le.params.slug}/return_order`,a);d.success(e.data.message),se.push(te(`/order/tracking-order/${le.params.slug}`))}catch(s){d.error(s.response.data.message)}finally{me.value=!1}};return(a,s)=>{var r,l,t,o,d;const n=e,u=i,L=c,z=p("VeeForm");return m(),v("div",j,[_("div",D,[_("h2",I,x(a.$t("TITLES.return_order")),1),"success"===b(de)&&(null==(r=b(oe))?void 0:r.products)?(m(),v("div",C,[_("h3",A,x(a.$t("TITLES.order_details")),1),_("div",U,[_("div",null,x(a.$t("TITLES.order"))+" : "+x(b(oe).order_no),1)]),(null==(l=b(oe))?void 0:l.products)&&(null==(o=null==(t=b(oe))?void 0:t.products)?void 0:o.length)?(m(),v("div",V,[(m(!0),v(f,null,g(null==(d=b(oe))?void 0:d.products,(e=>(m(),v("div",{key:e.product_order_id,class:h(["flex lg:items-center border bg-white border-[#E1E1E1] p-5 flex-wrap flex-col lg:flex-row gap-5",{"border-primary bg-[#FAFAFA]":b(ce).includes(e.product_order_id)}])},[y(_("input",{type:"checkbox",name:`checked_${e.product_order_id}`,id:`id_${e.product_order_id}`,value:e.product_order_id,class:"hidden","onUpdate:modelValue":s[0]||(s[0]=e=>k(ce)?ce.value=e:null)},null,8,q),[[$,b(ce)]]),y(_("span",{onClick:a=>ne(e.product_order_id),class:"block size-[30px] border rounded-full border-primary cursor-pointer"},null,8,O),[[T,!b(ce).includes(e.product_order_id)]]),y(E(n,{onClick:a=>ne(e.product_order_id),name:"checked",class:"cursor-pointer"},null,8,["onClick"]),[[T,b(ce).includes(e.product_order_id)]]),_("div",R,[E(u,{to:b(te)(`/product/${e.product_id}?color=${e.color_id}&size=${e.size_id}`),class:"block flex-shrink-0 relative z-0"},{default:F((()=>{var a,s;return[(null==e?void 0:e.images)&&(null==(a=null==e?void 0:e.images)?void 0:a.length)?(m(),v("img",{key:0,src:null==(s=null==e?void 0:e.images[0])?void 0:s.media,alt:e.title,class:"size-[128px] object-cover"},null,8,B)):w("",!0)]})),_:2},1032,["to"]),_("div",N,[E(u,{to:b(te)(`/product/${e.product_id}?color=${e.color_id}&size=${e.size_id}`)},{default:F((()=>[_("h3",P,x(e.title),1)])),_:2},1032,["to"]),_("div",G,[s[2]||(s[2]=S(" Color : ")),_("span",null,x(e.color)+" x"+x(e.quantity),1)]),_("div",H,[e.has_offer?(m(),v("div",W,[_("p",X,x(e.price)+" "+x(a.$t("TITLES.egp")),1),_("p",null,x(e.offer_price)+" "+x(a.$t("TITLES.egp")),1)])):(m(),v("p",M,x(e.price)+" "+x(a.$t("TITLES.egp")),1))])])]),_("div",J,[_("div",K," X "+x(e.quantity),1)])],2)))),128))])):w("",!0),_("div",Q,[E(z,{"validation-schema":b(ue),onSubmit:ve,initialValues:b(pe)},{default:F((()=>[_("div",Y,[E(L,{name:"reason",label:a.$t("LABELS.reason"),placeholder:a.$t("INPUTS.reason"),type:"textarea",value:b(pe).reason,"onUpdate:value":s[1]||(s[1]=e=>b(pe).reason=e)},null,8,["label","placeholder","value"])]),_("div",null,[_("button",{disabled:b(me),loading:b(me),type:"submit",class:"base-btn capitalize w-full mb-2"},x(a.$t("BUTTONS.confirm")),9,Z)])])),_:1},8,["validation-schema","initialValues"])])])):w("",!0)])])}}};export{ee as default};
