veza/.build/incus/web/js/DashboardPage-tU6v8lrU.js
senke 1ed6e7f07b state-ownership: delete unused optimisticStoreUpdates.ts file
- 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
2026-01-15 19:26:53 +01:00

3 lines
14 KiB
JavaScript

const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/chunk-m7Vgm5hx.js","js/chunk-Dj70Y9U3.js","js/chunk-CbPYJovs.js","js/chunk-VMUEamc6.js","js/chunk-DZ12PeIs.js"])))=>i.map(i=>d[i]);
import{a4 as T,o as k,t as S,aB as N,N as w,l as E,r as p,j as e,c as j,n as D,M as L,ar as _,au as F,ao as R,B as g,aJ as A,aK as q,aL as f,aM as h,aN as v,aO as b,aP as I,aQ as C,a9 as K,U as P}from"./chunk-m7Vgm5hx.js";import{C as Q,B as M,u as $}from"./index-vht7ZNSp.js";import{s as B}from"./chunk-Ofl1aOM0.js";import{f as U,a as V}from"./chunk-B4NZlYwU.js";import"./chunk-Dj70Y9U3.js";import"./chunk-CbPYJovs.js";import"./chunk-VMUEamc6.js";import"./chunk-DZ12PeIs.js";import"./chunk-pW9FG0iV.js";import"./chunk-CSrBv2n5.js";const d={all:["library"],items:a=>[...d.all,"items",a],favorites:()=>[...d.all,"favorites"]};async function G(a={}){const{page:t=1,limit:n=20,type:i,search:o}=a,s=(await k.get("/tracks",{params:{page:t,limit:n,type:i,search:o}})).data,m=Array.isArray(s.items)?s.items:Array.isArray(s)?s:[];return{...s,items:m,page:s.page||t,limit:s.limit||n,total:s.total||0,has_next:s.has_next??!1,has_prev:s.has_prev??!1}}async function O(){const t=(await k.get("/tracks",{params:{page:1,limit:100,type:"favorites"}})).data;return Array.isArray(t.items)?t.items:Array.isArray(t)?t:[]}function X(a={}){return T({queryKey:d.items(a),queryFn:()=>G(a),staleTime:300*1e3,gcTime:600*1e3})}function z(){return T({queryKey:d.favorites(),queryFn:O,staleTime:300*1e3,gcTime:600*1e3})}typeof window<"u"&&(window.React=w,w&&!w.Children&&console.error("[CRITICAL] React.Children not available after import"));function J(){const a=X({}),t=z();return{isLoading:a.isLoading||t.isLoading,error:a.error||t.error}}function H(){const a=S();return{fetchItems:async t=>{await a.refetchQueries({queryKey:d.items(t)})},fetchFavorites:async()=>{await a.refetchQueries({queryKey:d.favorites()})},uploadFile:async(t,n)=>{const{apiClient:i}=await N(async()=>{const{apiClient:l}=await import("./chunk-m7Vgm5hx.js").then(s=>s.bX);return{apiClient:l}},__vite__mapDeps([0,1,2,3,4])),o=new FormData;o.append("file",t),o.append("title",n.title),n.description&&o.append("description",n.description),await i.post("/tracks",o,{headers:{"Content-Type":"multipart/form-data"}}),await a.invalidateQueries({queryKey:d.all})},toggleFavorite:async t=>{const{apiClient:n}=await N(async()=>{const{apiClient:i}=await import("./chunk-m7Vgm5hx.js").then(o=>o.bX);return{apiClient:i}},__vite__mapDeps([0,1,2,3,4]));await n.post(`/tracks/${t}/favorite`),await a.invalidateQueries({queryKey:d.all})},deleteItem:async t=>{const{apiClient:n}=await N(async()=>{const{apiClient:i}=await import("./chunk-m7Vgm5hx.js").then(o=>o.bX);return{apiClient:i}},__vite__mapDeps([0,1,2,3,4]));await n.delete(`/tracks/${t}`),await a.invalidateQueries({queryKey:d.all})},clearItems:()=>{a.invalidateQueries({queryKey:d.all})}}}async function W(){try{const a=await k.get("/audit/stats"),t={tracks_played:0,messages_sent:0,favorites:0,active_friends:0};return a.data?.stats&&a.data.stats.forEach(i=>{(i.action==="upload"||i.action==="play")&&(t.tracks_played+=i.action_count||0),(i.action==="message_sent"||i.action?.includes("message"))&&(t.messages_sent+=i.action_count||0),(i.action==="favorite"||i.action?.includes("favorite"))&&(t.favorites+=i.action_count||0)}),t}catch(a){return E.error("Failed to fetch dashboard stats",{error:a instanceof Error?a.message:String(a),stack:a instanceof Error?a.stack:void 0}),{tracks_played:0,messages_sent:0,favorites:0,active_friends:0}}}async function Y(a=10){try{const[t,n]=await Promise.all([k.get("/audit/activity",{params:{limit:a}}).catch(()=>({data:{activity:[]}})),B.getFeed({limit:a}).catch(()=>({posts:[]}))]),i=(t.data?.activity||[]).map(s=>({id:s.id||"",type:Z(s.action),title:ee(s.action,s.resource,s.metadata),description:te(s.action,s.metadata),timestamp:s.timestamp||s.created_at||new Date().toISOString()})),o=(n.posts||[]).map(s=>({id:s.id,type:"post",title:`${s.author.name} a publié`,description:s.content.length>50?`${s.content.substring(0,50)}...`:s.content,timestamp:s.timestamp,icon:s.author.avatar}));return[...i,...o].sort((s,m)=>new Date(m.timestamp).getTime()-new Date(s.timestamp).getTime()).slice(0,a)}catch(t){return E.error("Failed to fetch recent activity",{error:t instanceof Error?t.message:String(t),stack:t instanceof Error?t.stack:void 0,limit:a}),[]}}function Z(a){return a.includes("upload")||a.includes("track")?"track_upload":a.includes("message")||a.includes("chat")?"message_received":a.includes("favorite")||a.includes("like")?"favorite_added":a.includes("playlist")?"playlist_created":a.includes("comment")?"comment_added":"track_upload"}function ee(a,t,n){return a.includes("upload")?"Nouvelle piste ajoutée":a.includes("message")?`Message reçu de @${n?.username||n?.from_user||"un utilisateur"}`:a.includes("favorite")||a.includes("like")?"Nouveau favori ajouté":a.includes("playlist")?"Nouvelle playlist créée":a.includes("comment")?"Nouveau commentaire":"Nouvelle activité"}function te(a,t){return t?.file_name?t.file_name:t?.track_title?t.track_title:t?.playlist_name?t.playlist_name:""}async function ae(){const[a,t]=await Promise.all([W(),Y(10)]);return{stats:a,recent_activity:t}}function se(){const[a,t]=p.useState(null),[n,i]=p.useState([]),[o,l]=p.useState(!0),[s,m]=p.useState(null),y=async()=>{l(!0),m(null);try{const u=await ae();t(u.stats),i(u.recent_activity)}catch(u){m(u instanceof Error?u:new Error("Failed to fetch dashboard data")),t({tracks_played:0,messages_sent:0,favorites:0,active_friends:0}),i([])}finally{l(!1)}};return p.useEffect(()=>{y()},[]),{stats:a,recentActivity:n,isLoading:o,error:s,refetch:y}}function re({icon:a,title:t,description:n,actionLabel:i,onAction:o,className:l}){return e.jsxs(Q,{variant:"glass",className:j("flex flex-col items-center justify-center text-center p-8 sm:p-12 animate-slideUp",l),children:[e.jsxs("div",{className:"relative mb-6",children:[e.jsx("div",{className:"absolute inset-0 bg-kodo-cyan/20 blur-2xl rounded-full animate-pulse"}),e.jsx("div",{className:"relative bg-kodo-ink p-4 rounded-2xl border border-kodo-cyan/30 shadow-neon-cyan animate-float",children:e.jsx(a,{className:"h-10 w-10 text-kodo-cyan"})})]}),e.jsx("h3",{className:"text-xl font-display font-bold text-white mb-2 tracking-tight",children:t}),e.jsx("p",{className:"text-kodo-secondary max-w-xs mb-8 text-sm sm:text-base leading-relaxed",children:n}),i&&o&&e.jsx(M,{variant:"gaming",onClick:o,className:"group",children:e.jsx("span",{className:"flex items-center gap-2",children:i})})]})}function fe(){const{fetchItems:a}=H();J();const{stats:t,recentActivity:n,isLoading:i}=se(),o=$(),{data:l}=D();p.useEffect(()=>{a({limit:5})},[a]);const s=r=>r>=1e6?`${(r/1e6).toFixed(1)}M`:r>=1e3?`${(r/1e3).toFixed(1)}K`:r.toString(),m=[{title:"Pistes écoutées",value:t?s(t.tracks_played):"0",change:t?.tracks_played_change||"+0%",icon:L,color:"text-kodo-cyan",bgGradient:"from-kodo-cyan/10 to-kodo-cyan/5"},{title:"Messages envoyés",value:t?s(t.messages_sent):"0",change:t?.messages_sent_change||"+0%",icon:_,color:"text-kodo-lime",bgGradient:"from-kodo-lime/10 to-kodo-lime/5"},{title:"Favoris",value:t?s(t.favorites):"0",change:t?.favorites_change||"+0%",icon:F,color:"text-kodo-magenta",bgGradient:"from-kodo-magenta/10 to-kodo-magenta/5"},{title:"Amis actifs",value:t?s(t.active_friends):"0",change:t?.active_friends_change||"+0%",icon:R,color:"text-kodo-gold",bgGradient:"from-kodo-gold/10 to-kodo-gold/5"}],y=p.useMemo(()=>{const r={};return n.reduce((c,x)=>{if(!r[x.timestamp])try{r[x.timestamp]=U(new Date(x.timestamp),{addSuffix:!0,locale:V})}catch{r[x.timestamp]="Récemment"}return c[x.timestamp]=r[x.timestamp],c},{})},[n]),u=r=>y[r]||"Récemment";return e.jsxs("div",{className:"space-y-8 pb-12 animate-fade-in",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h1",{className:"text-4xl font-bold text-white tracking-tight",children:["Bienvenue,"," ",e.jsx("span",{className:"text-kodo-cyan",children:l?.username||"Utilisateur"})]}),e.jsx("p",{className:"text-kodo-secondary text-sm",children:"Voici un aperçu de votre activité sur Veza"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(g,{variant:"outline",size:"lg",onClick:()=>o("/library"),className:"hidden sm:flex",children:[e.jsx(A,{className:"w-4 h-4 mr-2"}),"Bibliothèque"]}),e.jsxs(g,{variant:"default",size:"lg",onClick:()=>o("/library?action=upload"),className:"shadow-glow-cyan",children:[e.jsx(q,{className:"w-4 h-4 mr-2"}),"Upload Track"]})]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:m.map((r,c)=>e.jsx(f,{className:"group hover:border-kodo-cyan/30 transition-all duration-300",children:e.jsxs(h,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("div",{className:j("p-3 rounded-xl bg-gradient-to-br",r.bgGradient,"border border-white/10 group-hover:scale-110 transition-transform duration-300"),children:e.jsx(r.icon,{className:j("w-5 h-5",r.color)})}),e.jsx("div",{className:j("text-xs font-semibold px-2 py-1 rounded-lg",r.change.startsWith("+")?"bg-kodo-lime/10 text-kodo-lime border border-kodo-lime/20":"bg-kodo-red/10 text-kodo-red border border-kodo-red/20"),children:r.change})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs font-medium text-kodo-secondary uppercase tracking-wider",children:r.title}),e.jsx("p",{className:"text-3xl font-bold text-white",children:r.value})]})]})},c))}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(f,{children:[e.jsx(v,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(I,{className:"w-5 h-5 text-kodo-cyan"}),"Activité récente"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{className:"text-xs font-medium text-kodo-secondary hover:text-kodo-cyan transition-colors px-2 py-1",children:"7J"}),e.jsx("button",{className:"text-xs font-medium text-kodo-cyan bg-kodo-cyan/10 px-2 py-1 rounded-lg border border-kodo-cyan/20",children:"30J"}),e.jsx("button",{className:"text-xs font-medium text-kodo-secondary hover:text-kodo-cyan transition-colors px-2 py-1",children:"MAX"})]})]})}),e.jsx(h,{children:e.jsx("div",{className:"h-64 flex items-end gap-2",children:[40,65,35,90,55,75,45,85,60,70,50,95].map((r,c)=>e.jsx("div",{className:"flex-1 bg-gradient-to-t from-kodo-cyan/40 to-kodo-cyan/20 rounded-t-lg transition-all duration-300 hover:from-kodo-cyan/60 hover:to-kodo-cyan/40 cursor-pointer group relative",style:{height:`${r}%`},children:e.jsxs("div",{className:"absolute -top-8 left-1/2 -translate-x-1/2 bg-kodo-ink border border-kodo-cyan/30 text-kodo-cyan text-xs px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap shadow-lg",children:[r,"%"]})},c))})})]}),e.jsxs(f,{children:[e.jsx(v,{children:e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(C,{className:"w-5 h-5 text-kodo-cyan"}),"Dernières activités"]})}),e.jsx(h,{children:e.jsx("div",{className:"space-y-4",children:i?Array(3).fill(0).map((r,c)=>e.jsx("div",{className:"h-16 bg-white/5 rounded-xl animate-pulse"},c)):n.length>0?n.slice(0,5).map((r,c)=>e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-xl bg-white/5 border border-white/5 hover:bg-white/10 hover:border-kodo-cyan/30 transition-all duration-200 group cursor-pointer",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-gradient-to-br from-kodo-cyan/20 to-kodo-cyan/10 border border-kodo-cyan/20 flex items-center justify-center group-hover:scale-110 transition-transform",children:e.jsx(K,{className:"w-5 h-5 text-kodo-cyan"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-white group-hover:text-kodo-cyan transition-colors",children:r.title}),e.jsx("p",{className:"text-xs text-kodo-secondary mt-0.5",children:r.description||"Activité système"})]})]}),e.jsx("div",{className:"text-xs text-kodo-secondary font-mono",children:u(r.timestamp)})]},c)):e.jsx(re,{icon:C,title:"Aucune activité récente",description:"Vos activités apparaîtront ici"})})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(f,{children:[e.jsx(v,{children:e.jsx(b,{className:"text-lg",children:"Actions rapides"})}),e.jsx(h,{className:"space-y-3",children:[{label:"Upload Track",icon:P,action:()=>o("/library?action=upload"),variant:"default"},{label:"Bibliothèque",icon:A,action:()=>o("/library"),variant:"outline"},{label:"Messages",icon:_,action:()=>o("/chat"),variant:"outline"}].map((r,c)=>e.jsxs(g,{variant:r.variant,className:"w-full justify-start",onClick:r.action,children:[e.jsx(r.icon,{className:"w-4 h-4 mr-2"}),r.label]},c))})]}),e.jsxs(f,{children:[e.jsx(v,{children:e.jsx(b,{className:"text-lg",children:"Statut système"})}),e.jsxs(h,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-kodo-secondary",children:"Backend API"}),e.jsxs("span",{className:"text-kodo-lime font-semibold flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-kodo-lime animate-pulse"}),"En ligne"]})]}),e.jsx("div",{className:"h-1.5 w-full bg-white/5 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-kodo-lime w-full"})})]}),e.jsx("div",{className:"pt-4 border-t border-white/5",children:e.jsx(g,{variant:"ghost",className:"w-full",onClick:()=>o("/settings"),children:"Paramètres système"})})]})]})]})]})]})}export{fe as DashboardPage};
//# sourceMappingURL=DashboardPage-tU6v8lrU.js.map