1 line
16 KiB
JavaScript
1 line
16 KiB
JavaScript
import{j as e,a as j}from"./vendor-react-YMhRUmcb.js";import{u as h,a as L}from"./vendor-tanstack-CoFNL2zy.js";import{u as A,f as F,a as S,g as E}from"./users-DDt25V_U.js";import{t as D}from"./tracks-C_h6xkxF.js";import{p as z,P as K}from"./PlaylistCard-Due74KZ6.js";import{s as M}from"./socialService-rJN8QISo.js";import{d as B,L as y}from"./vendor-router-DX94Iu-2.js";import{g as Q}from"./vendor-utils-4BWoYre8.js";import{B as k,u as V,g as $,p as H,C as f,e as P}from"./index-D2uzyr9g.js";import{A as _}from"./avatar-DwZKme3D.js";import{g as R,an as J,ao as W,ap as Y,aq as G,U as O,a6 as w,Y as X,a7 as Z,z as I}from"./vendor-icons-DINCNwpk.js";import{T as ee,a as se,b as v,c as N}from"./Tabs-C8UCeQNW.js";import"./vendor-fFnFILYR.js";import"./features-CKIBrJL0.js";function ae(){const{username:a}=B(),{data:s,isLoading:d,error:i}=h({queryKey:["userProfile",a],queryFn:async()=>{if(!a)throw new Error("Username is required");return A.getProfileByUsername(a)},enabled:!!a,retry:!1}),{data:n,isLoading:l}=h({queryKey:["userTracks",s?.id],queryFn:()=>D.list(1,12,{userId:s?.id}),enabled:!!s?.id}),{data:r,isLoading:o}=h({queryKey:["userPosts",s?.id],queryFn:()=>M.getPostsByUser(s.id,1,s),enabled:!!s?.id}),{data:t,isLoading:m}=h({queryKey:["userPlaylists",s?.id],queryFn:()=>z.list(1,12,s?.id),enabled:!!s?.id}),c=s?.first_name||s?.last_name?`${s.first_name||""} ${s.last_name||""}`.trim():s?.username??"",x=c.split(" ").map(p=>p[0]).join("").toUpperCase().slice(0,2),u=s?.created_at!=null?Q(new Date(s.created_at),"MMM yyyy"):null;return{username:a??null,profile:s,isLoading:d,error:i,tracksData:n,isTracksLoading:l,postsData:r,isPostsLoading:o,playlistsData:t,isPlaylistsLoading:m,displayName:c,initials:x,memberSince:u}}function te(){return e.jsxs("div",{className:"h-64 md:h-80 w-full relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-cyan-900/40 via-purple-900/40 to-magenta-900/40"}),e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-white/10 to-transparent opacity-50"}),e.jsx("div",{className:"absolute inset-0 noise opacity-20","aria-hidden":!0})]})}function re(){return e.jsxs("div",{className:"container mx-auto px-4 py-8 flex flex-col items-center justify-center min-h-layout-page text-center",children:[e.jsx("div",{className:"text-9xl mb-4","aria-hidden":!0,children:"👾"}),e.jsx("h2",{className:"text-3xl font-display font-bold text-destructive mb-2",children:"User Not Found"}),e.jsx("p",{className:"text-muted-foreground text-lg max-w-md",children:"The signal was lost in the void. We couldn't find the profile you were looking for."}),e.jsx(k,{variant:"outline",className:"mt-8",asChild:!0,children:e.jsx(y,{to:"/dashboard",children:"Return to Base"})})]})}function ie({userId:a,initialFollowing:s=!1,onFollowChange:d,className:i,size:n="default",variant:l}){const{data:r}=V(),{success:o,error:t}=$(),m=L(),[c,x]=j.useState(s),[u,p]=j.useState(!1),{data:g}=h({queryKey:["userProfile",a],queryFn:()=>E(a),enabled:!!a&&a!==r?.id,staleTime:3e4});if(j.useEffect(()=>{g&&g.is_following!==void 0?x(g.is_following):s!==void 0&&x(s)},[g,s]),r?.id===a)return null;const U=async()=>{if(u||!r)return;p(!0);const b=!c;try{b?(await F(a),o("Vous suivez maintenant cet utilisateur")):(await S(a),o("Vous ne suivez plus cet utilisateur")),x(b),d?.(b),m.invalidateQueries({queryKey:["userProfile",a]}),m.invalidateQueries({queryKey:["userProfile"]})}catch(T){const q=H(T).message;t(q)}finally{p(!1)}};if(r?.id===a||!r)return null;const C=l||(c?"outline":"default");return e.jsx(k,{onClick:U,disabled:u,variant:C,size:n,className:i||"min-w-[100px]",children:u?e.jsxs(e.Fragment,{children:[e.jsx(R,{className:"h-4 w-4 animate-spin mr-2"}),c?"Désabonnement...":"Abonnement..."]}):c?e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"h-4 w-4 mr-2"}),"Abonné"]}):e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"h-4 w-4 mr-2"}),"Suivre"]})})}function le({profile:a,displayName:s,initials:d,memberSince:i,tracksCount:n,playlistsCount:l,followersCount:r}){return e.jsx(f,{variant:"glass",className:"mb-8 overflow-visible border-white/10 shadow-[0_20px_50px_rgba(0,0,0,0.5)] bg-black/40 backdrop-blur-2xl",children:e.jsxs(P,{className:"pt-0 md:pt-0 pb-8 px-6 md:px-10",children:[e.jsxs("div",{className:"flex flex-col md:flex-row items-start md:items-end gap-6 md:gap-10",children:[e.jsxs("div",{className:"relative -mt-16 md:-mt-20 group",children:[e.jsx("div",{className:"absolute inset-0 rounded-3xl bg-gradient-to-br from-cyan-400 to-magenta-500 blur-lg opacity-50 group-hover:opacity-100 transition-opacity duration-500","aria-hidden":!0}),e.jsx(_,{src:a.avatar_url??void 0,alt:a.username,fallback:d,size:"3xl",className:"h-32 w-32 md:h-40 md:w-40 rounded-3xl border-4 border-background shadow-2xl relative z-10"})]}),e.jsx("div",{className:"flex-1 pt-4 md:pt-6 md:pb-2",children:e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-4xl md:text-5xl font-display font-bold text-white tracking-tight mb-2",children:s}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-6 gap-y-2 text-sm text-muted-foreground/80 font-medium",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-primary",children:[e.jsx("span",{className:"text-primary-foreground/50",children:"@"}),a.username]}),a.location!=null&&a.location!==""&&e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Y,{className:"w-4 h-4","aria-hidden":!0}),a.location]}),i!=null&&e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(G,{className:"w-4 h-4","aria-hidden":!0}),"Joined ",i]})]})]}),e.jsx("div",{className:"flex-shrink-0",children:e.jsx(ie,{userId:a.id.toString()})})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-8 mt-10",children:[e.jsxs("div",{className:"md:col-span-2",children:[e.jsxs("h3",{className:"text-sm font-bold uppercase tracking-widest text-muted-foreground mb-3 flex items-center gap-2",children:[e.jsx(O,{className:"w-4 h-4","aria-hidden":!0})," About"]}),e.jsx("p",{className:"text-lg leading-relaxed text-foreground/90 whitespace-pre-wrap",children:a.bio??e.jsx("span",{className:"text-muted-foreground italic",children:"Systems online. No bio data available."})})]}),e.jsxs("div",{className:"flex items-center justify-between md:justify-end gap-2 bg-white/5 rounded-2xl p-2 border border-white/5",children:[e.jsxs("div",{className:"flex-1 text-center p-3 rounded-xl hover:bg-white/5 transition-colors cursor-default",children:[e.jsx("div",{className:"text-2xl font-bold font-display text-white",children:n}),e.jsx("div",{className:"text-xs uppercase tracking-wider text-muted-foreground font-bold",children:"Tracks"})]}),e.jsx("div",{className:"w-px h-10 bg-white/10","aria-hidden":!0}),e.jsxs("div",{className:"flex-1 text-center p-3 rounded-xl hover:bg-white/5 transition-colors cursor-default",children:[e.jsx("div",{className:"text-2xl font-bold font-display text-white",children:l}),e.jsx("div",{className:"text-xs uppercase tracking-wider text-muted-foreground font-bold",children:"Playlists"})]}),e.jsx("div",{className:"w-px h-10 bg-white/10","aria-hidden":!0}),e.jsxs("div",{className:"flex-1 text-center p-3 rounded-xl hover:bg-white/5 transition-colors cursor-default",children:[e.jsx("div",{className:"text-2xl font-bold font-display text-white",children:r}),e.jsx("div",{className:"text-xs uppercase tracking-wider text-muted-foreground font-bold",children:"Followers"})]})]})]})]})})}function ne({tracksData:a,playlistsData:s,postsData:d}){const i=a?.tracks??[],n=a?.pagination?.total??0,l=s?.playlists??[],r=s?.total??0,o=d?.posts??[];return e.jsxs(ee,{defaultValue:"tracks",className:"w-full",children:[e.jsxs(se,{className:"bg-transparent border-b border-white/10 w-full justify-start h-auto p-0 rounded-none gap-8",children:[e.jsxs(v,{value:"tracks",className:"rounded-none border-b-2 border-transparent data-[state=active]:bg-transparent data-[state=active]:border-primary data-[state=active]:text-primary data-[state=active]:shadow-none py-4 px-0 text-lg font-display bg-transparent",children:["Tracks"," ",e.jsx("span",{className:"ml-2 text-xs bg-white/10 px-2 py-0.5 rounded-full text-muted-foreground align-middle",children:n})]}),e.jsxs(v,{value:"playlists",className:"rounded-none border-b-2 border-transparent data-[state=active]:bg-transparent data-[state=active]:border-primary data-[state=active]:text-primary data-[state=active]:shadow-none py-4 px-0 text-lg font-display bg-transparent",children:["Playlists"," ",e.jsx("span",{className:"ml-2 text-xs bg-white/10 px-2 py-0.5 rounded-full text-muted-foreground align-middle",children:r})]}),e.jsx(v,{value:"posts",className:"rounded-none border-b-2 border-transparent data-[state=active]:bg-transparent data-[state=active]:border-primary data-[state=active]:text-primary data-[state=active]:shadow-none py-4 px-0 text-lg font-display bg-transparent",children:"Feed"})]}),e.jsxs("div",{className:"mt-8 animate-slide-up",children:[e.jsx(N,{value:"tracks",className:"m-0",children:i.length===0?e.jsxs("div",{className:"text-center py-20 bg-muted/5 rounded-3xl border border-dashed border-white/10",children:[e.jsx(w,{className:"h-16 w-16 mx-auto mb-6 text-muted-foreground opacity-20","aria-hidden":!0}),e.jsx("h3",{className:"text-xl font-bold mb-2",children:"No audio signals detected"}),e.jsx("p",{className:"text-muted-foreground",children:"This user currently has no public tracks."})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:i.map(t=>e.jsx(y,{to:`/tracks/${t.id}`,children:e.jsx(f,{variant:"glass",className:"overflow-hidden hover:-translate-y-2 hover:shadow-[0_20px_40px_rgba(0,0,0,0.4)] transition-all duration-300 group border-white/5",children:e.jsxs("div",{className:"relative aspect-video bg-black/50 overflow-hidden",children:[t.cover_art_path!=null?e.jsx("img",{src:t.cover_art_path,alt:t.title,className:"w-full h-full object-cover transition-transform duration-700 group-hover:scale-110"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center bg-muted/10",children:e.jsx(w,{className:"h-12 w-12 text-muted-foreground/30","aria-hidden":!0})}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-transparent to-transparent opacity-60 group-hover:opacity-80 transition-opacity","aria-hidden":!0}),e.jsxs("div",{className:"absolute bottom-4 left-4 right-4",children:[e.jsx("h3",{className:"font-bold text-lg text-white truncate drop-shadow-md",children:t.title}),e.jsx("p",{className:"text-sm text-white/70 truncate",children:t.artist??"Unknown Artist"})]}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity duration-300 bg-black/20 backdrop-blur-[2px]",children:e.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/90 text-primary-foreground flex items-center justify-center shadow-glow-cyan hover:scale-110 transition-transform",children:e.jsx(X,{className:"w-6 h-6 ml-1 fill-current","aria-hidden":!0})})})]})})},t.id))})}),e.jsx(N,{value:"playlists",className:"m-0",children:l.length===0?e.jsxs("div",{className:"text-center py-20 bg-muted/5 rounded-3xl border border-dashed border-white/10",children:[e.jsx(Z,{className:"h-16 w-16 mx-auto mb-6 text-muted-foreground opacity-20","aria-hidden":!0}),e.jsx("h3",{className:"text-xl font-bold mb-2",children:"Archive empty"}),e.jsx("p",{className:"text-muted-foreground",children:"No public playlists found in this sector."})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:l.map(t=>e.jsx(y,{to:`/playlists/${t.id}`,children:e.jsx(K,{playlist:t})},t.id))})}),e.jsx(N,{value:"posts",className:"m-0",children:o.length===0?e.jsxs("div",{className:"text-center py-20 bg-muted/5 rounded-3xl border border-dashed border-white/10",children:[e.jsx(I,{className:"h-16 w-16 mx-auto mb-6 text-muted-foreground opacity-20","aria-hidden":!0}),e.jsx("h3",{className:"text-xl font-bold mb-2",children:"No transmissions"}),e.jsx("p",{className:"text-muted-foreground",children:"This frequency is silent."})]}):e.jsx("div",{className:"space-y-4 max-w-2xl mx-auto",children:o.map(t=>e.jsx(f,{variant:"glass",className:"p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(_,{src:t.author.avatar,alt:t.author.name,fallback:t.author.name[0],className:"mt-1"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsxs("h4",{className:"font-bold text-white",children:[t.author.name,e.jsx("span",{className:"ml-2 text-sm font-normal text-muted-foreground",children:t.author.handle})]}),e.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:new Date(t.timestamp).toLocaleDateString()})]}),e.jsx("p",{className:"mt-3 text-base text-white/80 leading-relaxed font-sans",children:t.content}),e.jsxs("div",{className:"mt-4 flex items-center gap-6 text-xs font-mono text-muted-foreground",children:[e.jsxs("span",{className:"hover:text-primary cursor-pointer transition-colors",children:["❤️ ",t.likes," Likes"]}),e.jsxs("span",{className:"hover:text-primary cursor-pointer transition-colors",children:["💬 ",t.comments," Comments"]})]})]})]})},t.id))})})]})]})}function de(){return e.jsxs("div",{className:"min-h-screen pb-24",role:"status","aria-label":"Loading profile",children:[e.jsx("span",{className:"sr-only",children:"Loading profile"}),e.jsx("div",{className:"h-64 md:h-80 w-full bg-muted/20 animate-pulse","aria-hidden":!0}),e.jsxs("div",{className:"container mx-auto px-4 md:px-8 relative -mt-24 z-10",children:[e.jsx(f,{variant:"glass",className:"mb-8 overflow-visible border-white/10",children:e.jsxs(P,{className:"pt-0 pb-8 px-6 md:px-10",children:[e.jsxs("div",{className:"flex flex-col md:flex-row items-start md:items-end gap-6 md:gap-10",children:[e.jsx("div",{className:"h-32 w-32 md:h-40 md:w-40 rounded-3xl bg-muted animate-pulse -mt-16 md:-mt-20"}),e.jsxs("div",{className:"flex-1 pt-4 md:pt-6 w-full max-w-md",children:[e.jsx("div",{className:"h-10 bg-muted rounded animate-pulse mb-2"}),e.jsx("div",{className:"h-5 bg-muted/80 rounded animate-pulse w-2/3"}),e.jsx("div",{className:"h-9 w-24 bg-muted rounded animate-pulse mt-4"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-8 mt-10",children:[e.jsxs("div",{className:"md:col-span-2 space-y-2",children:[e.jsx("div",{className:"h-4 bg-muted rounded w-16 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted/80 rounded w-full animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted/80 rounded w-4/5 animate-pulse"})]}),e.jsxs("div",{className:"flex gap-2 bg-white/5 rounded-2xl p-2",children:[e.jsx("div",{className:"flex-1 h-16 bg-muted/50 rounded-xl animate-pulse"}),e.jsx("div",{className:"flex-1 h-16 bg-muted/50 rounded-xl animate-pulse"}),e.jsx("div",{className:"flex-1 h-16 bg-muted/50 rounded-xl animate-pulse"})]})]})]})}),e.jsxs("div",{className:"mt-8",children:[e.jsxs("div",{className:"flex gap-8 border-b border-white/10 pb-4",children:[e.jsx("div",{className:"h-6 w-24 bg-muted rounded animate-pulse"}),e.jsx("div",{className:"h-6 w-28 bg-muted rounded animate-pulse"}),e.jsx("div",{className:"h-6 w-16 bg-muted rounded animate-pulse"})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 mt-8",children:[1,2,3].map(a=>e.jsx("div",{className:"aspect-video bg-muted/20 rounded-2xl animate-pulse"},a))})]})]})]})}function ke(){const{username:a,profile:s,isLoading:d,error:i,tracksData:n,playlistsData:l,postsData:r,displayName:o,initials:t,memberSince:m}=ae();return d?e.jsx(de,{}):i!=null||a==null||s==null?e.jsx(re,{}):e.jsxs("div",{className:"min-h-screen pb-24",children:[e.jsx(te,{}),e.jsxs("div",{className:"container mx-auto px-4 md:px-8 relative -mt-24 z-10",children:[e.jsx(le,{profile:s,displayName:o,initials:t,memberSince:m,tracksCount:n?.pagination?.total??0,playlistsCount:l?.total??0,followersCount:s.followers_count??0}),e.jsx(ne,{tracksData:n,playlistsData:l,postsData:r})]})]})}export{ke as UserProfilePage};
|