veza/.build/incus/web/js/SearchPage-CyLvFrqT.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

2 lines
9.6 KiB
JavaScript

import{r as h,a4 as w,j as s,aL as l,aM as c,a8 as P,G as O,B as p,X as W,aA as N,M as u,aJ as C,ao as S}from"./chunk-Cad8leGS.js";import{d as Y,a as Z,L as x,z as ss,s as es,A as as}from"./index-D792PhRw.js";import{T as ts,a as rs,b as f,c as v}from"./chunk-DWbKrX8g.js";import{P as F}from"./chunk-Dx2pq3Hm.js";import{A as K}from"./chunk-BipwgKQz.js";import{P as T}from"./chunk-C2j-MMB3.js";import"./chunk-wkfC2Tom.js";import"./chunk-BoPufJSi.js";import"./chunk-VMUEamc6.js";import"./chunk-Df4po8fP.js";import"./chunk-B7sOPOlf.js";import"./chunk-B4NZlYwU.js";import"./chunk-BlDLB1ZZ.js";function Ns(){const[L,k]=Y(),[j,q]=h.useState(L.get("q")||""),[r,g]=h.useState(L.get("type")||"all"),[i,m]=h.useState(1),a=20,t=Z(j,500);h.useEffect(()=>{const e=new URLSearchParams;t&&e.set("q",t),r!=="all"&&e.set("type",r),k(e,{replace:!0})},[t,r,k]),h.useEffect(()=>{m(1)},[t,r]);const{data:E,isLoading:U,isError:B}=w({queryKey:["searchTracks",t,i,a],queryFn:()=>ss(t,{pagination:{page:i,limit:a}}),enabled:(r==="all"||r==="tracks")&&!!t.trim()}),{data:A,isLoading:I,isError:G}=w({queryKey:["searchPlaylists",t,i,a],queryFn:()=>es({q:t,page:i,limit:a}),enabled:(r==="all"||r==="playlists")&&!!t.trim()}),{data:_,isLoading:M,isError:J}=w({queryKey:["searchUsers",t,i,a],queryFn:()=>as({query:t,page:i,limit:a}),enabled:(r==="all"||r==="users")&&!!t.trim()}),$=E?.data||[],D=A?.playlists||[],Q=_?.users||[],n=E?.total||0,d=A?.total||0,o=_?.total||0,z=n+d+o,y=U||I||M,b=B||G||J,X=e=>{e.preventDefault(),j.trim()&&m(1)},H=()=>{q(""),m(1)},R=z>0,V=t.trim().length>0;return s.jsx("div",{className:"container mx-auto px-4 py-8",children:s.jsxs("div",{className:"max-w-4xl mx-auto",children:[s.jsxs("div",{className:"mb-8",children:[s.jsx("h1",{className:"text-3xl font-bold mb-2",children:"Search"}),s.jsx("p",{className:"text-muted-foreground",children:"Search for tracks, playlists, and users"})]}),s.jsx(l,{className:"mb-6",children:s.jsx(c,{className:"pt-6",children:s.jsx("form",{onSubmit:X,className:"space-y-4",children:s.jsxs("div",{className:"relative",children:[s.jsx(P,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-5 w-5 text-muted-foreground"}),s.jsx(O,{type:"text",placeholder:"Search tracks, playlists, users...",value:j,onChange:e=>q(e.target.value),className:"pl-10 pr-10"}),j&&s.jsx(p,{type:"button",variant:"ghost",size:"icon",className:"absolute right-1 top-1/2 transform -translate-y-1/2 h-8 w-8",onClick:H,children:s.jsx(W,{className:"h-4 w-4"})})]})})})}),V&&s.jsxs("div",{className:"space-y-6",children:[y&&s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(N,{})}),b&&s.jsx(l,{children:s.jsx(c,{className:"pt-6",children:s.jsx("div",{className:"text-center text-destructive",children:s.jsx("p",{children:"An error occurred while searching. Please try again."})})})}),!y&&!b&&!R&&s.jsx(l,{children:s.jsx(c,{className:"pt-6",children:s.jsxs("div",{className:"text-center py-12",children:[s.jsx(P,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground opacity-50"}),s.jsxs("p",{className:"text-muted-foreground",children:['No results found for "',t,'"']})]})})}),!y&&!b&&R&&s.jsxs(ts,{value:r,onValueChange:e=>g(e),children:[s.jsxs(rs,{className:"grid w-full grid-cols-4",children:[s.jsxs(f,{value:"all",children:["All (",z,")"]}),s.jsxs(f,{value:"tracks",children:[s.jsx(u,{className:"h-4 w-4 mr-2"}),"Tracks (",n,")"]}),s.jsxs(f,{value:"playlists",children:[s.jsx(C,{className:"h-4 w-4 mr-2"}),"Playlists (",d,")"]}),s.jsxs(f,{value:"users",children:[s.jsx(S,{className:"h-4 w-4 mr-2"}),"Users (",o,")"]})]}),s.jsx(v,{value:"all",className:"mt-6",children:s.jsxs("div",{className:"space-y-6",children:[n>0&&s.jsxs("div",{children:[s.jsxs("h2",{className:"text-xl font-bold mb-4 flex items-center gap-2",children:[s.jsx(u,{className:"h-5 w-5"}),"Tracks (",n,")"]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:$.slice(0,6).map(e=>s.jsx(x,{to:`/tracks/${e.id}`,children:s.jsxs(l,{className:"overflow-hidden hover:shadow-lg transition-shadow cursor-pointer",children:[s.jsx("div",{className:"relative aspect-square bg-muted flex items-center justify-center",children:e.cover?s.jsx("img",{src:e.cover,alt:e.title,className:"w-full h-full object-cover"}):s.jsx(u,{className:"h-16 w-16 text-muted-foreground/50"})}),s.jsxs(c,{className:"p-4",children:[s.jsx("h3",{className:"font-medium truncate",children:e.title}),e.artist&&s.jsx("p",{className:"text-sm text-muted-foreground truncate",children:e.artist})]})]})},e.id))}),n>6&&s.jsx("div",{className:"mt-4 text-center",children:s.jsx(p,{variant:"outline",onClick:()=>g("tracks"),children:"View All Tracks"})})]}),d>0&&s.jsxs("div",{children:[s.jsxs("h2",{className:"text-xl font-bold mb-4 flex items-center gap-2",children:[s.jsx(C,{className:"h-5 w-5"}),"Playlists (",d,")"]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:D.slice(0,6).map(e=>s.jsx(x,{to:`/playlists/${e.id}`,children:s.jsx(F,{playlist:e})},e.id))}),d>6&&s.jsx("div",{className:"mt-4 text-center",children:s.jsx(p,{variant:"outline",onClick:()=>g("playlists"),children:"View All Playlists"})})]}),o>0&&s.jsxs("div",{children:[s.jsxs("h2",{className:"text-xl font-bold mb-4 flex items-center gap-2",children:[s.jsx(S,{className:"h-5 w-5"}),"Users (",o,")"]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Q.slice(0,6).map(e=>s.jsx(x,{to:`/u/${e.username}`,children:s.jsx(l,{className:"hover:shadow-lg transition-shadow cursor-pointer",children:s.jsx(c,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(K,{src:e.avatar_url||"",fallback:e.username[0].toUpperCase(),size:"md"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:"font-medium truncate",children:e.username}),e.first_name||e.last_name?s.jsxs("p",{className:"text-sm text-muted-foreground truncate",children:[e.first_name," ",e.last_name]}):null]})]})})})},e.id))}),o>6&&s.jsx("div",{className:"mt-4 text-center",children:s.jsx(p,{variant:"outline",onClick:()=>g("users"),children:"View All Users"})})]})]})}),s.jsxs(v,{value:"tracks",className:"mt-6",children:[U?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(N,{})}):n===0?s.jsx(l,{children:s.jsx(c,{className:"pt-6",children:s.jsxs("div",{className:"text-center py-12",children:[s.jsx(u,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground opacity-50"}),s.jsx("p",{className:"text-muted-foreground",children:"No tracks found"})]})})}):s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:$.map(e=>s.jsx(x,{to:`/tracks/${e.id}`,children:s.jsxs(l,{className:"overflow-hidden hover:shadow-lg transition-shadow cursor-pointer",children:[s.jsx("div",{className:"relative aspect-square bg-muted flex items-center justify-center",children:e.cover?s.jsx("img",{src:e.cover,alt:e.title,className:"w-full h-full object-cover"}):s.jsx(u,{className:"h-16 w-16 text-muted-foreground/50"})}),s.jsxs(c,{className:"p-4",children:[s.jsx("h3",{className:"font-medium truncate",children:e.title}),e.artist&&s.jsx("p",{className:"text-sm text-muted-foreground truncate",children:e.artist})]})]})},e.id))}),n>a&&s.jsx(T,{currentPage:i,totalPages:Math.ceil(n/a),onPageChange:m,totalItems:n,itemsPerPage:a,showItemsInfo:!0,className:"mt-6"})]}),s.jsxs(v,{value:"playlists",className:"mt-6",children:[I?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(N,{})}):d===0?s.jsx(l,{children:s.jsx(c,{className:"pt-6",children:s.jsxs("div",{className:"text-center py-12",children:[s.jsx(C,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground opacity-50"}),s.jsx("p",{className:"text-muted-foreground",children:"No playlists found"})]})})}):s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:D.map(e=>s.jsx(x,{to:`/playlists/${e.id}`,children:s.jsx(F,{playlist:e})},e.id))}),d>a&&s.jsx(T,{currentPage:i,totalPages:Math.ceil(d/a),onPageChange:m,totalItems:d,itemsPerPage:a,showItemsInfo:!0,className:"mt-6"})]}),s.jsxs(v,{value:"users",className:"mt-6",children:[M?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(N,{})}):o===0?s.jsx(l,{children:s.jsx(c,{className:"pt-6",children:s.jsxs("div",{className:"text-center py-12",children:[s.jsx(S,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground opacity-50"}),s.jsx("p",{className:"text-muted-foreground",children:"No users found"})]})})}):s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Q.map(e=>s.jsx(x,{to:`/u/${e.username}`,children:s.jsx(l,{className:"hover:shadow-lg transition-shadow cursor-pointer",children:s.jsx(c,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(K,{src:e.avatar_url||"",fallback:e.username[0].toUpperCase(),size:"md"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:"font-medium truncate",children:e.username}),e.first_name||e.last_name?s.jsxs("p",{className:"text-sm text-muted-foreground truncate",children:[e.first_name," ",e.last_name]}):null,e.bio&&s.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:e.bio})]})]})})})},e.id))}),o>a&&s.jsx(T,{currentPage:i,totalPages:Math.ceil(o/a),onPageChange:m,totalItems:o,itemsPerPage:a,showItemsInfo:!0,className:"mt-6"})]})]})]}),!V&&s.jsx(l,{children:s.jsx(c,{className:"pt-6",children:s.jsxs("div",{className:"text-center py-12",children:[s.jsx(P,{className:"h-16 w-16 mx-auto mb-4 text-muted-foreground opacity-50"}),s.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Start Searching"}),s.jsx("p",{className:"text-muted-foreground",children:"Enter a search query to find tracks, playlists, and users"})]})})})]})})}export{Ns as SearchPage};
//# sourceMappingURL=SearchPage-CyLvFrqT.js.map