PageSourceSearch

https://native-re-market.base44.app/assets/BuyerProfile-D2eDMHxQ.js

js native-re-market.base44.app collected 2026-10-03 03:07:03 UTC 7,668 bytes, 1 lines download raw bytes

1import{h as A,u as R,i as C,r as n,d as l,j as e,B as O,A as E,H as N}from"./index-Bchq-z0K.js";import{B as Y}from"./badge-3Vpo_jCP.js";import{S as x}from"./star-BwWcJYH_.js";import{S as y}from"./shopping-bag-Db99XNNK.js";function I(){const{userId:i}=A(),{user:m}=R(),w=C(),[r,S]=n.useState(null),[c,_]=n.useState([]),[a,B]=n.useState([]),[h,D]=n.useState([]),[L,b]=n.useState(!0),[o,u]=n.useState("purchases");n.useEffect(()=>{$()},[i]);async function $(){b(!0);try{const[t,s,d,v]=await Promise.all([l.entities.User.filter({id:i},void 0,1),l.entities.Order.filter({buyer_id:i},"-created_date",100),l.entities.Review.filter({buyer_id:i},"-created_date",50),l.entities.SavedListing.filter({user_id:i},"-created_date",100)]);if(t[0]&&S(t[0]),_(s),B(d),v.length>0){const P=await Promise.all(v.map(g=>l.entities.Listing.filter({id:g.listing_id},void 0,1)));D(P.map(g=>g[0]).filter(Boolean))}}catch(t){console.error(t)}b(!1)}if(L)return e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx("div",{className:"w-8 h-8 border-4 border-primary/30 border-t-primary rounded-full animate-spin"})});const f=(m==null?void 0:m.id)===i,j=(r==null?void 0:r.full_name)||"Buyer",k=r!=null&&r.created_date?new Date(r.created_date).toLocaleDateString():"Unknown",p=a.length>0?(a.reduce((t,s)=>t+s.rating,0)/a.length).toFixed(1):null;return e.jsx("div",{className:"min-h-screen bg-background",children:e.jsxs("div",{className:"max-w-5xl mx-auto px-6 py-10",children:[e.jsxs(O,{variant:"ghost",className:"mb-6 text-muted-foreground",onClick:()=>w(-1),children:[e.jsx(E,{className:"w-4 h-4 mr-2"})," Back"]}),e.jsxs("div",{className:"bg-card border border-border rounded-2xl p-6 mb-10",children:[e.jsxs("div",{className:"flex items-start gap-6",children:[e.jsx("div",{className:"w-20 h-20 rounded-full bg-primary/20 flex items-center justify-center shrink-0",children:e.jsx("span",{className:"font-playfair text-3xl font-bold text-primary",children:j[0].toUpperCase()})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"font-playfair text-2xl font-bold text-foreground",children:j}),e.jsxs("p",{className:"text-sm text-muted-foreground font-inter mt-0.5",children:["Joined ",k]}),e.jsx("p",{className:"text-sm text-muted-foreground font-inter",children:r==null?void 0:r.email})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-8 mt-6 pt-6 border-t border-border",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-playfair text-2xl font-bold text-foreground",children:c.length}),e.jsx("p",{className:"text-xs text-muted-foreground font-inter",children:"Purchases"})]}),p&&e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("p",{className:"font-playfair text-2xl font-bold text-foreground",children:p}),e.jsx("div",{className:"flex gap-0.5",children:[...Array(5)].map((t,s)=>e.jsx(x,{className:`w-4 h-4 ${s<Math.round(p)?"fill-gold text-gold":"text-border"}`},s))})]}),e.jsxs("p",{className:"text-xs text-muted-foreground font-inter",children:[a.length," reviews"]})]})]})]}),e.jsx("div",{className:"mb-6",children:e.jsxs("div",{className:"flex gap-2 border-b border-border",children:[e.jsxs("button",{onClick:()=>u("purchases"),className:`px-4 py-3 font-inter text-sm font-semibold border-b-2 transition-colors ${o==="purchases"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx(y,{className:"w-4 h-4 inline mr-2"})," Purchases (",c.length,")"]}),e.jsxs("button",{onClick:()=>u("reviews"),className:`px-4 py-3 font-inter text-sm font-semibold border-b-2 transition-colors ${o==="reviews"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx(x,{className:"w-4 h-4 inline mr-2"})," Reviews (",a.length,")"]}),e.jsxs("button",{onClick:()=>u("saved"),className:`px-4 py-3 font-inter text-sm font-semibold border-b-2 transition-colors ${o==="saved"?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[e.jsx(N,{className:"w-4 h-4 inline mr-2"})," Saved (",h.length,")"]})]})}),o==="purchases"&&e.jsx("div",{className:"space-y-3",children:c.length===0?e.jsxs("div",{className:"text-center py-12 border border-dashed border-border rounded-xl text-muted-foreground font-inter",children:[e.jsx(y,{className:"w-8 h-8 mx-auto mb-3 opacity-30"}),e.jsx("p",{children:f?"You have no purchases yet.":"No purchases to display."})]}):c.map(t=>{var s;return e.jsx("div",{className:"border border-border rounded-xl p-4 bg-card hover:bg-secondary/30 transition-colors",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-inter font-semibold text-foreground text-sm",children:t.listing_title}),e.jsx("p",{className:"text-xs text-muted-foreground font-inter mt-0.5",children:new Date(t.created_date).toLocaleDateString()})]}),e.jsxs("div",{className:"text-right",children:[e.jsx(Y,{className:`text-xs ${t.status==="completed"?"bg-green-500/15 text-green-400":t.status==="shipped"?"bg-primary/15 text-primary":t.status==="paid"?"bg-accent/15 text-accent":"bg-secondary text-muted-foreground"}`,children:t.status}),e.jsxs("p",{className:"text-sm font-semibold text-gold mt-1",children:["$",(s=t.total_charged)==null?void 0:s.toFixed(2)]})]})]})},t.id)})}),o==="reviews"&&e.jsx("div",{className:"space-y-3",children:a.length===0?e.jsxs("div",{className:"text-center py-12 border border-dashed border-border rounded-xl text-muted-foreground font-inter",children:[e.jsx(x,{className:"w-8 h-8 mx-auto mb-3 opacity-30"}),e.jsx("p",{children:f?"You haven't left any reviews yet.":"No reviews to display."})]}):a.map(t=>e.jsxs("div",{className:"border border-border rounded-xl p-4 bg-card space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-inter font-semibold text-foreground text-sm",children:t.listing_title}),e.jsx("p",{className:"text-xs text-muted-foreground font-inter mt-0.5",children:new Date(t.created_date).toLocaleDateString()})]}),e.jsx("div",{className:"flex gap-0.5",children:[...Array(5)].map((s,d)=>e.jsx(x,{className:`w-4 h-4 ${d<t.rating?"fill-gold text-gold":"text-border"}`},d))})]}),t.comment&&e.jsx("p",{className:"text-sm font-inter text-muted-foreground leading-relaxed",children:t.comment})]},t.id))}),o==="saved"&&e.jsx("div",{className:"space-y-3",children:h.length===0?e.jsxs("div",{className:"text-center py-12 border border-dashed border-border rounded-xl text-muted-foreground font-inter",children:[e.jsx(N,{className:"w-8 h-8 mx-auto mb-3 opacity-30"}),e.jsx("p",{children:f?"You have no saved listings.":"No saved listings to display."})]}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:h.map(t=>{var s,d;return e.jsxs("a",{href:`/listing/${t.id}`,className:"border border-border rounded-xl overflow-hidden bg-card hover:border-primary transition-colors group",children:[((s=t.images)==null?void 0:s[0])&&e.jsx("div",{className:"h-40 overflow-hidden bg-secondary",children:e.jsx("img",{src:t.images[0],alt:t.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform"})}),e.jsxs("div",{className:"p-3",children:[e.jsx("p",{className:"font-inter font-semibold text-foreground text-sm line-clamp-2",children:t.title}),e.jsxs("p",{className:"text-gold font-semibold text-sm mt-2",children:["$",(d=t.price)==null?void 0:d.toLocaleStr
1ing()]})]})]},t.id)})})})]})})}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.