veza/apps/web/dist_verification/assets/PurchasesView-Dc_dipW8.js
senke 670282989b chore(refactor/sumi-migration): commit pending changes — tests, stream server, dist_verification
- apps/web: test updates (Vitest/setup), playbackAnalyticsService, TrackGrid, serviceErrorHandler
- veza-common: logging, metrics, traits, validation, random
- veza-stream-server: audio pipeline, codecs, cache, monitoring, routes
- apps/web/dist_verification: refresh build assets (content-hashed filenames)

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-13 19:39:18 +01:00

1 line
8.2 KiB
JavaScript

import{a as i,j as e}from"./vendor-react-C9dYU-TK.js";import{u as j,B as x,l as y,C as S,E as C,S as f}from"./index-BMBS6scK.js";import{a8 as v,X as k,a9 as R,aa as D,a5 as I,p as P}from"./vendor-icons-BSV6HBy1.js";import{c as O}from"./commerceService-bs-xd9qB.js";import{S as E}from"./input-DeoQfymd.js";import{m as g}from"./vendor-motion-CbAtAbUE.js";import"./vendor-CjLUfV8Y.js";import"./vendor-security-DsrNJhpn.js";import"./vendor-router-Dr0ZB7zf.js";import"./vendor-tanstack-C4XaEYj2.js";import"./vendor-http-CctT3C58.js";import"./vendor-utils-D0JLFg89.js";import"./vendor-i18n-PN7w4axr.js";const V=({orderId:s,onClose:t})=>{const{addToast:a}=j(),[l,d]=i.useState("Duplicate Purchase"),[c,o]=i.useState(""),r=()=>{a(`Refund request submitted for Order #${s}`,"success"),t()};return e.jsxs("div",{className:"fixed inset-0 z-[var(--sumi-z-modal)] flex items-center justify-center p-4",children:[e.jsx("div",{className:"absolute inset-0 bg-background/90 backdrop-blur-sm",onClick:t}),e.jsxs("div",{className:"relative w-full max-w-lg bg-card border border-border rounded-xl shadow-2xl animate-scaleIn overflow-hidden",children:[e.jsxs("div",{className:"p-4 border-b border-border bg-muted flex justify-between items-center",children:[e.jsxs("h3",{className:"font-bold text-foreground flex items-center gap-2",children:[e.jsx(v,{className:"w-4 h-4 text-warning"})," Request Refund"]}),e.jsx("button",{onClick:t,children:e.jsx(k,{className:"w-5 h-5 text-muted-foreground hover:text-foreground"})})]}),e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Refund requests are subject to approval. Please provide details below for Order"," ",e.jsxs("span",{className:"font-mono text-foreground",children:["#",s]}),"."]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-muted-foreground uppercase mb-2",children:"Reason"}),e.jsxs("select",{className:"w-full bg-muted border border-border rounded-lg px-4 py-2.5 text-foreground focus:border-primary outline-none focus-visible:ring-2 focus-visible:ring-ring",value:l,onChange:u=>d(u.target.value),children:[e.jsx("option",{children:"Duplicate Purchase"}),e.jsx("option",{children:"Accidental Purchase"}),e.jsx("option",{children:"Quality Issue / Corrupted File"}),e.jsx("option",{children:"Other"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-bold text-muted-foreground uppercase mb-2",children:"Details"}),e.jsx("textarea",{className:"w-full bg-muted border border-border rounded-lg p-4 text-foreground focus:border-primary outline-none focus-visible:ring-2 focus-visible:ring-ring text-sm resize-none h-24",placeholder:"Please explain why you are requesting a refund...",value:c,onChange:u=>o(u.target.value)})]}),e.jsxs("div",{className:"border-2 border-dashed border-border rounded-lg p-6 flex flex-col items-center justify-center text-muted-foreground hover:text-foreground hover:border-border cursor-pointer transition-colors",children:[e.jsx(R,{className:"w-8 h-8 mb-2"}),e.jsx("span",{className:"text-xs font-bold uppercase",children:"Upload Evidence (Optional)"})]})]}),e.jsxs("div",{className:"p-4 border-t border-border bg-muted flex justify-end gap-4",children:[e.jsx(x,{variant:"ghost",onClick:t,children:"Cancel"}),e.jsx(x,{variant:"primary",onClick:r,children:"Submit Request"})]})]})]})};function A(s){const{addToast:t}=j(),[a,l]=i.useState(""),[d,c]=i.useState(null),[o,r]=i.useState(null),[u,m]=i.useState(s??[]),[h,p]=i.useState(s==null),b=i.useCallback(async()=>{if(s!=null){m(s),p(!1);return}p(!0);try{const n=await O.getPurchases();m(n)}catch(n){y.error("Error loading purchases",{error:n instanceof Error?n.message:String(n),stack:n instanceof Error?n.stack:void 0})}finally{p(!1)}},[s]);i.useEffect(()=>{b()},[b]);const w=u.filter(n=>n.product.title.toLowerCase().includes(a.toLowerCase())),N=i.useCallback(n=>{t(`Downloading ${n}...`,"success"),r(null)},[t]);return{search:a,setSearch:l,refundOrderId:d,setRefundOrderId:c,activeDownloadId:o,setActiveDownloadId:r,purchases:w,loading:h,addToast:t,handleDownload:N}}function L({search:s,onSearchChange:t}){return e.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-end border-b border-border pb-6 gap-4 mb-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-heading font-bold text-foreground mb-2 tracking-tight",children:"MY PURCHASES"}),e.jsx("p",{className:"text-muted-foreground font-mono text-sm",children:"Access your sounds, licenses, and receipts."})]}),e.jsx("div",{className:"w-full md:w-64",children:e.jsx(E,{placeholder:"Search library...",value:s,onChange:a=>t(a.target.value)})})]})}const q=["WAV (24-bit)","MP3 (320kbps)","Stems (ZIP)"];function z({purchase:s,isDownloadOpen:t,onToggleDownload:a,onDownloadFormat:l,onLicense:d,onRefund:c}){const o=s.product;return e.jsxs(S,{variant:"default",className:"flex flex-col md:flex-row items-center gap-8 p-4",children:[e.jsx("div",{className:"w-20 h-20 rounded-lg overflow-hidden flex-shrink-0 bg-muted",children:e.jsx("img",{src:o.coverUrl,alt:"",className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"flex-1 w-full text-center md:text-left",children:[e.jsx("h3",{className:"font-bold text-foreground text-lg mb-1 tracking-tight",children:o.title}),e.jsxs("div",{className:"flex flex-wrap items-center justify-center md:justify-start gap-4 text-xs text-muted-foreground",children:[e.jsx("span",{className:"bg-card px-2 py-1 rounded border border-border text-muted-foreground",children:o.type??"pack"}),e.jsxs("span",{children:["Order #",s.orderId]}),e.jsx("span",{children:"•"}),e.jsx("span",{children:s.date}),e.jsx("span",{children:"•"}),e.jsxs("span",{className:"text-foreground",children:["$",s.price]})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 w-full md:w-auto",children:[e.jsxs("div",{className:"relative",children:[e.jsx(x,{variant:"primary",size:"sm",icon:e.jsx(D,{className:"w-4 h-4"}),onClick:a,children:"Download"}),t&&e.jsx("div",{className:"absolute top-full right-0 mt-2 w-40 bg-card border border-border rounded-lg shadow-xl z-20 overflow-hidden animate-fadeIn",children:q.map(r=>e.jsx("button",{type:"button",className:"w-full text-left px-4 py-2 text-xs text-foreground hover:bg-foreground/10",onClick:()=>l(r),children:r},r))})]}),e.jsx(x,{variant:"ghost",size:"sm",className:"border border-border",icon:e.jsx(I,{className:"w-4 h-4"}),onClick:d,children:"License"}),e.jsx(x,{variant:"ghost",size:"sm",className:"text-muted-foreground hover:text-foreground",title:"Request Refund",onClick:c,children:e.jsx(v,{className:"w-4 h-4"})})]})]})}const T={visible:{transition:{staggerChildren:.06,delayChildren:.04}}},F={hidden:{opacity:0,y:12},visible:{opacity:1,y:0,transition:{duration:.3,ease:[.33,1,.68,1]}}};function M({purchases:s,loading:t,activeDownloadId:a,setActiveDownloadId:l,onDownloadFormat:d,onLicense:c,onRefund:o}){return t?null:s.length===0?e.jsx(C,{icon:e.jsx(P,{className:"w-full h-full"}),title:"No purchases yet",description:"Your purchase history will appear here."}):e.jsx(g.div,{className:"space-y-4",variants:T,initial:"hidden",animate:"visible",children:s.map(r=>e.jsx(g.div,{variants:F,children:e.jsx(z,{purchase:r,isDownloadOpen:a===r.id,onToggleDownload:()=>l(a===r.id?null:r.id),onDownloadFormat:d,onLicense:c,onRefund:()=>o(r.orderId)})},r.id))})}function U(){return e.jsxs("div",{className:"animate-fadeIn max-w-5xl mx-auto pb-20",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-end border-b border-border pb-6 gap-4 mb-8",children:[e.jsxs("div",{children:[e.jsx(f,{className:"h-9 w-56 mb-2"}),e.jsx(f,{className:"h-4 w-72"})]}),e.jsx(f,{className:"h-10 w-full md:w-64"})]}),e.jsx("div",{className:"space-y-4",children:[1,2,3].map(s=>e.jsx(f,{className:"h-28 w-full rounded-xl"},s))})]})}function se({initialPurchases:s}={}){const{search:t,setSearch:a,refundOrderId:l,setRefundOrderId:d,activeDownloadId:c,setActiveDownloadId:o,purchases:r,loading:u,addToast:m,handleDownload:h}=A(s??void 0);return u?e.jsx(U,{}):e.jsxs("div",{className:"animate-fadeIn max-w-5xl mx-auto pb-20",children:[e.jsx(L,{search:t,onSearchChange:a}),e.jsx(M,{purchases:r,loading:!1,activeDownloadId:c,setActiveDownloadId:o,onDownloadFormat:h,onLicense:()=>m("License document opened"),onRefund:d}),l&&e.jsx(V,{orderId:l,onClose:()=>d(null)})]})}export{se as PurchasesView};