PageSourceSearch

https://iconaapp.com/assets/category-BW7mtV3U.js

js iconaapp.com collected 2026-10-06 15:24:10 UTC 6,380 bytes, 1 lines download raw bytes

1import{H as O,r as d,i as V,Q as W,h as z,d as I,ai as G,j as e,L as w,B as M,e as _,k as J,M as R,g as X}from"./index-WHULU0jW.js";import{u as T}from"./useMutation-BYXU51OA.js";import{u as Y}from"./useInfiniteQuery-0nS4gBGR.js";import{S as Z}from"./show-card-BVYhb6Yk.js";import{C as D}from"./chevron-right-DeJyYtwC.js";import"./avatar-CiHUCdk-.js";import"./user-badge-Dv8r1xDL.js";import"./circle-check-big-CfzjSlYs.js";import"./star-DOWfXQTG.js";import"./en-US-Cc-9gH5A.js";import"./bookmark-HYwFQqYT.js";import"./isTomorrow-CdPkTDkl.js";import"./constructNow-BkTMlMS8.js";import"./isSameDay-Dbbmvugx.js";import"./format-CILBJ7El.js";function xe(){var E,U,L,S;const[,m]=O("/category/:id"),r=m==null?void 0:m.id,[g,c]=d.useState(!1),{toast:u}=V(),j=W(),{externalApiUrl:$}=z(),{data:o}=I({queryKey:["/api/auth/session"]}),n=((E=o==null?void 0:o.data)==null?void 0:E._id)||((U=o==null?void 0:o.data)==null?void 0:U.id),{data:f}=I({queryKey:["/api/categories"]}),y=(f==null?void 0:f.categories)||[];let s=y.find(t=>t._id===r),l;if(!s)for(const t of y){const i=(L=t.subCategories)==null?void 0:L.find(a=>a._id===r);if(i){s=i,l=t;break}}const{data:x,fetchNextPage:b,hasNextPage:N,isFetchingNextPage:h,isLoading:K}=Y({queryKey:["/api/rooms",r],queryFn:async({pageParam:t=1})=>{const i=new URLSearchParams({page:String(t),limit:"20",status:"active"});return r&&i.set("category",r),(await X(`/api/rooms?${i}`)).json()},getNextPageParam:(t,i)=>{const a=i.length,A=t.totalDoc||0,C=Math.max(t.limits||20,1),H=Math.ceil(A/C);return a<H?a+1:void 0},initialPageParam:1,enabled:!!r}),P=((S=x==null?void 0:x.pages)==null?void 0:S.flatMap(t=>t.rooms||[]))||[],F=d.useRef(null);d.useEffect(()=>{const t=new IntersectionObserver(a=>{a[0].isIntersecting&&N&&!h&&b()},{threshold:0,rootMargin:"100px"}),i=F.current;return i&&t.observe(i),()=>{i&&t.unobserve(i)}},[N,h,b]);const k=(s==null?void 0:s.subCategories)||[],q=!!l;G((s==null?void 0:s.name)||"Category");const p=T({mutationFn:async()=>{if(!n||!r)throw new Error("User not logged in");return await R("PUT",`/api/category/follow/${r}`)},onSuccess:()=>{c(!0),j.invalidateQueries({queryKey:["/api/categories"]})},onError:t=>{u({title:"Error",description:t.message||"Failed to follow category",variant:"destructive"})}}),v=T({mutationFn:async()=>{if(!n||!r)throw new Error("User not logged in");return await R("PUT",`/api/category/unfollow/${r}`)},onSuccess:()=>{c(!1),j.invalidateQueries({queryKey:["/api/categories"]})},onError:t=>{u({title:"Error",description:t.message||"Failed to unfollow category",variant:"destructive"})}});d.useEffect(()=>{c(s&&n?s.isFollowing===!0:!1),window.scrollTo({top:0,behavior:"smooth"})},[r,s,n]);const Q=()=>{if(!n){u({title:"Login Required",description:"Please log in to follow categories",variant:"destructive"});return}g?v.mutate():p.mutate()},B=t=>t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString();return s?e.jsx("div",{className:"flex flex-col min-h-screen bg-background","data-testid":"page-category",children:e.jsx("main",{className:"flex-1 overflow-y-auto bg-white dark:bg-background",children:e.jsx("div",{className:"flex justify-center w-full",children:e.jsxs("div",{className:"w-full lg:w-[90%] px-2 py-3 lg:p-6",children:[q&&l&&e.jsxs("div",{className:"flex items-center gap-2 mb-3 text-sm","data-testid":"breadcrumb",children:[e.jsx(w,{href:`/category/${l._id}`,className:"text-primary hover:underline",children:l.name}),e.jsx(D,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:s==null?void 0:s.name})]}),e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h1",{className:"text-2xl lg:text-3xl font-bold text-foreground","data-testid":"heading-category",children:s==null?void 0:s.name}),e.jsx(M,{className:_("rounded-full font-semibold px-4 lg:px-6 h-9 lg:h-10",g?"bg-muted text-foreground hover:bg-muted/80":"bg-primary text-primary-foreground hover:bg-primary/90"),onClick:Q,disabled:p.isPending||v.isPending,"data-testid":"button-follow-category",children:p.isPending||v.isPending?"Loading...":g?"Following":"Follow"})]}),!q&&k.length>0&&e.jsx("div",{className:"mb-6 overflow-x-auto scrollbar-hide","data-testid":"subcategories-container",children:e.jsx("div",{className:"flex gap-3",children:k.map(t=>{const i=t.icon?J(t.icon,$):"";return e.jsx(w,{href:`/category/${t._id}`,className:_("relative flex-shrink-0 h-16 lg:h-20 rounded-lg overflow-hidden transition-all","hover:ring-2 hover:ring-primary"),"data-testid":`subcategory-${t._id}`,children:e.jsxs("div",{className:"relative h-full w-32 lg:w-40",children:[i?e.jsx("img",{src:i,alt:t.name,className:"absolute inset-0 w-full h-full object-cover"}):e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-primary/20 to-primary/40"}),e.jsx("div",{className:"absolute inset-0 bg-black/30"}),e.jsxs("div",{className:"relative h-full flex flex-col justify-between p-2.5",children:[(t.viewersCount??0)>0&&e.jsxs("div",{className:"flex items-center gap-1 self-start",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-red-600"}),e.jsxs("span",{className:"text-white text-xs font-semibold",children:[B(t.viewersCount??0)," viewers"]})]}),e.jsx("div",{className:"text-white font-bold text-sm text-left leading-tight",children:t.name})]})]})},t._id)})})}),K?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("p",{className:"text-muted-foreground",children:"Loading shows..."})}):P.length===0?e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("p",{className:"text-muted-foreground",children:"No live shows in this category"})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5 ga
1p-2 lg:gap-4","data-testid":"live-shows-grid",children:P.map(t=>e.jsx(Z,{show:t,currentUserId:n||"",variant:"grid",categoryName:s==null?void 0:s.name},t._id))}),e.jsx("div",{ref:F,className:"h-20 flex items-center justify-center mt-4",children:h&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading more shows..."})})]})]})})})}):e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Category not found"}),e.jsx(w,{href:"/browse",children:e.jsx(M,{children:"Back to Browse"})})]})})}export{xe as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.