import A from"./C-Tw4iS-.js";import F from"./Bvs3L9q-.js";import U from"./9v3tgSYW.js";import{b as q,s as S,d as G,e as H,u as X,r as c,f as x,i as z,w as b,j as n,k as t,l as f,m as i,A as y,p as o,t as r,v as J,F as P,B,C as K,D as Q,G as W,E as Z,q as $,_ as tt,P as et,J as st}from"./BCLrUOBx.js";import{_ as rt}from"./CglRsQQc.js";import{h as w}from"./zH0z38ay.js";import{u as ot}from"./CCot8u0_.js";import"./CWalxxGV.js";import"./Bxmfm8sn.js";const at=""+new URL("track-order.DL6sX3rI.png",import.meta.url).href,nt={class:"mtb-20 pb-30"},lt={class:"container"},dt={class:"track-container"},it={class:"form-wrapper"},ct={class:"page-title mt-10"},ut={class:"mt-10 mb-30 mb-sm-15 f-12"},mt={key:0,class:"error-list mb-15"},pt={class:"mb-30 mb-sm-15"},_t={class:"icon-input"},ft=["placeholder"],ht={key:0,class:"error"},gt={class:"mb-30 mb-sm-15"},vt={key:0,class:"tracked-result"},kt={class:"mb-20 mt-20"},bt={class:"delivery-container"},yt={class:"mb-20"},$t={class:"ordered-product mb-20"},Tt={__name:"track-order",setup(wt){var Y;const D=q(),{customScripts:Dt,site_setting:O}=S(D),{unAuthPost:C}=D,{t:m}=G(),{pageMeta:L}=ot();H(L({...O.value,meta_title:`${m("header.trackOrder")} | ${(Y=O.value)==null?void 0:Y.meta_title}`}));const V=X(),{langData:Ot,currentLanguage:Mt,langCode:E}=S(V),h=c(!1),p=c(!1),_=c([]),l=c(null),d=c(null),N=x(()=>m("header.trackOrder")),T=()=>(l.value.ordered_products.forEach(e=>{let s=w(l.value.created_at,"YYYY-MM-DD").add(e.shipping_place.day_needed,"days");w().diff(s,"days")>=0&&(s=w().add(1,"days"));const g=s.format("MMM").toLowerCase(),v=s.format("DD"),k=s.format("YYYY");e.delivery=m("date.MMMDDYYYY",{mon:m(`date.${g}`),date:v,year:k})}),l.value),M=c(null),I=async()=>{var e;if(d.value){h.value=!0;const s=await C({params:`?${et({tracking_id:d.value})}`,lang:E.value,api:"trackOder"});if((s==null?void 0:s.status)===200){p.value=!1,_.value=[],l.value=s.data,T(),await st();const u=M.value;u&&u.scrollIntoView({behavior:"smooth"})}else _.value=(e=s==null?void 0:s.data)==null?void 0:e.form;h.value=!1}else p.value=!0};return(e,s)=>{const u=A,g=F,v=U,k=tt,R=rt;return n(),z(R,null,{default:b(()=>[t("div",nt,[t("div",lt,[f(u,{page:o(N)},null,8,["page"]),t("div",dt,[t("div",it,[t("h1",ct,r(e.$t("trackOrder.trackOrder")),1),t("p",ut,r(e.$t("trackOrder.haveAnOrder")),1),t("form",{class:"track-form user-form",onSubmit:J(I,["prevent"])},[o(_).length?(n(),i("ul",mt,[t("li",null,r(e.$t("forgotPassword.errorOccurred")),1),(n(!0),i(P,null,B(o(_),(a,j)=>(n(),i("li",{key:j},r(a),1))),128))])):y("",!0),t("h4",pt,[t("b",null,r(e.$t("trackOrder.enterCode")),1)]),t("div",{class:K(["input-wrap",{invalid:!o(d)&&o(p)}])},[t("label",null,r(e.$t("addressPopup.order")),1),t("div",_t,[s[1]||(s[1]=t("i",{class:"icon order-icon"},null,-1)),Q(t("input",{type:"text","onUpdate:modelValue":s[0]||(s[0]=a=>W(d)?d.value=a:null),placeholder:e.$t("contact.your",{type:e.$t("addressPopup.order")})+". eg. 20230704N2H5X2"},null,8,ft),[[Z,o(d)]])]),!o(d)&&o(p)?(n(),i("span",ht,r(e.$t("addressPopup.isRequired",{type:e.$t("addressPopup.order")})),1)):y("",!0)],2),t("h6",gt,r(e.$t("trackOrder.knowProgress")),1),t("div",{ref_key:"submitBtn",ref:M,class:"flex right no-space"},[f(g,{class:"primary-btn plr-20 w-50","fetching-data":o(h),"loading-text":e.$t("forgotPassword.registering")},{default:b(()=>[$(r(e.$t("ajaxButton.submit")),1)]),_:1},8,["fetching-data","loading-text"])],512)],32)]),s[2]||(s[2]=t("div",{class:"img-wrap"},[t("img",{src:at,alt:"Error image",height:"50",width:"50"})],-1))]),o(l)?(n(),i("div",vt,[t("h3",kt,r(e.$t("trackOrder.orderStatus")),1),f(v,{class:"mb-30 mt-20","status-of-order":o(l).status},null,8,["status-of-order"]),t("div",bt,[t("h3",yt,r(e.$t("trackOrder.estimatedDelivery")),1),t("div",null,[(n(!0),i(P,null,B(o(l).ordered_products,a=>(n(),i("div",$t,[t("h5",null,[f(k,{to:e.productLink(a.product),class:"title",title:a.product.title},{default:b(()=>[$(r(a.product.title),1)]),_:2},1032,["to","title"])]),t("h5",null,[$(r(e.$t("trackOrder.estimated"))+": ",1),t("b",null,r(a.delivery),1)])]))),256))])])])):y("",!0)])])]),_:1})}}};export{Tt as default};
