PageSourceSearch

https://caphousemedia.lovable.app/assets/marketplace.index-D-zC-qN2.js

js caphousemedia.lovable.app collected 2026-10-03 03:24:23 UTC 10,084 bytes, 1 lines download raw bytes

1import{i as e,t}from"./jsx-runtime-DUAcabCT.js";import{t as n}from"./react-6OGjdfot.js";import{t as r}from"./link-C_Yb9p4W.js";import{t as i}from"./useQuery-CL-gk1FN.js";import{t as a}from"./useMutation-DsVncjK0.js";import{n as o}from"./QueryClientProvider-ClEBBNYH.js";import{t as s}from"./createLucideIcon-CLQ5Hlf7.js";import{t as c}from"./bookmark-DpP-r5Dj.js";import{t as l}from"./trash-2-BSJfMgI6.js";import{Cr as u,Qt as d,_r as f,er as p,fr as m,pr as h,tr as g,yr as _}from"./index-DI-Re93t.js";import{i as v,r as y}from"./roles-Cfa2Rgcc.js";import{t as b}from"./SignInLink-DKi7_NIP.js";import{t as x}from"./ThumbImage-xmvwSWAi.js";import{c as S,d as C,l as w,n as T,t as E}from"./marketplace-D5DwEDYC.js";import{a as D,i as O,n as k,o as A,r as j}from"./cart-CFX_xGCk.js";var M=s(`store`,[[`path`,{d:`M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5`,key:`slp6dd`}],[`path`,{d:`M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244`,key:`o0xfot`}],[`path`,{d:`M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05`,key:`wn3emo`}]]),N=e(n(),1),P=t();function F({open:e,onClose:t}){let{user:n}=p(),r=o(),[s,c]=(0,N.useState)(!1),{data:d=[],isLoading:f}=i({queryKey:[`cart`],queryFn:k,enabled:e&&!!n}),h=a({mutationFn:({id:e,qty:t})=>D(e,t),onSuccess:()=>r.invalidateQueries({queryKey:[`cart`]})}),v=a({mutationFn:e=>O(e),onSuccess:()=>r.invalidateQueries({queryKey:[`cart`]})});(0,N.useEffect)(()=>{if(!e)return;let n=e=>e.key===`Escape`&&t();return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]);let y=d.reduce((e,t)=>e+t.product.price_cents*t.quantity,0);return e?(0,P.jsxs)(`div`,{className:`fixed inset-0 z-50`,children:[(0,P.jsx)(`div`,{className:`absolute inset-0 bg-black/70`,onClick:t}),(0,P.jsxs)(`div`,{className:`absolute inset-x-0 bottom-0 mx-auto w-full max-w-md rounded-t-2xl border-t border-hairline bg-surface-2 shadow-2xl`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between border-b border-hairline px-4 py-3`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(m,{className:`h-4 w-4 text-toxic`}),(0,P.jsx)(`h2`,{className:`font-display text-lg uppercase tracking-wider`,children:`Your Cart`})]}),(0,P.jsx)(`button`,{onClick:t,"aria-label":`Close`,className:`text-muted-foreground`,children:(0,P.jsx)(g,{className:`h-5 w-5`})})]}),(0,P.jsx)(`div`,{className:`max-h-[60vh] overflow-y-auto px-4 py-3`,children:n?f?(0,P.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:`Loading…`}):d.length===0?(0,P.jsx)(`p`,{className:`py-8 text-center text-sm text-muted-foreground`,children:`Cart's empty. Go cop something.`}):(0,P.jsx)(`ul`,{className:`space-y-3`,children:d.map(e=>(0,P.jsxs)(`li`,{className:`flex items-center gap-3 rounded-lg border border-hairline bg-surface p-2`,children:[(0,P.jsx)(`div`,{className:`h-14 w-14 shrink-0 overflow-hidden rounded-md bg-black`,children:e.product.image_url?(0,P.jsx)(`img`,{src:e.product.image_url,alt:``,className:`h-full w-full object-cover`}):null}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`p`,{className:`truncate text-sm font-semibold`,children:e.product.title}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:j(e.product.price_cents,e.product.currency)}),(0,P.jsxs)(`div`,{className:`mt-1 flex items-center gap-2`,children:[(0,P.jsx)(`button`,{onClick:()=>h.mutate({id:e.id,qty:e.quantity-1}),className:`grid h-6 w-6 place-items-center rounded border border-hairline`,"aria-label":`Decrease`,children:(0,P.jsx)(u,{className:`h-3 w-3`})}),(0,P.jsx)(`span`,{className:`text-xs font-bold`,children:e.quantity}),(0,P.jsx)(`button`,{onClick:()=>h.mutate({id:e.id,qty:e.quantity+1}),className:`grid h-6 w-6 place-items-center rounded border border-hairline`,"aria-label":`Increase`,children:(0,P.jsx)(_,{className:`h-3 w-3`})})]})]}),(0,P.jsx)(`button`,{onClick:()=>v.mutate(e.id),"aria-label":`Remove`,className:`text-muted-foreground hover:text-blood`,children:(0,P.jsx)(l,{className:`h-4 w-4`})})]},e.id))}):(0,P.jsxs)(`div`,{className:`py-8 text-center`,children:[(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Sign in to use your cart.`}),(0,P.jsx)(b,{onClick:t,className:`mt-4 inline-flex rounded-md bg-toxic px-4 py-2 text-sm font-bold uppercase text-toxic-foreground`,children:`Sign in`})]})}),n&&d.length>0&&(0,P.jsxs)(`div`,{className:`border-t border-hairline px-4 py-3`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsx)(`span`,{className:`text-xs uppercase tracking-wider text-muted-foreground`,children:`Subtotal`}),(0,P.jsx)(`span`,{className:`font-display text-xl text-toxic`,children:j(y)})]}),(0,P.jsxs)(`button`,{type:`button`,onClick:()=>c(!0),className:`mt-3 w-full rounded-md bg-toxic px-4 py-3 text-sm font-bold uppercase text-toxic-foreground`,children:[`Checkout · `,j(y)]})]})]}),(0,P.jsx)(A,{open:s,items:d.map(e=>({productId:e.product_id,quantity:e.quantity})),totalCents:y,onClose:()=>{c(!1),r.invalidateQueries({queryKey:[`cart`]})}})]}):null}function I(){let[e,t]=(0,N.useState)(!1),{user:n}=p(),{data:r=[]}=i({queryKey:[`cart`],queryFn:k,enabled:!!n}),a=r.reduce((e,t)=>
1e+t.quantity,0);return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`button`,{type:`button`,onClick:()=>t(!0),"aria-label":`Cart (${a})`,className:`relative inline-flex h-11 w-11 items-center justify-center rounded-md text-foreground`,children:[(0,P.jsx)(m,{className:`h-5 w-5`}),a>0&&(0,P.jsx)(`span`,{className:`absolute -right-0.5 -top-0.5 grid h-4 min-w-[1rem] place-items-center rounded-full bg-toxic px-1 text-[9px] font-bold text-toxic-foreground`,children:a})]}),(0,P.jsx)(F,{open:e,onClose:()=>t(!1)})]})}function L(){let{user:e}=p(),{isAdmin:t}=y(),{isCreator:n}=v(),s=o(),[l,u]=(0,N.useState)(``),[m,g]=(0,N.useState)(`all`),[b,D]=(0,N.useState)(!1),{data:O=[],isLoading:k}=i({queryKey:[`marketplace`,l,m,b],queryFn:()=>T({search:l,type:m,savedOnly:b})}),{data:A=new Set}=i({queryKey:[`marketplace-saves`],queryFn:S,enabled:!!e}),j=a({mutationFn:({id:e,isSaved:t})=>C(e,t),onSuccess:()=>{s.invalidateQueries({queryKey:[`marketplace-saves`]}),s.invalidateQueries({queryKey:[`marketplace`]})}});return(0,P.jsx)(d,{children:(0,P.jsxs)(`div`,{className:`px-4 pb-24 pt-3`,children:[(0,P.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[(0,P.jsxs)(`h1`,{className:`inline-flex items-center gap-2 font-display text-xl uppercase tracking-wider`,children:[(0,P.jsx)(M,{className:`h-5 w-5 text-toxic`}),` Marketplace`]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1`,children:[t&&(0,P.jsx)(r,{to:`/marketplace/admin`,"aria-label":`Moderate listings`,className:`grid h-10 w-10 place-items-center rounded-full text-foreground/80 hover:text-toxic`,children:(0,P.jsx)(h,{className:`h-5 w-5`})}),n&&(0,P.jsx)(r,{to:`/marketplace/manage`,"aria-label":`Sell on marketplace`,className:`grid h-10 w-10 place-items-center rounded-full text-foreground/80 hover:text-toxic`,children:(0,P.jsx)(_,{className:`h-5 w-5`})}),(0,P.jsx)(I,{})]})]}),(0,P.jsxs)(`label`,{className:`flex items-center gap-2 rounded-xl border border-hairline bg-surface px-3 py-2 focus-within:border-toxic`,children:[(0,P.jsx)(f,{className:`h-4 w-4 text-toxic`}),(0,P.jsx)(`input`,{type:`search`,value:l,onChange:e=>u(e.target.value),placeholder:`Search the marketplace…`,className:`min-w-0 flex-1 bg-transparent text-sm focus:outline-none`})]}),(0,P.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[[{value:`all`,label:`All`},...E].map(e=>(0,P.jsx)(`button`,{type:`button`,onClick:()=>{g(e.value),D(!1)},className:`rounded-full border px-3 py-1.5 text-xs font-bold uppercase tracking-wider ${!b&&m===e.value?`border-toxic bg-toxic/20 text-toxic`:`border-hairline bg-surface text-muted-foreground`}`,children:e.label},e.value)),e&&(0,P.jsxs)(`button`,{type:`button`,onClick:()=>D(e=>!e),className:`inline-flex items-center gap-1 rounded-full border px-3 py-1.5 text-xs font-bold uppercase tracking-wider ${b?`border-toxic bg-toxic/20 text-toxic`:`border-hairline bg-surface text-muted-foreground`}`,children:[(0,P.jsx)(c,{className:`h-3 w-3`}),` Saved`]})]}),k?(0,P.jsx)(`div`,{className:`mt-4 grid grid-cols-2 gap-3`,children:Array.from({length:6}).map((e,t)=>(0,P.jsx)(`div`,{className:`h-52 animate-pulse rounded-xl border border-hairline bg-surface`},t))}):O.length===0?(0,P.jsx)(`p`,{className:`mt-10 text-center text-sm text-muted-foreground`,children:b?`Nothing saved yet.`:`No listings match that search yet.`}):(0,P.jsx)(`div`,{className:`mt-4 grid grid-cols-2 gap-3`,children:O.map(t=>{let n=A.has(t.id);return(0,P.jsxs)(`div`,{className:`relative overflow-hidden rounded-xl border border-hairline bg-surface`,children:[(0,P.jsxs)(r,{to:`/marketplace/$productId`,params:{productId:t.id},className:`block`,children:[(0,P.jsx)(`div`,{className:`aspect-square w-full bg-black`,children:(0,P.jsx)(x,{src:t.image_url,alt:t.title,className:`h-full w-full object-cover`})}),(0,P.jsxs)(`div`,{className:`p-2`,children:[(0,P.jsx)(`p`,{className:`text-sm font-bold text-toxic`,children:w(t.price_cents,t.currency)}),(0,P.jsx)(`p`,{className:`line-clamp-2 text-xs text-foreground/90`,children:t.title}),(0,P.jsx)(`p`,{className:`mt-1 truncate text-[10px] uppercase tracking-wider text-muted-foreground`,children:t.seller?.display_name??t.seller?.username??`Cap House`})]})]}),t.is_featured&&(0,P.jsx)(`span`,{className:`absolute left-2 top-2 rounded-full bg-toxic px-2 py-0.5 text-[9px] font-bold uppercase text-toxic-foreground`,children:`Featured`}),e&&(0,P.jsx)(`button`,{type:`button`,"aria-label":n?`Unsave listing`:`Save listing`,onClick:()=>j.mutate({id:t.id,isSaved:n}),className:`absolute right-2 top-2 grid h-8 w-8 place-items-center rounded-full bg-black/60 text-white`,children:(0,P.jsx)(c,{className:`h-4 w-4 ${n?`fill-toxic text-toxic`:``}`})})]},t.id)})})]})})}export{L as component};

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.