PageSourceSearch

https://trovable.ai/assets/TrevorPicksSection-L8lObQUY.js

js trovable.ai collected 2026-10-05 13:48:56 UTC 5,374 bytes, 1 lines download raw bytes

1import{u as k,r as f,j as e,ag as b,Y as y,b8 as v,p as P,B as E,bB as B,s as i,h as S,aV as $,bH as q}from"./index-CaerIkuo.js";function I(){const{user:c}=k(),[_,w]=f.useState([]),[N,h]=f.useState(!0);if(f.useEffect(()=>{if(!c){h(!1);return}(async()=>{var m;h(!0);try{const d=[],{data:x}=await i.from("pod_members").select("pod_id").eq("user_id",c.id),p=(x==null?void 0:x.map(s=>s.pod_id))||[];if(p.length>0){const{data:s}=await i.from("pod_discussions").select("id, title, content, pod_id, reply_count, created_at").in("pod_id",p).order("reply_count",{ascending:!1}).limit(2);if(s){const r=[...new Set(s.map(n=>n.pod_id))],{data:o}=await i.from("pods").select("id, name").in("id",r),l=new Map((o==null?void 0:o.map(n=>[n.id,n.name]))||[]);s.forEach(n=>{var u;d.push({id:n.id,type:"discussion",title:n.title,subtitle:l.get(n.pod_id)||"Your pod",description:((u=n.content)==null?void 0:u.slice(0,120))+(n.content&&n.content.length>120?"…":"")||"",metadata:{podName:l.get(n.pod_id),replyCount:n.reply_count||0},link:`/pod/${n.pod_id}`})})}}const{data:j}=await i.from("pods").select("id, name, description, member_count").eq("is_active",!0).not("id","in",p.length>0?`(${p.join(",")})`:"(00000000-0000-0000-0000-000000000000)").order("member_count",{ascending:!1}).limit(2);j&&j.forEach(s=>{var r;d.push({id:s.id,type:"pod",title:s.name,subtitle:`${s.member_count||0} members`,description:((r=s.description)==null?void 0:r.slice(0,120))+(s.description&&s.description.length>120?"…":"")||"A community of curious trovers",metadata:{memberCount:s.member_count||0,contentType:void 0},link:`/pod/${s.id}`})});const{data:g}=await i.from("saved_content").select("content_type").eq("user_id",c.id).limit(20);if(g&&g.length>0){const s={};g.forEach(o=>{s[o.content_type]=(s[o.content_type]||0)+1});const r=(m=Object.entries(s).sort(([,o],[,l])=>l-o)[0])==null?void 0:m[0];if(r){const{data:o}=await i.from("saved_content").select("content_title").eq("user_id",c.id),l=new Set((o==null?void 0:o.map(u=>u.content_title))||[]),{data:n}=await i.from("content_ratings").select("content_title, content_type, content_creator, rating").eq("content_type",r).gte("rating",4).order("rating",{ascending:!1}).limit(20);n&&n.filter(a=>!l.has(a.content_title)).slice(0,1).forEach(a=>{d.push({id:`content-${a.content_title}`,type:"content",title:a.content_title,subtitle:a.content_creator||"Unknown creator",description:`Highly rated ${a.content_type} that trovers like you enjoyed`,metadata:{contentType:a.content_type,creator:a.content_creator||void 0},link:"/library"})})}}w(d.slice(0,5))}catch(d){console.error("Error fetching Trevor's picks:",d)}finally{h(!1)}})()},[c]),!c)return null;const C=t=>{switch(t){case"discussion":return e.jsx(q,{className:"w-4 h-4"});case"pod":return e.jsx($,{className:"w-4 h-4"});case"content":return e.jsx(S,{className:"w-4 h-4"})}},T=t=>{switch(t){case"discussion":return"Discussion";case"pod":return"Pod";case"content":return"Content"}};return N?e.jsxs("section",{className:"max-w-5xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx("img",{src:b,alt:"Trevor",width:40,height:40,loading:"lazy",decoding:"async",className:"w-10 h-10 rounded-full object-cover"}),e.jsxs("div",{children:[e.jsx(y,{className:"h-6 w-48 mb-1"}),e.jsx(y,{className:"h-4 w-64"})]})]}),e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3].map(t=>e.jsx(y,{className:"h-40 rounded-xl"},t))})]}):_.length===0?null:e.jsxs("section",{className:"max-w-5xl mx-auto",children:[e.jsx("div",{className:"flex items-center justify-between mb-8",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:b,alt:"Trevor",width:40,height:40,loading:"lazy",decoding:"async",className:"w-10 h-10 rounded-full object-cover border-2 border-accent/30"}),e.jsxs("div",{children:[e.jsxs("h2",{className:"font-serif text-2xl sm:text-3xl font-semibold text-foreground flex items-center gap-2",children:["Trevor's Picks for You ",e.jsx("span",{children:"🐢"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Based on your interests and troving habits"})]})]})}),e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-4 mb-6",children:_.map(t=>{var m;return e.jsxs(v,{to:t.link,className:"group p-5 rounded-xl bg-card/50 backdrop-blur-sm border border-border/50 hover:border-accent/30 hover:shadow-md transition-all duration-300",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsxs(P,{variant:"outline",className:"text-xs gap-1 text-muted-foreground",children:[C(t.type),T(t.type)]}),((m=t.metadata)==null?void 0:m.replyCount)!==void 0&&t.metadata.replyCount>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.metadata.replyCount," ",t.metadata.replyCount===1?"reply":"replies"]})]}),e.jsx("h3",{className:"font-medium text-foreground mb-1 line-clamp-2 group-hover:text-accent transition-colors",children:t.title}),e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:t.subtitle}),e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:t.description})]},t.id)})}),e.jsx("div",{className:"text-center",children:e.jsx(E,{variant:"outline",asChild:!0,className:"gap-2",children:e.jsxs(v,{to:"/community",children:["See more picks",e.jsx(B,{className:"w-4 h-4"})]})})})]})}export{I as TrevorPicksSection};

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.