1import{r as f,j as e}from"./vendor-react-CSSqAeAu.js";import{u as $}from"./vendor-query-DiXUylMp.js";import{c as C,u as M,e as P,j as T,N as E,n as L,I as q,B as p,p as m,an as I,cg as K,al as A,ag as g,t as b,L as B,z as y,aa as H,ab as z}from"./index-BGBqiLLz.js";import{P as F}from"./plus-C3HWGH5A.js";import{C as D}from"./circle-help-DW25ivqZ.js";import{E as _}from"./eye-CVaekH5o.js";import{T as Q}from"./thumbs-up-ZvvqEq45.js";import"./vendor-charts-BKriOm_U.js";import"./vendor-motion-DNXF7DOe.js";/** 2 * @license lucide-react v0.453.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const R=C("MessagesSquare",[["path",{d:"M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z",key:"p1xzt8"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1",key:"1cx29u"}]]),U=[{id:"all",labelKey:"forum.categories.all",icon:R},{id:"repair-tips",labelKey:"forum.categories.repairTips",icon:I},{id:"success-stories",labelKey:"forum.categories.successStories",icon:K},{id:"questions",labelKey:"forum.categories.questions",icon:D},{id:"product-reviews",labelKey:"forum.categories.productReviews",icon:A},{id:"general",labelKey:"forum.categories.general",icon:g}];function ae(){const{t:r,language:n}=M(),[,x]=P(),[i,j]=f.useState("all"),[l,N]=f.useState(""),{data:d,isLoading:v}=$({queryKey:["/api/forum/posts",i,l],queryFn:async()=>{const a=new URLSearchParams;i!=="all"&&a.append("category",i),l&&a.append("search",l);const s=await fetch(`/api/forum/posts?${a}`);if(!s.ok)throw new Error("Failed to fetch posts");return s.json()}}),u=(d==null?void 0:d.posts)||[],k=a=>{const s={"repair-tips":"bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-400","success-stories":"bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400",questions:"bg-orange-100 dark:bg-orange-900/30 text-orange-700 dark:text-orange-400","product-reviews":"bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-400",general:"bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-400"};return s[a]||s.general},w=a=>{const s=new Date(a),t=new Date().getTime()-s.getTime(),c=Math.floor(t/6e4),h=Math.floor(t/36e5),S=Math.floor(t/864e5);return c<60?`${c}${r("forum.time.minsAgo")}`:h<24?`${h}${r("forum.time.hoursAgo")}`:`${S}${r("forum.time.daysAgo")}`};return e.jsxs("div",{className:"min-h-screen bg-white dark:bg-black text-gray-900 dark:text-gray-100 pb-20 md:pb-0",children:[e.jsxs(T,{children:[e.jsx("title",{children:r("forum.meta.title")}),e.jsx("meta",{name:"description",content:r("forum.meta.description")})]}),e.jsx(E,{}),e.jsxs("div",{className:"container mx-auto px-4 py-8 max-w-6xl",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h1",{className:"text-3xl font-bold mb-3 text-gray-900 dark:text-gray-100","data-testid":"text-forum-title",children:r("forum.title")}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-6",children:r("forum.subtitle")}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(L,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-400"}),e.jsx(q,{type:"text",placeholder:r("forum.search.placeholder"),value:l,onChange:a=>N(a.target.value),className:"pl-10","data-testid":"input-forum-search"})]}),e.jsxs(p,{onClick:()=>x(m("/forum/new",n)),className:"bg-gray-900 dark:bg-gray-100 text-white dark:text-black hover:bg-gray-800 dark:hover:bg-gray-200","data-testid":"button-create-post",children:[e.jsx(F,{className:"w-4 h-4 mr-2"}),r("forum.button.createPost")]})]})]}),e.jsx("div",{className:"flex gap-2 mb-6 overflow-x-auto pb-2",children:U.map(a=>{const s=a.icon,o=i===a.id;return e.jsxs("button",{onClick:()=>j(a.id),className:`flex items-center gap-2 px-4 py-2 rounded-lg border transition-colors whitespace-nowrap ${o?"bg-gray-900 dark:bg-gray-100 text-white dark:text-black border-gray-900 dark:border-gray-100":"bg-white dark:bg-black text-gray-700 dark:text-gray-300 border-gray-300 dark:border-gray-700 hover:border-gray-900 dark:hover:border-gray-100"}`,"data-testid":`button-category-${a.id}`,children:[e.jsx(s,{className:"w-4 h-4"}),e.jsx("span",{className:"text-sm font-medium",children:r(a.labelKey)})]},a.id)})}),e.jsx("div",{className:"space-y-4",children:v?e.jsx("div",{className:"text-center py-12",children:e.jsx("p",{className:"text-gray-500 dark:text-gray-500",children:r("forum.loading")})}):u.length===0?e.jsxs(b,{className:"p-8 text-center",children:[e.jsx(g,{className:"w-12 h-12 mx-auto mb-3 text-gray-400"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:r(l||i!=="all"?"forum.noPosts.filtered":"forum.noPosts.empty")}),e.jsx(p,{onClick:()=>x(m("/forum/new",n)),variant:"outline","data-testid":"button-create-first-post",children:r("forum.button.createFirstPost")})]}):u.map(a=>{var t,c;const s=a.Images&&a.Images.length>0?((c=(t=a.Images[0].thumbnails)==null?void 0:t.large)==null?void 0:c.url)||a.Images[0].url:null,o=n==="de"?a.Slug_DE||a.Slug_EN||a.id:a.Slug_EN||a.Slug_DE||a.id;return e.jsx(B,{href:m(`/forum/posts/${o}`,n),children:e.jsxs(b,{className:"p-5 hover:shadow-lg transition-shadow cursor-pointer border-gray-200 dark:border-gray-800","data-testid":`card-post-${a.id}`,children:[e.jsxs("div",{className:"flex gap-4",children:[s&&e.jsx("div",{className:"flex-shrink-0",children:e.jsx("img",{src:s,alt:a.title,className:"w-24 h-24 object-cover rounded-lg",loading:"lazy"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(y,{className:k(a.category),children:r(`forum.categories.${a.category.replace("-","")}`)}),a.deviceType&&e.jsx(y,{variant:"outline",className:"text-xs",children:a.deviceBrand?`${a.deviceBrand} ${a.deviceType}`:a.deviceType})]}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-2 hover:text-gray-700 dark:hover:text-gray-300",children:a.title}),e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400 line-clamp-2 mb-3",children:[a.content.substring(0,200),"..."]})]})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm text-gray-500 dark:text-gray-500",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-300",children:a.authorName}),e.jsx("span",{children:w(a.createdAt)})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(_,{className:"w-4 h-4"}),e.jsx("span",{children:a.viewCount})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(g,{className:"w-4 h-4"}),e.jsx("span",{children:a.commentCount})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Q,{className:"w-4 h-4"}),e.jsx("span",{children:a.isHelpful})]})]})]})]})},a.id)})})]}),e.jsx(H,{}),e.jsx(z,{})]})}
6export{ae as ForumPage};
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.