import L from"./CWalxxGV.js";import U from"./a5umXhxZ.js";import E from"./GQCWnG0A.js";import{a as F,s as m,u as H,b as M,r as y,H as j,f as u,y as z,I as A,h as G,m as r,j as c,l as d,A as b,k as t,w as Q,p as s,T as Z,t as o,F as J,B as K,v as O,q as W,P as X,Q as Y}from"./BCLrUOBx.js";import{u as ee}from"./DamcjH0I.js";import"./Bxmfm8sn.js";const te={class:"vouchers-wrapper"},se={key:0,class:"spinner-wrapper flex"},oe={key:0,class:"info-msg"},ae={class:"flex wrap start align-start"},ne={class:"flex sided gap-15"},re={class:"semi-bold mx-w-400x mb-5"},ce={class:"semi-bold mb-5"},ie={class:"flex sided f-9"},ue={class:"semi-bold voucher mb-5"},de=["onClick"],le={class:"flex sided f-9 gap-15"},pe={class:"mb-5 color-lite"},_e={class:"mr-5"},me={class:"f-9 mb-5 color-danger"},he={class:"mr-5"},ge={class:"flow-hidden"},Se={__name:"Vouchers",props:{changingRoute:{type:Boolean,default:!0}},setup(w){const h=F(),{vouchers:i}=m(h),{setVouchers:V}=h,q=H(),{langCode:x}=m(q),g=M(),{currencyIcon:fe,setting:S}=m(g),{getRequest:T}=g,l=y(!1),f=y(""),n=j(),{getPriceType:k}=ee();u(()=>S.value.currency_position);const C=u(()=>{var e;return(e=i.value)==null?void 0:e.current_page}),B=u(()=>{var e;return(e=i.value)==null?void 0:e.last_page}),p=u(()=>{var e;return(e=i.value)==null?void 0:e.data}),$=e=>{navigator.clipboard.writeText(e.code),f.value=e.id},{getTimeZone:P}=z(),v=async()=>{var _;l.value=!0;const e=await T({api:"userVouchers",params:`?${X({time_zone:P(),order_by:n.query.orderBy||"created_at",type:n.query.orderByType||"desc",page:n.query.page||1,q:n.query.q||null})}`,lang:x.value});(e==null?void 0:e.status)===201?Y({statusCode:400,message:(_=e.data)==null?void 0:_.form[0]}):V(e.data),l.value=!1};return A(()=>n.query,async()=>{await v()}),G(async()=>{i.value||await v()}),(e,_)=>{const R=L,N=U,D=E;return c(),r("div",te,[d(Z,{name:"fade",mode:"out-in"},{default:Q(()=>[s(l)?(c(),r("div",se,[d(R,{radius:100})])):b("",!0)]),_:1}),s(p)&&!s(p).length?(c(),r("div",oe,o(e.$t("vouchers.noVoucher")),1)):b("",!0),t("div",ae,[(c(!0),r(J,null,K(s(p),(a,I)=>(c(),r("div",{class:"card p-15 pt-10 pb-5 mb-15",key:I},[t("div",ne,[t("h5",re,o(a.title),1),t("h4",ce,o(s(k)(a)),1)]),t("div",ie,[t("h6",ue,o(a.code),1),t("button",{"aria-label":"submit",onClick:O(ve=>$(a),["prevent"]),class:"lite-btn mb-5"},o(s(f)===a.id?e.$t("filter.copied"):e.$t("filter.copy")),9,de)]),t("div",le,[t("p",pe,[t("span",_e,o(e.$t("vouchers.minSpend")),1),t("b",null,[d(N,{price:a.min_spend},null,8,["price"])])]),t("p",me,[t("span",he,o(e.$t("vouchers.valid")),1),W(" "+o(a.end_time),1)])])]))),128))]),t("div",ge,[d(D,{ref:"voucherPagination","total-page":s(B),page:s(C),"changing-route":w.changingRoute},null,8,["total-page","page","changing-route"])])])}}};export{Se as default};
