veza/apps/web/dist_verification/assets/SocialView-G0WUSTMl.js
senke b733f47a33 chore: playwright workflow, docs, rapports audit, visual-tests, tmt unit
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-11 22:19:34 +01:00

1 line
12 KiB
JavaScript

import{a as i,j as s}from"./vendor-react-Dkpvlwai.js";import{a as o,l as v,F as N,m as _,C as j,B as f,S as g}from"./index-VJPzCABl.js";import{aJ as S,x as T,a1 as C,Z as $,F as A,D as F,i as L,a2 as U,b2 as E,L as D,ac as P}from"./vendor-icons-CbmLcMl-.js";import{A as z}from"./avatar-aAmhfJnn.js";import{y,x as I}from"./vendor-CAoAb3tF.js";import"./vendor-router-4bycex72.js";import"./vendor-tanstack-BoI3DtL9.js";import"./vendor-utils-CDFfoeXY.js";const k=1024*1024*2,w={uploadTrack:async(e,a,t)=>{const r=Math.ceil(e.size/k),m=await o.post("/tracks/initiate",{filename:e.name,total_chunks:r,file_size:e.size,title:a.title,artist:a.artist,album:a.album,genre:a.genre}),{upload_id:c}=m.data;v.info(`[UPLOAD] Upload initiated with ID: ${c}`,{filename:e.name,totalChunks:r});for(let l=0;l<r;l++){const p=l*k,h=Math.min(p+k,e.size),d=e.slice(p,h),x=new FormData;x.append("chunk",d),x.append("index",l.toString()),x.append("upload_id",c);try{await o.post("/tracks/chunk",x,{timeout:3e5,_enableLogging:!1});const u=(l+1)/r*100;t&&t(u)}catch(u){throw v.error(`[UPLOAD] Failed to upload chunk ${l} for ${c}`,{error:u}),u}}const n=await o.post("/tracks/complete",{upload_id:c});return v.info(`[UPLOAD] Upload completed. Track ID: ${n.data.track_id}`),n.data},getTrackStatus:async e=>(await o.get(`/tracks/${e}/status`)).data},V={API_URL:"https://api.veza.com/api/v1"},b=e=>({id:e.id,title:e.title,artist:typeof e.artist=="object"?e.artist.name:e.artist,album:e.album||"Unknown",duration:e.duration_formatted||"0:00",durationSec:e.duration||0,genre:e.genre||"None",year:e.year||new Date().getFullYear(),coverUrl:e.cover_art_path?`${V.API_URL}${e.cover_art_path}`:void 0,cover_art_path:e.cover_art_path,filePath:e.file_path,file_path:e.file_path,file_size:e.file_size||0,format:e.format||"mp3",bitrate:e.bitrate||0,sample_rate:e.sample_rate||0,play_count:e.play_count||0,like_count:e.like_count||0,plays:e.play_count||0,likes:e.like_count||0,created_at:e.created_at,updated_at:e.updated_at,creator_id:e.creator_id,is_public:e.is_public??!0,status:e.status,stream_status:e.stream_status||"pending",stream_manifest_url:e.stream_manifest_url}),R={list:async e=>{const t=(await o.get("/tracks",{params:{...e,query:e?.query||e?.search}})).data;return{tracks:(t.items||[]).map(b),pagination:{total:t.total,page:t.page,limit:t.limit,total_pages:t.total_pages,has_next:t.has_next,has_prev:t.has_prev}}},search:async e=>({tracks:(await o.get("/tracks/search",{params:{query:e}})).data.map(b)}),get:async e=>{const a=await o.get(`/tracks/${e}`,{validateSchema:N});return{track:b(a.data)}},update:async(e,a)=>{const t={title:a.title,artist:a.artist,album:a.album,genre:a.genre,is_public:a.is_public},r=await o.put(`/tracks/${e}`,t,{validateSchema:N});return{track:b(r.data)}},delete:async e=>o.delete(`/tracks/${e}`),like:async e=>o.post(`/tracks/${e}/like`),unlike:async e=>o.delete(`/tracks/${e}/like`),recordPlay:async e=>o.post(`/tracks/${e}/play`),download:async e=>(await o.get(`/tracks/${e}/download`,{responseType:"blob"})).data,upload:async(e,a,t)=>await w.uploadTrack(e,a,t),getStatus:async e=>await w.getTrackStatus(e)};function H(){const{playTrack:e}=_(),[a,t]=i.useState("feed"),[r,m]=i.useState([]),[c,n]=i.useState(!0),[l,p]=i.useState(!1),h=i.useCallback(async()=>{n(!0),p(!1);try{const d=await R.list({limit:10,sort_by:"created_at"});m(d.tracks)}catch(d){v.error("Error loading feed tracks",{error:d instanceof Error?d.message:String(d),stack:d instanceof Error?d.stack:void 0}),p(!0)}finally{n(!1)}},[]);return i.useEffect(()=>{h()},[h]),{activeTab:a,setActiveTab:t,feedTracks:r,loading:c,error:l,retry:h,playTrack:e}}function M({activeTab:e,onTabChange:a,onProfileClick:t}){return s.jsxs("div",{className:"hidden lg:block lg:col-span-3 space-y-8",children:[s.jsxs(j,{variant:"glass",className:"p-0 overflow-hidden border-white/5 bg-black/20 backdrop-blur-xl hover-glow-cyan transition-shadow duration-[var(--duration-normal)]",children:[s.jsx("div",{className:"h-20 bg-gradient-gaming"}),s.jsxs("div",{className:"px-4 pb-4",children:[s.jsx("div",{className:"relative -mt-10 mb-3 cursor-pointer focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background rounded-full",onClick:t,onKeyDown:r=>r.key==="Enter"&&t(),role:"button",tabIndex:0,children:s.jsx("div",{className:"w-20 h-20 rounded-full border-4 border-border overflow-hidden bg-muted",children:s.jsx("img",{src:"https://picsum.photos/id/237/200/200",alt:"",className:"w-full h-full object-cover"})})}),s.jsx("h3",{className:"font-bold text-foreground text-lg tracking-tight",children:"My Profile"}),s.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"View your stats"})]})]}),s.jsx(j,{variant:"glass",className:"p-2 border-white/5 bg-black/20 backdrop-blur-xl",children:s.jsxs("nav",{className:"space-y-1",children:[s.jsxs(f,{variant:e==="feed"?"outline":"ghost",size:"sm",className:"w-full justify-start",onClick:()=>a("feed"),children:[s.jsx(S,{className:"w-4 h-4"})," Fresh Tracks"]}),s.jsxs(f,{variant:"ghost",size:"sm",className:"w-full justify-start",onClick:()=>a("communities"),children:[s.jsx(T,{className:"w-4 h-4"})," Communities"]})]})})]})}function O({track:e,onPlay:a}){const[t,r]=i.useState(!1),[m,c]=i.useState(e.like_count??0),[n,l]=i.useState(!1),[p,h]=i.useState(!1),d=i.useCallback(()=>{r(u=>!u),c(u=>t?u-1:u+1),t||(l(!0),setTimeout(()=>l(!1),400))},[t]),x=i.useCallback(()=>{h(!0),setTimeout(()=>h(!1),1500)},[]);return s.jsx(y.div,{whileHover:{scale:1.005},transition:{duration:.2},className:"mb-4",children:s.jsxs(j,{variant:"glass",className:"p-0 overflow-hidden border-white/5 bg-black/20 backdrop-blur-xl hover:border-primary/20 hover-glow-cyan transition-all duration-[var(--duration-normal)]",children:[s.jsxs("div",{className:"p-4 flex items-center gap-3",children:[s.jsx(z,{src:e.coverUrl,alt:e.artist,fallback:e.artist,size:"md",status:"online"}),s.jsxs("div",{children:[s.jsx("button",{className:"font-bold text-foreground text-sm hover:underline transition-colors text-left",children:e.artist}),s.jsx("div",{className:"text-xs text-muted-foreground",children:"uploaded a new track"})]}),s.jsx(f,{variant:"ghost",size:"sm",className:"ml-auto text-muted-foreground hover:text-foreground",children:s.jsx(C,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"px-4 pb-4",children:s.jsxs("div",{className:"bg-card p-4 rounded-xl flex items-center gap-4 border border-border hover:border-primary/20 group cursor-pointer transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",onClick:()=>a(e),onKeyDown:u=>u.key==="Enter"&&a(e),role:"button",tabIndex:0,children:[s.jsxs("div",{className:"w-16 h-16 rounded-lg overflow-hidden relative",children:[s.jsx("img",{src:e.coverUrl,alt:"",className:"w-full h-full object-cover transition-transform duration-[var(--duration-normal)] group-hover:scale-110"}),s.jsx("div",{className:"absolute inset-0 bg-black/30 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:s.jsx($,{className:"w-6 h-6 text-white fill-current"})})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h4",{className:"font-bold text-foreground tracking-tight truncate",children:e.title}),s.jsx("p",{className:"text-xs text-muted-foreground",children:e.genre||"Electronic"})]}),s.jsx("div",{className:"text-xs text-muted-foreground font-mono pr-2",children:e.duration})]})}),s.jsxs("div",{className:"px-4 py-3 border-t border-border flex gap-2 text-xs text-muted-foreground",children:[s.jsxs("button",{onClick:d,className:`flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 transition-colors hover:bg-destructive/10 hover:text-destructive ${t?"text-destructive":""}`,children:[s.jsx(A,{className:`w-3.5 h-3.5 ${t?"fill-current":""} ${n?"animate-like-bounce":""}`}),s.jsx("span",{className:"tabular-nums",children:m})]}),s.jsxs("button",{className:"flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 transition-colors hover:bg-primary/10 hover:text-primary",children:[s.jsx(F,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:"Comment"})]}),s.jsx("button",{onClick:x,className:`flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 transition-colors ${p?"text-success":"hover:bg-primary/10 hover:text-primary"}`,children:p?s.jsxs(s.Fragment,{children:[s.jsx(L,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:"Shared!"})]}):s.jsxs(s.Fragment,{children:[s.jsx(U,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:"Share"})]})})]})]})})}const q={visible:{transition:{staggerChildren:.06,delayChildren:.02}}},G={hidden:{opacity:0,y:12},visible:{opacity:1,y:0,transition:{duration:.3}}};function K({tracks:e,loading:a,onPlayTrack:t}){const[r,m]=i.useState(!1);i.useEffect(()=>{const n=setTimeout(()=>{e.length>0&&m(!0)},45e3);return()=>clearTimeout(n)},[e.length]);const c=i.useCallback(()=>{m(!1),window.scrollTo({top:0,behavior:"smooth"})},[]);return s.jsxs("div",{className:"col-span-1 lg:col-span-6 space-y-6",children:[s.jsxs("div",{className:"mb-4",children:[s.jsx("h2",{className:"text-2xl font-bold text-foreground mb-1 tracking-tight",children:"Community Feed"}),s.jsx("p",{className:"text-muted-foreground text-xs",children:"New uploads from the network"})]}),s.jsx(I,{children:r&&s.jsxs(y.button,{initial:{opacity:0,y:-12},animate:{opacity:1,y:0},exit:{opacity:0,y:-12},onClick:c,className:"w-full flex items-center justify-center gap-2 py-2.5 px-4 rounded-xl bg-primary/10 text-primary text-sm font-medium border border-primary/20 hover:bg-primary/20 transition-all cursor-pointer",children:[s.jsx(E,{className:"w-4 h-4"}),"New posts available"]})}),a?null:s.jsxs(s.Fragment,{children:[e.length>0?s.jsx(y.div,{className:"space-y-4",variants:q,initial:"hidden",animate:"visible",children:e.map(n=>s.jsx(y.div,{variants:G,children:s.jsx(O,{track:n,onPlay:t})},n.id))}):s.jsx("div",{className:"text-center py-24 text-muted-foreground",children:"No recent activity."}),e.length>0&&s.jsx("div",{className:"text-center py-6",children:s.jsxs(f,{variant:"ghost",className:"gap-2 text-muted-foreground hover:text-foreground",children:[s.jsx(D,{className:"w-4 h-4"}),"Load More"]})})]})]})}const B=["#Techno","#Synthwave","#NewGear","#Tutorial"];function Z(){return s.jsx("div",{className:"hidden lg:block lg:col-span-3 space-y-8",children:s.jsxs(j,{variant:"glass",className:"border-white/5 bg-black/20 backdrop-blur-xl hover-glow-cyan transition-shadow duration-[var(--duration-normal)]",children:[s.jsxs("h3",{className:"font-bold text-sm text-foreground uppercase tracking-wider mb-4 flex items-center gap-2",children:[s.jsx(P,{className:"w-4 h-4 text-primary"})," Trending Tags"]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:B.map(e=>s.jsx("span",{className:"text-xs bg-muted px-2 py-1 rounded text-muted-foreground cursor-pointer hover:text-foreground hover:bg-muted/80 transition-all duration-[var(--duration-fast)]",children:e},e))})]})})}function J(){return s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-8 animate-fadeIn pb-20 min-h-layout-page",children:[s.jsxs("div",{className:"hidden lg:block lg:col-span-3 space-y-8",children:[s.jsx(g,{className:"h-48 rounded-xl"}),s.jsx(g,{className:"h-32 rounded-xl"})]}),s.jsxs("div",{className:"col-span-1 lg:col-span-6 space-y-8",children:[s.jsxs("div",{className:"mb-4",children:[s.jsx(g,{className:"h-8 w-48 mb-2"}),s.jsx(g,{className:"h-4 w-64"})]}),[1,2,3].map(e=>s.jsx(g,{className:"h-44 rounded-xl"},e))]}),s.jsx("div",{className:"hidden lg:block lg:col-span-3",children:s.jsx(g,{className:"h-40 rounded-xl"})})]})}function W({onRetry:e}){return s.jsxs("div",{className:"flex flex-col items-center justify-center min-h-layout-page-sm text-center px-4",children:[s.jsx("p",{className:"text-destructive font-medium mb-2",children:"Failed to load feed"}),s.jsx("p",{className:"text-muted-foreground text-sm mb-4",children:"We couldn't load the community feed. Please try again."}),e!=null&&s.jsx(f,{variant:"outline",onClick:e,children:"Retry"})]})}function ie({onViewProfile:e}){const{activeTab:a,setActiveTab:t,feedTracks:r,loading:m,error:c,retry:n,playTrack:l}=H();return m?s.jsx(J,{}):c?s.jsx(W,{onRetry:n}):s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-8 animate-fadeIn pb-20 min-h-layout-page",children:[s.jsx(M,{activeTab:a,onTabChange:p=>t(p),onProfileClick:()=>e(null)}),s.jsx(K,{tracks:r,loading:!1,onPlayTrack:l}),s.jsx(Z,{})]})}export{ie as SocialView};