- Deleted apps/web/src/utils/optimisticStoreUpdates.ts (unused file) - File was unused - no imports found in codebase - Mutations already use React Query's onMutate pattern - No TypeScript errors after deletion - Actions 4.4.1.2 and 4.4.1.3 complete
2 lines
9.8 KiB
JavaScript
2 lines
9.8 KiB
JavaScript
import{n as F,a3 as K,t as M,r as P,a4 as f,j as e,B as q,L as B,bm as V,bn as $,aD as z,aA as p,aL as l,aM as o,aN as N,aO as y,ar as C,M as k,aJ as _}from"./chunk-Cad8leGS.js";import{e as Q,L as g,l as H}from"./index-D792PhRw.js";import{f as J,u as O,g as R,a as G}from"./chunk-Bj3nhta5.js";import{g as W}from"./chunk-B7sOPOlf.js";import{A as U}from"./chunk-BipwgKQz.js";import{T as X,a as Y,b as T,c as L}from"./chunk-DWbKrX8g.js";import{P as Z}from"./chunk-Dx2pq3Hm.js";import{s as I}from"./chunk-C-LINxi8.js";import{b as ee}from"./chunk-B4NZlYwU.js";import"./chunk-wkfC2Tom.js";import"./chunk-BoPufJSi.js";import"./chunk-VMUEamc6.js";import"./chunk-Df4po8fP.js";import"./chunk-BlDLB1ZZ.js";function se({userId:t,initialFollowing:n=!1,onFollowChange:s,className:v,size:u="default",variant:i}){const{data:c}=F(),{success:m,error:b}=K(),r=M(),[x,d]=P.useState(n),[h,j]=P.useState(!1),{data:a}=f({queryKey:["userProfile",t],queryFn:()=>R(t),enabled:!!t&&t!==c?.id,staleTime:3e4});if(P.useEffect(()=>{a&&a.is_following!==void 0?d(a.is_following):n!==void 0&&d(n)},[a,n]),c?.id===t)return null;const S=async()=>{if(h||!c)return;j(!0);const w=!x;try{w?(await J(t),m("Vous suivez maintenant cet utilisateur")):(await O(t),m("Vous ne suivez plus cet utilisateur")),d(w),s?.(w),r.invalidateQueries({queryKey:["userProfile",t]}),r.invalidateQueries({queryKey:["userProfile"]})}catch(A){const D=z(A).message;b(D)}finally{j(!1)}};if(c?.id===t||!c)return null;const E=i||(x?"outline":"default");return e.jsx(q,{onClick:S,disabled:h,variant:E,size:u,className:v||"min-w-[100px]",children:h?e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"h-4 w-4 animate-spin mr-2"}),x?"Désabonnement...":"Abonnement..."]}):x?e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"h-4 w-4 mr-2"}),"Abonné"]}):e.jsxs(e.Fragment,{children:[e.jsx($,{className:"h-4 w-4 mr-2"}),"Suivre"]})})}function pe(){const{username:t}=Q(),{data:n}=F(),{data:s,isLoading:v,error:u}=f({queryKey:["userProfile",t],queryFn:async()=>{if(!t)throw new Error("Username is required");return G(t)},enabled:!!t,retry:!1}),{data:i,isLoading:c}=f({queryKey:["userTracks",s?.id],queryFn:()=>W(1,12,{userId:s?.id}),enabled:!!s?.id}),{data:m,isLoading:b}=f({queryKey:["userPosts",s?.id],queryFn:()=>I.getPostsByUser(s.id,1,s),enabled:!!s?.id}),{data:r,isLoading:x}=f({queryKey:["userPlaylists",s?.id],queryFn:()=>H(1,12,s?.id),enabled:!!s?.id});if(v)return e.jsx("div",{className:"container mx-auto px-4 py-8",children:e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsxs("div",{className:"text-center",children:[e.jsx(p,{}),e.jsx("p",{className:"mt-4 text-muted-foreground",children:"Loading profile..."})]})})});if(u||!t)return e.jsx("div",{className:"container mx-auto px-4 py-8",children:e.jsx(l,{children:e.jsx(o,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h2",{className:"text-2xl font-bold text-destructive mb-2",children:"Error"}),e.jsx("p",{className:"text-muted-foreground",children:u instanceof Error?u.message:t?"Failed to load profile":"Username is required"})]})})})});if(!s)return e.jsx("div",{className:"container mx-auto px-4 py-8",children:e.jsx(l,{children:e.jsx(o,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h2",{className:"text-2xl font-bold mb-2",children:"User Not Found"}),e.jsx("p",{className:"text-muted-foreground",children:"The user profile you're looking for doesn't exist."})]})})})});const d=s.first_name||s.last_name?`${s.first_name||""} ${s.last_name||""}`.trim():s.username,h=d.split(" ").map(a=>a[0]).join("").toUpperCase().slice(0,2),j=s.created_at?ee(new Date(s.created_at),"M/d/yyyy"):null;return e.jsx("div",{className:"container mx-auto px-4 py-8",children:e.jsxs("div",{className:"max-w-4xl mx-auto",children:[e.jsxs(l,{children:[e.jsx(N,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(U,{src:s.avatar_url||void 0,alt:s.username,fallback:h,size:"3xl",className:"h-24 w-24"}),e.jsxs("div",{children:[e.jsx(y,{className:"text-3xl mb-1",children:s.username}),d!==s.username&&e.jsx("p",{className:"text-xl text-muted-foreground",children:d}),j&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:["Member since ",j]})]})]}),e.jsx(se,{userId:s.id.toString()})]})}),e.jsx(o,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4 pb-4 border-b",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:i?.pagination.total||0}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Tracks"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:r?.total||0}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Playlists"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"text-2xl font-bold",children:s.followers_count||0}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Followers"})]})]}),s.bio&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold mb-2",children:"Bio"}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:s.bio})]}),s.location&&e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold mb-2",children:"Location"}),e.jsx("p",{className:"text-muted-foreground",children:s.location})]}),!s.bio&&!s.location&&e.jsx("p",{className:"text-muted-foreground italic",children:"No additional information available."})]})})]}),e.jsxs(X,{defaultValue:"tracks",className:"w-full mt-6",children:[e.jsxs(Y,{children:[e.jsxs(T,{value:"posts",children:[e.jsx(C,{className:"mr-2 h-4 w-4"}),"Posts"]}),e.jsxs(T,{value:"tracks",children:[e.jsx(k,{className:"mr-2 h-4 w-4"}),"Tracks (",i?.pagination.total||0,")"]}),e.jsxs(T,{value:"playlists",children:[e.jsx(_,{className:"mr-2 h-4 w-4"}),"Playlists (",r?.total||0,")"]})]}),e.jsx(L,{value:"posts",className:"mt-6",children:e.jsxs(l,{children:[e.jsx(N,{children:e.jsx(y,{children:"Posts"})}),e.jsx(o,{children:b?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(p,{})}):m?.posts&&m.posts.length>0?e.jsx("div",{className:"space-y-4",children:m.posts.map(a=>e.jsx(l,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(U,{src:a.author.avatar,alt:a.author.name,fallback:a.author.name[0]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsxs("h4",{className:"font-semibold",children:[a.author.name," ",e.jsx("span",{className:"text-sm font-normal text-muted-foreground",children:a.author.handle})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(a.timestamp).toLocaleDateString()})]}),e.jsx("p",{className:"mt-2 text-sm",children:a.content}),e.jsxs("div",{className:"mt-3 flex items-center gap-4 text-xs text-muted-foreground",children:[e.jsxs("span",{children:[a.likes," Likes"]}),e.jsxs("span",{children:[a.comments," Comments"]})]})]})]})},a.id))}):e.jsxs("div",{className:"text-center py-8",children:[e.jsx(C,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground opacity-50"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No posts yet"}),e.jsx("p",{className:"text-muted-foreground",children:"This user hasn't posted anything yet."})]})})]})}),e.jsx(L,{value:"tracks",className:"mt-6",children:e.jsxs(l,{children:[e.jsx(N,{children:e.jsx(y,{children:"Tracks"})}),e.jsxs(o,{children:[c?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(p,{})}):i?.tracks&&i.tracks.length>0?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:i.tracks.map(a=>e.jsx(g,{to:`/tracks/${a.id}`,children:e.jsxs(l,{className:"overflow-hidden hover:shadow-lg transition-shadow cursor-pointer",children:[e.jsx("div",{className:"relative aspect-square bg-muted flex items-center justify-center",children:a.cover_art_path?e.jsx("img",{src:a.cover_art_path,alt:a.title,className:"w-full h-full object-cover"}):e.jsx(k,{className:"h-16 w-16 text-muted-foreground/50"})}),e.jsxs(o,{className:"p-4",children:[e.jsx("h3",{className:"font-medium truncate",children:a.title}),a.artist&&e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:a.artist})]})]})},a.id))}):e.jsxs("div",{className:"text-center py-8",children:[e.jsx(k,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground opacity-50"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No tracks yet"}),e.jsx("p",{className:"text-muted-foreground",children:n?.id===s.id?"Start by uploading your first track to share with others.":"This user has not uploaded any tracks yet."})]}),i&&i.pagination.total>12&&e.jsx("div",{className:"mt-4 text-center",children:e.jsx(q,{variant:"outline",asChild:!0,children:e.jsx(g,{to:`/tracks?user_id=${s.id}`,children:"View All Tracks"})})})]})]})}),e.jsx(L,{value:"playlists",className:"mt-6",children:e.jsxs(l,{children:[e.jsx(N,{children:e.jsx(y,{children:"Playlists"})}),e.jsxs(o,{children:[x?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(p,{})}):r?.playlists&&r.playlists.length>0?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:r.playlists.map(a=>e.jsx(g,{to:`/playlists/${a.id}`,children:e.jsx(Z,{playlist:a})},a.id))}):e.jsxs("div",{className:"text-center py-8",children:[e.jsx(_,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground opacity-50"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No playlists yet"}),e.jsx("p",{className:"text-muted-foreground",children:n?.id===s.id?"Create your first playlist to organize your favorite tracks.":"This user has not created any playlists yet."})]}),r&&r.total>12&&e.jsx("div",{className:"mt-4 text-center",children:e.jsx(q,{variant:"outline",asChild:!0,children:e.jsx(g,{to:`/playlists?user_id=${s.id}`,children:"View All Playlists"})})})]})]})})]})]})})}export{pe as UserProfilePage};
|
|
//# sourceMappingURL=UserProfilePage-B5KUhCAk.js.map
|