1import{r as i,c as N,u as w,j as e,H as C,I as P,h as d,l as E,v as g}from"./index-DCG2_wKO.js";const I=()=>{const{selectedSong:t,musicItems:l,setSelectedSong:u}=i.useContext(N),[x,m]=i.useState(!1),[o,h]=i.useState(""),n=w();i.useEffect(()=>{!t&&l.length===0&&n.push("/")},[t,l,n]);const p=()=>{m(!0);try{const a=t?t.Price:l.reduce((c,s)=>c+s.Price,0),y=`REF-${Date.now()}`,j=g.currentUser.email,v="10000100",b="46f0cd694581a",r=document.createElement("form");r.method="POST",r.action="https://sandbox.payfast.co.za/eng/process",[{name:"merchant_id",value:v},{name:"merchant_key",value:b},{name:"amount",value:a.toFixed(2)},{name:"reference",value:y},{name:"email",value:j},{name:"item_name",value:t?t.SongTitle:"Music Purchase"},{name:"return_url",value:"http://localhost:3000/"},{name:"cancel_url",value:"http://localhost:3000/collection"}].forEach(c=>{const s=document.createElement("input");s.type="hidden",s.name=c.name,s.value=c.value,r.appendChild(s)}),document.body.appendChild(r),r.submit()}catch(a){console.error("Error initiating payment:",a),h("Failed to proceed with payment. Please try again.")}finally{m(!1)}},f=()=>{t&&u(null),n.push("/")};return e.jsxs(e.Fragment,{children:[e.jsxs(C,{children:[e.jsx("title",{children:"DeepHouse Space - Confirm Purchase"}),e.jsx("meta",{name:"description",content:"Review your selected songs before proceeding to payment."})]}),e.jsx("div",{className:"fixed top-20 left-0 z-[110] bg-gray-800 opacity-95 w-full h-screen overflow-y-hidden overscroll-y-none",children:e.jsxs("div",{className:"w-[95%] mt-12 mx-auto md:w-[80%] lg:w-[60%] bg-black shadow-lg rounded-lg p-5",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h1",{className:"text-2xl font-semibold text-gray-300",children:"Confirm Your Purchase"}),e.jsx(P,{size:30,onClick:f,className:"text-white cursor-pointer"})]}),o&&e.jsx("div",{className:"text-red-400 text-sm py-2",children:o}),e.jsx("h2",{className:"text-lg font-semibold text-gray-300 mt-4",children:"Selected Songs"}),e.jsx("ul",{className:"space-y-4 my-4",children:t?e.jsxs("div",{className:"flex justify-between items-center bg-blue-20 p-4 text-gray-300 border-b transition-all transform hover:scale-100",children:[e.jsx("img",{src:t==null?void 0:t.ImgUrl,alt:`Cover of ${t==null?void 0:t.SongTitle}`,className:"w-[80px] h-[80px] rounded-sm"}),e.jsxs("div",{className:"flex-1 ml-4",children:[e.jsx("h3",{className:"text-lg",children:t==null?void 0:t.SongTitle}),e.jsx("p",{className:"text-sm text-gray-400",children:t==null?void 0:t.Artist})]}),e.jsx("div",{className:"text-lg",children:d(t==null?void 0:t.Price)})]}):l.map(a=>e.jsxs("div",{className:"flex justify-between items-center bg-blue-20 p-4 text-gray-300 border-b transition-all transform hover:scale-100",children:[e.jsx("img",{src:a==null?void 0:a.ImgUrl,alt:`Cover of ${a==null?void 0:a.SongTitle}`,className:"w-[80px] h-[80px] rounded-sm"}),e.jsxs("div",{className:"flex-1 ml-4",children:[e.jsx("h3",{className:"text-lg",children:a==null?void 0:a.SongTitle}),e.jsx("p",{className:"text-sm text-gray-400",children:a==null?void 0:a.Artist})]}),e.jsx("div",{className:"text-lg",children:d(a==null?void 0:a.Price)})]},a.id))}),e.jsx("button",{onClick:p,className:"w-full bg-yellow-500 text-black p-3 rounded-md font-semibold mt-4 hover:bg-yellow-600",children:x?e.jsx(E,{}):"Proceed to Pay"})]})})]})};export{I 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.