"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("react/jsx-runtime"),c=require("react"),d=require("react-redux"),r=require("semantic-ui-react"),x=require("react-intl"),j=p=>{const{"data-group":i}=p,h=d.useDispatch(),t=d.useSelector(e=>e.getIn(["data","postsPagination",i])),n=d.useSelector(e=>e.getIn(["data","posts",i])),l=t&&(t!=null&&t.totalPages)?t.totalPages:1,[o,g]=c.useState((n==null?void 0:n.page)??1),[P,f]=c.useState([]),m=()=>{const e=[];for(let s=1;s<=l;s++)e.push({key:s,text:s,value:s});f(e)},u=e=>{e!==o&&(e<1||e>l||(g(e),h({type:"SET_POSTS_FILTER",group:i,...n,page:e})))};return c.useEffect(()=>{m()},[t==null?void 0:t.totalPages]),c.useEffect(()=>{const e=(n==null?void 0:n.page)??1;e!==o&&g(e)},[n==null?void 0:n.page]),a.jsxs(r.Container,{fluid:!0,className:"posts-pagination",children:[a.jsxs("div",{className:"posts-pagination-dropdown",children:[a.jsx("span",{children:"Page"}),a.jsx(r.Dropdown,{options:P,placeholder:"Select Item",selection:!0,compact:!0,value:o,onChange:(e,s)=>u(Number(s.value))}),a.jsx("div",{children:a.jsxs("span",{children:["of ",t&&(t==null?void 0:t.totalPages)]})})]}),a.jsxs("div",{children:[a.jsx(r.Icon,{size:"large",style:{cursor:"pointer"},onClick:()=>u(o-1),name:"angle left",disabled:o===1}),a.jsx(r.Icon,{size:"large",style:{cursor:"pointer"},onClick:()=>u(o+1),name:"angle right",disabled:o===l})]})]})},v=x.injectIntl(c.memo(j));exports.default=v;
