veza/apps/web/dist_verification/assets/PurchasesView-E5u00cpv.js

2 lines
8.2 KiB
JavaScript
Raw Normal View History

import{a as i,j as e}from"./vendor-react-yWUy5XPk.js";import{u as j,B as x,l as y,C as S,E as C,S as f}from"./index-CYK_b1Uz.js";import{a8 as v,X as k,a9 as R,aa as D,a5 as I,p as P}from"./vendor-icons-DJFb1Tiw.js";import{c as O}from"./commerceService-bs-xd9qB.js";import{S as E}from"./input-CGdBHtsQ.js";import{m as g}from"./vendor-motion-B3XPS3Jc.js";import"./vendor-CveO81sn.js";import"./vendor-security-DsrNJhpn.js";import"./vendor-router-BNNHboN9.js";import"./vendor-tanstack-kPY9uK0s.js";import"./vendor-http-Cz8wfb0q.js";import"./vendor-utils-DtoSyhX2.js";import"./vendor-i18n-CMcqpBLz.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,handl