(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6134],{10830:function(e,t,o){(window.__NEXT_P=window.__NEXT_P||[]).push(["/news",function(){return o(96035)}])},96035:function(e,t,o){"use strict";o.r(t),o.d(t,{__N_SSP:function(){return y}});var n=o(85893),i=o(11163),a=o(41664),l=o.n(a),s=o(25675),r=o.n(s),c=o(69111),d=o(67294),h=o(65984),p=o(39484),x=o(38878),g=o(28008),m=o(95429),w=o(69084),u=o(76556),j=o(54410),b=o(24920),k=o(82922),f=o(27896);let S=(0,k.k)(()=>({logoContainer:{maxHeight:"32px",maxWidth:"32px",minHeight:"32px",minWidth:"32px",position:"relative",height:"32px",width:"32px"},logoImage:{flexShrink:0,flexGrow:1,padding:8}}));var y=!0;t.default=e=>{let{initialNews:t,error:o,categories:a}=e,{classes:s}=S(),[k,y]=(0,d.useState)(t),[_,v]=(0,d.useState)(!1),[C,N]=(0,d.useState)(new Date().getMonth()+1),[D,L]=(0,d.useState)(new Date().getFullYear()),[z,E]=(0,d.useState)(0),H=(0,h.rZ)(),P=(0,p.X)(),I=(0,i.useRouter)(),O=e=>{let t=new Date;return t.setMonth(e-1),t.toLocaleString("en-US",{month:"long"})},T=async(e,t,o)=>{v(!0);let n=!1,i=0;for(;!n&&i<12;){i++;let a=await fetch("/api/news/get-news-by-month?month=".concat(t,"&year=").concat(e));if(!a.ok)throw Error("HTTP error! status: ".concat(a.status));let l=await a.json();l.length>0?(y(l),N(t),L(e),n=!0):"prev"===o?--t<1&&(t=12,e--):++t>12&&(t=1,e++)}v(!1)},Z=1===C?12:C-1,X=1===C?D-1:D,F=12===C?1:C+1,M=12===C?D+1:D;return(0,n.jsxs)(x.Z,{style:{backgroundColor:"dark"===P.colorScheme?H.colors.dark[8]:H.colors.gray[1]},children:[o&&(0,n.jsxs)("p",{children:["Error: ",o]}),(0,n.jsxs)(g.D,{mb:32,children:[O(C)," ",D," News"]}),(0,n.jsx)(m.k,{direction:"column",align:"start",mb:16,children:(0,n.jsx)(w.P,{placeholder:"Select Category",onChange:e=>{e&&I.push("/news/category/".concat(e))},data:null==a?void 0:a.map(e=>({value:e.category_slug,label:e.category_name}))})}),(0,n.jsx)(m.k,{direction:"column",gap:12,align:"center",pb:16,children:_?(0,n.jsx)(u.a,{}):(0,n.jsxs)(n.Fragment,{children:[k.slice(0,12).map(e=>(0,n.jsx)(m.k,{direction:"column",w:"100%",gap:4,children:(0,n.jsx)(l(),{href:"/posts/".concat(e.slug),passHref:!0,style:{width:"100%",color:"inherit",textDecoration:"inherit"},children:(0,n.jsx)(x.Z,{radius:"md",p:6,style:{display:"block",boxShadow:"0px 0px 5px 0px rgba(0,0,0,0.25)",width:"100%"},children:(0,n.jsxs)(m.k,{align:"center",gap:"sm",children:[e.icon_image?(0,n.jsx)("div",{className:s.logoContainer,children:(0,n.jsx)(r(),{alt:e.title,height:32,src:e.icon_image,width:32})}):(0,n.jsx)("div",{className:s.logoContainer,children:(0,n.jsx)(r(),{alt:"bp logo",className:s.logoImage,height:32,width:32,src:"dark"===P.colorScheme?"/bpDarkLogo.png":"/bpLightLogo.png"})}),(0,n.jsx)(j.x,{fw:"bold",size:"sm",style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(0,c.decode)(e.title)}),(0,n.jsxs)(m.k,{direction:"column",gap:4,ml:"auto",mr:8,align:"end",children:[(0,n.jsx)(j.x,{size:"xs",style:{whiteSpace:"nowrap"},children:new Date(null==e?void 0:e.published_at).toLocaleDateString()}),(0,n.jsxs)(j.x,{size:"xs",style:{whiteSpace:"nowrap"},children:["Comments: ",e.commentsCount]})]})]})})})},e.id)),k.length>12&&(0,n.jsx)(f.default,{placementId:"657186fe4ecfa2596a09d57d",hybridBanner:!0},"ad-component"),k.slice(12).map(e=>(0,n.jsx)(m.k,{direction:"column",w:"100%",gap:4,children:(0,n.jsx)(l(),{href:"/posts/".concat(e.slug),passHref:!0,style:{width:"100%",color:"inherit",textDecoration:"inherit"},children:(0,n.jsx)(x.Z,{radius:"md",p:6,style:{display:"block",boxShadow:"0px 0px 5px 0px rgba(0,0,0,0.25)",width:"100%"},children:(0,n.jsxs)(m.k,{align:"center",gap:"sm",children:[e.icon_image?(0,n.jsx)("div",{className:s.logoContainer,children:(0,n.jsx)(r(),{alt:e.title,height:32,src:e.icon_image,width:32})}):(0,n.jsx)("div",{className:s.logoContainer,children:(0,n.jsx)(r(),{alt:"bp logo",className:s.logoImage,height:32,width:32,src:"dark"===P.colorScheme?"/bpDarkLogo.png":"/bpLightLogo.png"})}),(0,n.jsx)(j.x,{fw:"bold",size:"sm",style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(0,c.decode)(e.title)}),(0,n.jsxs)(m.k,{direction:"column",gap:4,ml:"auto",mr:8,align:"end",children:[(0,n.jsx)(j.x,{size:"xs",style:{whiteSpace:"nowrap"},children:new Date(null==e?void 0:e.published_at).toLocaleDateString()}),(0,n.jsxs)(j.x,{size:"xs",style:{whiteSpace:"nowrap"},children:["Comments: ",e.commentsCount]})]})]})})})},e.id))]})}),(0,n.jsxs)(m.k,{justify:"center",gap:16,children:[!_&&(0,n.jsxs)(b.z,{variant:"light",color:"gray",style:{boxShadow:"0px 0px 5px 0px rgba(0,0,0,0.25)",color:"dark"===P.colorScheme?"white":"black"},onClick:()=>{E(z-1),T(X,Z,"prev")},disabled:_,children:[O(Z)," News"]}),z<0&&!_&&(0,n.jsxs)(b.z,{variant:"light",color:"gray",style:{boxShadow:"0px 0px 5px 0px rgba(0,0,0,0.25)",color:"dark"===P.colorScheme?"white":"black"},onClick:()=>{E(z+1),T(M,F,"next")},disabled:_,children:[O(F)," News"]})]})]})}}},function(e){e.O(0,[9111,2888,9774,179],function(){return e(e.s=10830)}),_N_E=e.O()}]);