PageSourceSearch

https://africaread.org/assets/cart-syvw6w7h.js

js africaread.org collected 2026-10-02 01:06:14 UTC 6,830 bytes, 1 lines download raw bytes

1import{M as Q}from"./MarketingLayout-CAN2G_Lq.js";import{u as K,e as O,w as W,v as Z,_ as j}from"./adminAccess-DDyblVml.js";import{B as J}from"./BookCoverFrame-COHEUBBZ.js";import{C as X}from"./CountryRequiredModal-BLLynOCb.js";import{u as tt}from"./cart-DeeUPIRT.js";import{u as et}from"./toast-FhuJbtrz.js";import{d as ot,c as d,a as k,o as at,b as r,e as n,g as t,F as w,z as A,A as _,G as st,t as s,u as C,k as v,w as rt,l as I,n as R}from"./core-CWlG7Rbl.js";import{u as nt}from"./useCurrency-vwo3Omvx.js";import{h as lt,b as ut}from"./countryRequirement-CpezHowP.js";import{i as U}from"./purchaseItems--g3oR7-M.js";import{I as B}from"./info-CzYHbEJz.js";import{m as it,w as ct}from"./helpers-CJO_XKgG.js";import"./index-3Oivko5n.js";import"./readLater-CVPt0fx6.js";import"./readerLibraryService-DXAVZF8l.js";import"./AppBrand-CLPEzrzx.js";import"./storeLinks-B-mt_OU7.js";import"./ToastHost-fvPvaKyn.js";import"./useRegisterModal-Db0seAlk.js";import"./mpa-BMok9DFU.js";import"./authService-DmtfWgn5.js";import"./AppModal-CAtpei0E.js";import"./modalScrollLock-iJnDNyTs.js";const dt={class:"page"},pt={key:0,class:"card loading"},mt={key:1,class:"card empty"},vt={key:2,class:"cart-shell enter-fade"},yt={class:"meta"},ft={class:"muted"},ht={class:"format"},_t={class:"actions"},bt={key:0,class:"quantity-control"},kt=["for"],Ct=["id","disabled","value","onChange"],gt={class:"price-stack"},wt={class:"price"},Pt={key:0,class:"price-note"},St=["onClick"],qt={class:"summary"},xt={class:"totals"},At={key:0,class:"discount-row"},It={class:"total-row"},Rt={class:"coupon-entry"},Ut=["disabled"],Bt=["disabled"],Mt={key:0,class:"error compact"},Dt={key:1,class:"applied-coupon"},$t=["disabled"],Nt={key:2,class:"error compact"},Tt={class:"note"},Vt={key:3,class:"note"},Lt=["disabled"],Ft=ot({__name:"CartView",setup(P){const u=tt(),b=K(),S=et(),l=d(()=>u.cart??{id:0,currency:"USD",subtotal:0,discount_total:0,tax_total:0,total:0,items:[]}),y=d(()=>u.items),M=d(()=>u.status==="loading"),D=d(()=>u.status==="loading"),f=d(()=>l.value.currency??"USD"),$=d(()=>y.value.some(a=>U(a))),g=k(!1),N=d(()=>b.isAuthenticated&&!lt(b.user)),T=d(()=>ut("/reader/profile","/checkout")),p=k(""),m=k(!1),i=k(""),{formatPrice:q}=nt();at(()=>{u.load()});function x(a){const e=a.metadata??{},o=e.display_currency??f.value,c=e.display_price??a.unit_price??null;return{displayCurrency:o,displayPrice:c}}function V(a){const{displayCurrency:e,displayPrice:o}=x(a);return q(o,e)}function h(a){return q(a,f.value)}function L(a){const{displayCurrency:e}=x(a);return e!==f.value&&a.unit_price!=null}function F(a){return a.format?.type??"Standard format"}async function z(a,e){const o=e.target,c=Number(o.value);if(!Number.isFinite(c)||c<1){o.value=String(a.quantity??1);return}try{await u.updateItem(a.id,c)}catch{S.error("Unable to update quantity."),o.value=String(a.quantity??1)}}async function E(a){try{await u.removeItem(a)}catch{S.error("Unable to remove item.")}}async function G(){const a=p.value.trim();if(a){m.value=!0,i.value="";try{await u.applyCoupon(a),p.value=""}catch(e){i.value=I(e,"Unable to apply coupon.")}finally{m.value=!1}}}async function Y(){m.value=!0,i.value="";try{await u.removeCoupon()}catch(a){i.value=I(a,"Unable to remove coupon.")}finally{m.value=!1}}function H(){if(y.value.length){if(!b.isAuthenticated){const a=encodeURIComponent("/checkout");R(`/login?redirect=${a}`);return}if(N.value){g.value=!0;return}R("/checkout")}}return(a,e)=>(r(),n(w,null,[t("section",dt,[e[11]||(e[11]=t("header",{class:"header"},[t("div",null,[t("h1",null,"Your cart"),t("p",{class:"muted"},"Review items before heading to checkout.")]),t("a",{href:"/bookstore",class:"ghost-link"},"Continue shopping")],-1)),M.value?(r(),n("section",pt,[(r(),n(w,null,A(3,o=>t("div",{key:`cart-skeleton-${o}`,class:"skeleton-line"})),64))])):y.value.length?(r(),n("section",vt,[_(O,{tag:"div",name:"cart-item",class:"cart-list"},{default:st(()=>[(r(!0),n(w,null,A(y.value,o=>(r(),n("article",{key:o.id,class:"cart-item"},[_(J,{class:"cover",src:o.book.cover_image_path,title:o.book.title,alt:""},null,8,["src","title"]),t("div",yt,[t("h2",null,s(o.book.title),1),t("p",ft,s(o.book.author?.display_name??"AfricaRead author"),1),t("p",ht,s(F(o)),1)]),t("div",_t,[C(U)(o)?(r(),n("div",bt,[t("label",{for:`qty-${o.id}`},"Qty",8,kt),t("input",{id:`qty-${o.id}`,type:"number",min:"1",disabled:D.value,value:o.quantity,onChange:c=>z(o,c)},null,40,Ct)])):v("",!0),t("div",gt,[t("span",wt,s(V(o)),1),L(o)?(r(),n("span",Pt," Charged in "+s(f.value)+": "+s(h(o.unit_price)),1)):v("",!0)]),t("button",{type:"button",class:"remove",onClick:c=>E(o.id)},"Remove",8,St)])]))),128))]),_:1}),t("aside",qt,[e[10]||(e[10]=t("h3",{class:"summary-title"},"Order summary",-1)),t("dl",xt,[t("div",null,[e[4]||(e[4]=t("dt",null,"Subtotal",-1)),t("dd",null,s(h(l.value.subtotal)),1)]),Number(l.value.discount_total??0)>
10?(r(),n("div",At,[e[5]||(e[5]=t("dt",null,"Discounts",-1)),t("dd",null,"-"+s(h(l.value.discount_total)),1)])):v("",!0),t("div",null,[e[6]||(e[6]=t("dt",null,"Tax",-1)),t("dd",null,s(h(l.value.tax_total)),1)]),t("div",It,[e[7]||(e[7]=t("dt",null,"Total",-1)),t("dd",null,s(h(l.value.total)),1)])]),l.value.coupon?(r(),n("div",Dt,[t("span",null,s(l.value.coupon.code)+" · "+s(l.value.coupon.discount_percent)+"% off",1),t("button",{type:"button",disabled:m.value,onClick:Y},"Remove",8,$t)])):(r(),n("form",{key:0,class:"coupon-form",onSubmit:W(G,["prevent"])},[e[8]||(e[8]=t("label",{for:"cart-coupon"},"Coupon code",-1)),t("div",Rt,[rt(t("input",{id:"cart-coupon","onUpdate:modelValue":e[0]||(e[0]=o=>p.value=o),type:"text",maxlength:"7",placeholder:"AR7K2P9",disabled:m.value,onInput:e[1]||(e[1]=o=>p.value=p.value.toUpperCase().replace(/[^A-Z0-9]/g,"").slice(0,7))},null,40,Ut),[[Z,p.value]]),t("button",{type:"submit",disabled:m.value||!p.value.trim()},"Apply",8,Bt)]),i.value?(r(),n("p",Mt,s(i.value),1)):v("",!0)],32)),l.value.coupon&&i.value?(r(),n("p",Nt,s(i.value),1)):v("",!0),t("p",Tt,[_(C(B),{size:15,class:"note-icon","aria-hidden":"true"}),t("span",null,"Your order total is charged in "+s(f.value)+".",1)]),$.value?(r(),n("p",Vt,[_(C(B),{size:15,class:"note-icon","aria-hidden":"true"}),e[9]||(e[9]=t("span",null,"Physical items require a delivery address at checkout.",-1))])):v("",!0),t("button",{type:"button",class:"primary",onClick:H,disabled:!y.value.length},s(C(b).isAuthenticated?"Proceed to checkout":"Sign in to checkout"),9,Lt)])])):(r(),n("section",mt,[...e[3]||(e[3]=[t("p",null,"Your cart is empty. Browse the bookstore to add titles.",-1),t("a",{href:"/bookstore",class:"primary"},"Browse bookstore",-1)])]))]),_(X,{open:g.value,"profile-href":T.value,onClose:e[2]||(e[2]=o=>g.value=!1)},null,8,["open","profile-href"])],64))}}),zt=j(Ft,[["__scopeId","data-v-6b797665"]]);function pe(){const P=ct(Q,zt);it(P)}export{pe as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.