1 line
17 KiB
JavaScript
1 line
17 KiB
JavaScript
import{j as e,a as b}from"./vendor-react-Dkpvlwai.js";import{u as f,a as D}from"./vendor-tanstack-BoI3DtL9.js";import{u as E,f as z,a as M,g as K}from"./users-CIEZeIZa.js";import{t as B}from"./tracks-Cjy8Ef7a.js";import{p as $,P as Q}from"./PlaylistCard-Bx1-LioV.js";import{s as V}from"./socialService-x2q6JUuc.js";import{d as H,L as P,u as R}from"./vendor-router-4bycex72.js";import{g as W}from"./vendor-utils-CDFfoeXY.js";import{B as U,u as J,g as Z,p as G,C as v,e as T,k as N,S as i}from"./index-VJPzCABl.js";import{A as L}from"./avatar-aAmhfJnn.js";import{L as O,ap as X,aq as Y,ar as I,as as ee,U as ae,a8 as C,a9 as _,x as se,Z as te,D as re,F as ie,at as ne}from"./vendor-icons-CbmLcMl-.js";import{A as le}from"./AnimatedNumber-Bn2Qf9FV.js";import{T as oe,a as de,b as y,c as w}from"./Tabs-DPskxOgb.js";import"./vendor-CAoAb3tF.js";import"./features-CKIBrJL0.js";function ce(){const{username:a}=H(),{data:s,isLoading:d,error:r}=f({queryKey:["userProfile",a],queryFn:async()=>{if(!a)throw new Error("Username is required");return E.getProfileByUsername(a)},enabled:!!a,retry:!1}),{data:m,isLoading:c}=f({queryKey:["userTracks",s?.id],queryFn:()=>B.list(1,12,{userId:s?.id}),enabled:!!s?.id}),{data:n,isLoading:o}=f({queryKey:["userPosts",s?.id],queryFn:()=>V.getPostsByUser(s.id,1,s),enabled:!!s?.id}),{data:t,isLoading:l}=f({queryKey:["userPlaylists",s?.id],queryFn:()=>$.list(1,12,s?.id),enabled:!!s?.id}),u=s?.first_name||s?.last_name?`${s.first_name||""} ${s.last_name||""}`.trim():s?.username??"",x=u.split(" ").map(p=>p[0]).join("").toUpperCase().slice(0,2),h=s?.created_at!=null?W(new Date(s.created_at),"MMM yyyy"):null,g=r!=null&&typeof r?.response?.status=="number"&&r.response.status===404;return{username:a??null,profile:s,isLoading:d,error:r,isNotFound:g,tracksData:m,isTracksLoading:c,postsData:n,isPostsLoading:o,playlistsData:t,isPlaylistsLoading:l,displayName:u,initials:x,memberSince:h}}function me(){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-br from-primary/30 via-primary/20 to-secondary/30"}),e.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-primary/20 via-transparent to-transparent"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/5 to-transparent",style:{backgroundSize:"200% 100%",animation:"shimmer 8s ease-in-out infinite"},"aria-hidden":!0}),e.jsx("div",{className:"absolute bottom-0 left-6 md:left-10 w-48 h-48 rounded-full bg-primary/15 blur-3xl animate-pulse","aria-hidden":!0}),e.jsx("div",{className:"absolute inset-0 noise opacity-20","aria-hidden":!0}),e.jsx("div",{className:"absolute inset-x-0 bottom-0 h-32 bg-gradient-to-t from-background to-transparent","aria-hidden":!0})]})}function ue({isNotFound:a=!0,onRetry:s}){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:a?"User Not Found":"Something went wrong"}),e.jsx("p",{className:"text-muted-foreground text-lg max-w-md",children:a?"The signal was lost in the void. We couldn't find the profile you were looking for.":"We couldn't load this profile. Check your connection and try again."}),e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3 mt-8",children:[s&&!a&&e.jsx(U,{variant:"default",onClick:s,children:"Try again"}),e.jsx(U,{variant:"outline",asChild:!0,children:e.jsx(P,{to:"/dashboard",children:"Return to Base"})})]})]})}function xe({userId:a,initialFollowing:s=!1,onFollowChange:d,className:r,size:m="default",variant:c}){const{data:n}=J(),{success:o,error:t}=Z(),l=D(),[u,x]=b.useState(s),[h,g]=b.useState(!1),{data:p}=f({queryKey:["userProfile",a],queryFn:()=>K(a),enabled:!!a&&a!==n?.id,staleTime:3e4});if(b.useEffect(()=>{p&&p.is_following!==void 0?x(p.is_following):s!==void 0&&x(s)},[p,s]),n?.id===a)return null;const q=async()=>{if(h||!n)return;g(!0);const j=!u;try{j?(await z(a),o("Vous suivez maintenant cet utilisateur")):(await M(a),o("Vous ne suivez plus cet utilisateur")),x(j),d?.(j),l.invalidateQueries({queryKey:["userProfile",a]}),l.invalidateQueries({queryKey:["userProfile"]})}catch(A){const F=G(A).message;t(F)}finally{g(!1)}};if(n?.id===a||!n)return null;const S=c||(u?"outline":"default");return e.jsx(U,{onClick:q,disabled:h,variant:S,size:m,className:r||"min-w-24",children:h?e.jsxs(e.Fragment,{children:[e.jsx(O,{className:"h-4 w-4 animate-spin mr-2"}),u?"Désabonnement...":"Abonnement..."]}):u?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"h-4 w-4 mr-2"}),"Abonné"]}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{className:"h-4 w-4 mr-2"}),"Suivre"]})})}function pe({profile:a,displayName:s,initials:d,memberSince:r,tracksCount:m,playlistsCount:c,followersCount:n}){const o=[{icon:C,value:m,label:"Tracks"},{icon:_,value:c,label:"Playlists"},{icon:se,value:n,label:"Followers"}];return e.jsx(v,{variant:"glass",className:"mb-8 overflow-visible border-border shadow-cover-depth bg-card/80 backdrop-blur-2xl animate-slide-up",children:e.jsxs(T,{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-1 rounded-3xl bg-gradient-to-br from-primary via-primary/80 to-secondary blur-xl opacity-50 group-hover:opacity-100 transition-opacity duration-[var(--duration-slow)]","aria-hidden":!0}),e.jsx("div",{className:"absolute -inset-0.5 rounded-3xl bg-gradient-to-br from-primary to-secondary opacity-70","aria-hidden":!0}),e.jsx(L,{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-foreground 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 hover:text-foreground transition-colors duration-[var(--duration-fast)]",children:[e.jsx(I,{className:"w-4 h-4","aria-hidden":!0}),a.location]}),r!=null&&e.jsxs("span",{className:"flex items-center gap-1.5 hover:text-foreground transition-colors duration-[var(--duration-fast)]",children:[e.jsx(ee,{className:"w-4 h-4","aria-hidden":!0}),"Joined ",r]})]})]}),e.jsx("div",{className:"flex-shrink-0",children:e.jsx(xe,{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(ae,{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.jsx("div",{className:"flex items-center justify-between md:justify-end gap-2 bg-white/5 rounded-2xl p-2 border border-white/5",children:o.map((t,l)=>e.jsxs("div",{className:"contents",children:[e.jsxs("div",{className:"flex-1 text-center p-3 rounded-xl hover:bg-muted/50 transition-colors duration-[var(--duration-fast)] cursor-default group/stat",children:[e.jsx(t.icon,{className:"w-4 h-4 mx-auto mb-1.5 text-muted-foreground group-hover/stat:text-primary transition-colors duration-[var(--duration-fast)]","aria-hidden":!0}),e.jsx(le,{value:t.value,className:"text-2xl font-bold font-display text-white"}),e.jsx("div",{className:"text-xs uppercase tracking-wider text-muted-foreground font-bold",children:t.label})]}),l<o.length-1&&e.jsx("div",{className:"w-px h-10 bg-border","aria-hidden":!0})]},t.label))})]})]})})}function k(a){return{animationDelay:`${a*60}ms`}}function he({tracksData:a,playlistsData:s,postsData:d}){const r=a?.tracks??[],m=a?.pagination?.total??0,c=s?.playlists??[],n=s?.total??0,o=d?.posts??[];return e.jsxs(oe,{defaultValue:"tracks",className:"w-full",children:[e.jsxs(de,{className:"bg-transparent border-b border-border w-full justify-start h-auto p-0 rounded-none gap-8",children:[e.jsxs(y,{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 transition-colors duration-[var(--duration-fast)]",children:["Tracks"," ",e.jsx("span",{className:"ml-2 text-xs bg-muted/30 px-2 py-0.5 rounded-full text-muted-foreground align-middle",children:m})]}),e.jsxs(y,{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 transition-colors duration-[var(--duration-fast)]",children:["Playlists"," ",e.jsx("span",{className:"ml-2 text-xs bg-muted/30 px-2 py-0.5 rounded-full text-muted-foreground align-middle",children:n})]}),e.jsx(y,{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 transition-colors duration-[var(--duration-fast)]",children:"Feed"})]}),e.jsxs("div",{className:"mt-8",children:[e.jsx(w,{value:"tracks",className:"m-0",children:r.length===0?e.jsx(N,{icon:e.jsx(C,{className:"w-full h-full"}),title:"No tracks yet",description:"This user currently has no public tracks.",size:"lg"}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:r.map((t,l)=>e.jsx(P,{to:`/tracks/${t.id}`,className:"animate-stagger-in",style:k(l),children:e.jsx(v,{variant:"glass",className:"overflow-hidden hover:-translate-y-2 hover:shadow-card-hover transition-all duration-[var(--duration-normal)] group border-border",children:e.jsxs("div",{className:"relative aspect-video bg-muted/30 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(C,{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-foreground truncate drop-shadow-md",children:t.title}),e.jsx("p",{className:"text-sm text-muted-foreground 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-[var(--duration-normal)] bg-background/40 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(te,{className:"w-6 h-6 ml-1 fill-current","aria-hidden":!0})})})]})})},t.id))})}),e.jsx(w,{value:"playlists",className:"m-0",children:c.length===0?e.jsx(N,{icon:e.jsx(_,{className:"w-full h-full"}),title:"No playlists yet",description:"No public playlists found for this user.",size:"lg"}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:c.map((t,l)=>e.jsx(P,{to:`/playlists/${t.id}`,className:"animate-stagger-in",style:k(l),children:e.jsx(Q,{playlist:t})},t.id))})}),e.jsx(w,{value:"posts",className:"m-0",children:o.length===0?e.jsx(N,{icon:e.jsx(re,{className:"w-full h-full"}),title:"No posts yet",description:"This user hasn't posted anything yet.",size:"lg"}):e.jsx("div",{className:"space-y-4 max-w-2xl mx-auto",children:o.map((t,l)=>e.jsx(v,{variant:"glass",className:"p-6 animate-stagger-in hover:bg-muted/50 transition-colors duration-[var(--duration-fast)]",style:k(l),children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(L,{src:t.author.avatar,alt:t.author.name,fallback:t.author.name[0],className:"mt-1"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsxs("h4",{className:"font-bold text-foreground truncate",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 flex-shrink-0",children:new Date(t.timestamp).toLocaleDateString()})]}),e.jsx("p",{className:"mt-3 text-base text-foreground/90 leading-relaxed font-sans",children:t.content}),e.jsxs("div",{className:"mt-4 flex items-center gap-6 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1.5 hover:text-primary cursor-pointer transition-colors duration-[var(--duration-fast)]",children:[e.jsx(ie,{className:"w-3.5 h-3.5","aria-hidden":!0}),t.likes]}),e.jsxs("span",{className:"flex items-center gap-1.5 hover:text-primary cursor-pointer transition-colors duration-[var(--duration-fast)]",children:[e.jsx(ne,{className:"w-3.5 h-3.5","aria-hidden":!0}),t.comments]})]})]})]})},t.id))})})]})]})}function fe(){return e.jsxs("div",{className:"min-h-screen pb-24 animate-fade-in",role:"status","aria-label":"Loading profile",children:[e.jsx("span",{className:"sr-only",children:"Loading profile"}),e.jsxs("div",{className:"h-64 md:h-80 w-full relative overflow-hidden",children:[e.jsx(i,{className:"absolute inset-0","aria-hidden":!0}),e.jsx("div",{className:"absolute inset-x-0 bottom-0 h-32 bg-gradient-to-t from-background to-transparent","aria-hidden":!0})]}),e.jsxs("div",{className:"container mx-auto px-4 md:px-8 relative -mt-24 z-10",children:[e.jsx(v,{variant:"glass",className:"mb-8 overflow-visible border-border bg-card/80 backdrop-blur-2xl",children:e.jsxs(T,{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.jsx(i,{className:"h-32 w-32 md:h-40 md:w-40 rounded-3xl -mt-16 md:-mt-20"}),e.jsxs("div",{className:"flex-1 pt-4 md:pt-6 w-full max-w-md",children:[e.jsx(i,{className:"h-10 rounded mb-2"}),e.jsx(i,{className:"h-5 rounded w-2/3"}),e.jsx(i,{className:"h-9 w-24 rounded 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(i,{className:"h-4 rounded w-16"}),e.jsx(i,{className:"h-4 rounded w-full"}),e.jsx(i,{className:"h-4 rounded w-4/5"})]}),e.jsxs("div",{className:"flex gap-2 bg-muted/20 rounded-2xl p-2 border border-border",children:[e.jsx(i,{className:"flex-1 h-16 rounded-xl"}),e.jsx(i,{className:"flex-1 h-16 rounded-xl"}),e.jsx(i,{className:"flex-1 h-16 rounded-xl"})]})]})]})}),e.jsxs("div",{className:"mt-8",children:[e.jsxs("div",{className:"flex gap-8 border-b border-border pb-4",children:[e.jsx(i,{className:"h-6 w-24 rounded"}),e.jsx(i,{className:"h-6 w-28 rounded"}),e.jsx(i,{className:"h-6 w-16 rounded"})]}),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(i,{className:"aspect-video rounded-2xl"},a))})]})]})]})}function Ae(){const a=R(),{username:s,profile:d,isLoading:r,error:m,isNotFound:c,tracksData:n,playlistsData:o,postsData:t,displayName:l,initials:u,memberSince:x}=ce();return b.useEffect(()=>{!r&&!s&&a("/dashboard",{replace:!0})},[r,s,a]),r?e.jsx(fe,{}):s?m!=null||d==null?e.jsx(ue,{isNotFound:c,onRetry:()=>window.location.reload()}):e.jsxs("div",{className:"min-h-screen pb-24 animate-fade-in",children:[e.jsx(me,{}),e.jsxs("div",{className:"container mx-auto px-4 md:px-8 relative -mt-24 z-10",children:[e.jsx(pe,{profile:d,displayName:l,initials:u,memberSince:x,tracksCount:n?.pagination?.total??0,playlistsCount:o?.total??0,followersCount:d.followers_count??0}),e.jsx(he,{tracksData:n,playlistsData:o,postsData:t})]})]}):null}export{Ae as UserProfilePage};
|