PageSourceSearch

https://secure.columbiagames.com/assets/WishlistPage-BC8Lc_8Q.js

js columbiagames.com collected 2026-09-24 10:00:39 UTC 5,969 bytes, 1 lines download raw bytes

1import{r as l,H as M,G as P,f as R,j as s,L as w,X as $,O as N,Y as D,Z as A}from"./index-W04rzwDS.js";import{r as Q}from"./ProductImage-DxdKdEFd.js";import{S as U}from"./StartCollectionCard-B8V4pb5G.js";function Y(a){return[a.category,a.subCategory,a.subCategory2].filter(Boolean).join(" / ")}function F(a){return[a.status,a.releaseDate?`Release: ${a.releaseDate}`:""].filter(Boolean).join(" · ")}function T(){const[a,d]=l.useState(null),[S,p]=l.useState(!0),[f,i]=l.useState(null),[k,u]=l.useState(!1),[C,c]=l.useState(null),[h,m]=l.useState({}),[g,o]=l.useState(null),[y,x]=l.useState(!1),{refresh:j}=M(),{refresh:v}=P(),q=R();async function W(){var t;p(!0),i(null);try{const e=await $();if(!e.ok){u(!0),d(null);return}u(!1),d(e.data??null);const n={};for(const r of((t=e.data)==null?void 0:t.items)??[])n[r.productId]=r.quantity;m(n)}catch(e){u(!1),i(e instanceof Error?e.message:"Wishlist request failed")}finally{p(!1)}}l.useEffect(()=>{W()},[]);const b=l.useMemo(()=>(a==null?void 0:a.meta.categories.join(", "))??"",[a]);async function B(t){c(t),i(null),o(null);try{const e=await D(t,Math.max(0,h[t]??0));if(!e.ok){u(!0);return}d(e.data),m(n=>({...n,[t]:Math.max(0,h[t]??0)})),await j(),o(`Saved wishlist quantity for ${t}.`)}catch(e){i(e instanceof Error?e.message:"Wishlist update failed")}finally{c(null)}}async function E(t){c(t),i(null),o(null);try{const e=await A(t);if(!e.ok){u(!0);return}d(e.data),m(n=>{const r={...n};return delete r[t],r}),await j(),o(`${t} removed from wishlist.`)}catch(e){i(e instanceof Error?e.message:"Wishlist remove failed")}finally{c(null)}}async function L(t){var n;const e=Math.max(1,h[t]??((n=a==null?void 0:a.items.find(r=>r.productId===t))==null?void 0:n.quantity)??1);c(t),i(null),o(null);try{await N(t,e),await v(),o(`${t} added to cart.`)}catch(r){i(r instanceof Error?r.message:"Could not add wishlist item to cart")}finally{c(null)}}async function I(){if(!(!a||a.items.length===0)){x(!0),i(null),o(null);try{for(const t of a.items){const e=Math.max(1,h[t.productId]??t.quantity??1);await N(t.productId,e)}await v(),q("/checkout")}catch(t){i(t instanceof Error?t.message:"Could not move wishlist items to cart")}finally{x(!1)}}}return S?s.jsx("p",{className:"start-muted",children:"Loading wishlist…"}):f?s.jsx("p",{className:"start-error",children:f}):k?s.jsxs("section",{className:"start-page start-stack",children:[s.jsxs("div",{className:"start-card",children:[s.jsx("h1",{children:"Wishlist"}),s.jsx("p",{className:"start-muted",children:"Please sign in to view the items you saved for later."})]}),s.jsxs("div",{className:"start-card",children:[s.jsx("p",{className:"start-error",children:"Please log in to view or edit wishlist items."}),s.jsx(w,{className:"start-button-link",to:"/account",children:"Go to account login"})]})]}):!a||!a.meta.hasItems?s.jsx("section",{className:"start-page start-stack",children:s.jsxs("div",{className:"start-card",children:[s.jsx("div",{className:"start-page-header",children:s.jsxs("div",{children:[s.jsx("h1",{children:"Wishlist"}),s.jsx("p",{className:"start-muted",children:"Saved items will appear here once you add them from the catalog. Use the wishlist to park products for later, adjust quantities, and move selected items into the cart when you are ready to buy."})]})}),s.jsxs("div",{className:"start-card start-empty-state",children:[s.jsx("p",{children:"No wishlist items are stored for this account."}),s.jsx(w,{to:"/products",children:"Browse products"})]})]})}):s.jsxs("section",{className:"start-page start-wishlist-page start-stack",children:[s.jsxs("div",{className:"start-card",children:[s.jsxs("div",{className:"start-page-header",children:[s.jsxs("div",{children:[s.jsx("h1",{children:"Wishlist"}),s.jsxs("p",{className:"start-muted",children:[a.meta.count," saved item",a.meta.count===1?"":"s"," · total quantity ",a.meta.totalQuantity]})]}),s.jsx("div",{className:"start-action-row",children:s.jsx("button",{type:"button",onClick:()=>void I(),disabled:y,children:y?"Sending to checkout…":"Buy all now"})})]}),s.jsxs("div",{className:"start-card start-wishlist-summary-card",children:[s.jsx("p",{className:"start-muted start-compact-copy",children:b?`Categories: ${b}`:"Everything you saved is ready to revisit here."}),s.jsx("p",{className:"start-muted start-compact-copy",children:"Your wishlist keeps interesting products in one place without adding them to the cart immediately. You can update quantities, remove items, or send everything to checkout when you are ready."}),g?s.jsx("p",{className:"start-success",children:g}):null]})]}),s.jsx("div",{className:"start-product-grid start-wishlist-grid",children:a.items.map(t=>{const e=C===t.productId;return s.jsx(U,{href:`/products/${encodeURIComponent(t.productId)}`,title:t.description,productId:t.productId,categoryLabel:Y(t),priceLabel:t.price||"—",summary:F(t),imageUrl:Q(t.image,{width:360,format:"webp"}
1),imageAlt:t.description,cornerBadge:t.isDownloadable?"Saved download":void 0,badges:s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"start-badge",children:["Saved × ",t.quantity]}),t.preorder?s.jsx("span",{className:"start-badge",children:"Preorder"}):null,t.isDownloadable?s.jsx("span",{className:"start-badge",children:"Downloadable"}):null]}),actions:s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"start-qty-input start-compact-label",children:[s.jsx("span",{children:"Qty"}),s.jsx("input",{type:"number",min:0,max:999,value:h[t.productId]??t.quantity,onChange:n=>m(r=>({...r,[t.productId]:Math.max(0,Number(n.target.value)||0)}))})]}),s.jsx("button",{type:"button",disabled:e,onClick:()=>void B(t.productId),children:e?"Saving…":"Save qty"}),s.jsx("button",{type:"button",className:"start-button-secondary",disabled:e,onClick:()=>void E(t.productId),children:"Remove"}),s.jsx("button",{type:"button",className:"start-button-secondary",disabled:e||y,onClick:()=>void L(t.productId),children:"Add to cart"})]})},t.productId)})})]})}export{T as WishlistPage};

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.