1import{r as t,j as e,m as _,R as v,n as x,u as R,b as C,P as S}from"../main.CysLZECp.js";import{g as I}from"./communityBlog.service-_4ZuI_m4.js";import{u as y,g as N}from"./useScroll-DRXDzxi7.js";import{C as B}from"./Comments-CtyH5qxt.js";const E=({blogItem:i,commentCollection:c})=>{const{scrollToElement:m}=y(),[u,a]=t.useState(c),{heading:f,sortDate:h,preamble:g,caseImageUrl:l,url:d,contentId:o}=i,n=()=>{N(o).then(r=>{a(r),m(`${o}-comments`)})},p=r=>({__html:r});return e.jsxs("article",{className:"blog-list__item position-relative",children:[e.jsx("h3",{className:"blog-list__item-title",children:e.jsx("a",{href:d,className:`blog-list__item-link ${!c&&"stretched-link"}`,children:f})}),e.jsxs("div",{className:"blog-list__date",children:[e.jsx("span",{className:"me-2",children:_(h)})," Blogginlägg"]}),e.jsxs(v,{children:[e.jsx(x,{md:l?8:12,children:g&&e.jsx("div",{className:"blog-list__item-text",id:`${o}-comments`,dangerouslySetInnerHTML:p(g)})}),l&&e.jsx(x,{children:e.jsx("img",{src:l,alt:""})})]}),e.jsx(B,{contentId:o,...u||{comments:[],totalCount:0},onPostAdded:()=>n(),onPostDeleted:()=>n()})]})},k=({contentId:i})=>{const{getQueryParam:c}=R(),[m,u]=t.useState(!1),[a,f]=t.useState(c("page")?parseInt(c("page")):1),[h,g]=t.useState(),l=t.useRef(null),d=t.useRef(!1),o=t.useRef(!1),{items:n,pageSize:p,totalItems:r}=h??{items:[],pageSize:1,totalItems:1},j=t.useMemo(()=>Math.ceil(r/p),[r]),b=()=>{u(!0),I(a,i).then(s=>{g(s),u(!1)})};return t.useEffect(()=>{i&&b()},[a,i]),t.useEffect(()=>{if(!d.current){d.current=!0;return}o.current=!0},[a]),t.useEffect(()=>{if(m||!o.current)return;const s=l.current;s&&requestAnimationFrame(()=>{const P=s.getBoundingClientRect().top+window.scrollY;window.scrollTo({top:Math.max(P-80,0),behavior:"smooth"}),o.current=!1})},[m,n]),e.jsxs("div",{className:"blog-list",id:"blogs",ref:l,children:[m?e.jsx("div",{className:"py-3 d-flex justify-content-center align-items-center",children:e.jsx(C,{animation:"border",role:"status",variant:"primary"})}):e.jsx(e.Fragment,{children:n==null?void 0:n.map(s=>e.jsx(E,{blogItem:s,commentCollection:s.comments},s.contentId))}),n.length>0&&e.jsx(S,{noOfPages:j,activePage:a||1,callback:s=>f(s)})]})};export{k as default}; 2//# sourceMappingURL=CommunityBlogListing-BFyZrrc6.js.map
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.