(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2676],{23352:function(e,t,o){(window.__NEXT_P=window.__NEXT_P||[]).push(["/news/category/[slug]",function(){return o(77770)}])},77770:function(e,t,o){"use strict";o.r(t),o.d(t,{__N_SSP:function(){return y}});var r=o(85893),n=o(11163),a=o(67294),i=o(63991),s=o(9008),l=o.n(s),c=o(65984),h=o(39484),g=o(38878),d=o(24920),x=o(28008),p=o(95429),u=o(76556),w=o(54410),m=o(80929),b=o(41664),f=o.n(b),j=o(69111);let k=(0,o(82922).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,categoryName:s}=e,{classes:b}=k(),[y,S]=(0,a.useState)(t),_=(0,c.rZ)(),v=(0,h.X)(),[N,E]=(0,a.useState)(new Date().getMonth()+1),[C,D]=(0,a.useState)(new Date().getFullYear()),[z,F]=(0,a.useState)(!1),[M,H]=(0,a.useState)(0),{slug:I}=(0,n.useRouter)().query,L=e=>{let t=new Date;return t.setMonth(e-1),t.toLocaleString("en-US",{month:"long"})},P=async(e,t,o)=>{F(!0);let r=!1,n=0;for(;!r&&n<12;){n++;try{let n=await fetch("/api/news/get-news-by-month?month=".concat(t,"&year=").concat(e));if(!n.ok)throw Error("HTTP error! status: ".concat(n.status));let a=await n.json(),i=I?a.filter(e=>e.post_categories_category.some(e=>e.post_categories.category_slug===I)):a;i.length>0?(S(i),E(t),D(e),r=!0):"prev"===o?--t<1&&(t=12,e--):++t>12&&(t=1,e++)}catch(e){console.log(e);break}}F(!1)},T=1===N?12:N-1,Z=1===N?C-1:C,O=12===N?1:N+1,X=12===N?C+1:C;return(0,a.useEffect)(()=>{if(0===t.length){let e=new Date;e.setMonth(e.getMonth()-1),P(e.getFullYear(),e.getMonth()+1,"prev")}},[]),(0,a.useEffect)(()=>{let e=async()=>{F(!0),S([]),await P(new Date().getFullYear(),new Date().getMonth()+1,"prev"),F(!1)};I&&e()},[I]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l(),{children:(0,r.jsxs)("title",{children:[s," Category News | Breaking Point"]})}),(0,r.jsxs)(g.Z,{style:{backgroundColor:"dark"===v.colorScheme?_.colors.dark[8]:_.colors.gray[1]},children:[o&&(0,r.jsxs)("p",{children:["Error: ",o]}),(0,r.jsx)(f(),{href:"/news",style:{color:"dark"===v.colorScheme?"white":"black",textDecoration:"inherit",width:"100%"},children:(0,r.jsxs)(d.z,{w:"100%",variant:"light",color:"gray",style:{boxShadow:"0px 0px 5px 0px rgba(0,0,0,0.25)",color:"dark"===v.colorScheme?"white":"black"},children:[(0,r.jsx)(i.D6v,{})," News"]})}),(0,r.jsxs)(x.D,{mb:32,children:["News in Category: ",s]}),(0,r.jsx)(p.k,{direction:"column",gap:12,align:"center",pb:16,children:z?(0,r.jsx)(u.a,{}):(0,r.jsx)(r.Fragment,{children:0===y.length?(0,r.jsx)(w.x,{children:"No news available in this category."}):(0,r.jsx)(r.Fragment,{children:y.map(e=>(0,r.jsx)(p.k,{direction:"column",w:"100%",gap:4,children:(0,r.jsx)(f(),{href:"/posts/".concat(e.slug),passHref:!0,style:{width:"100%",color:"inherit",textDecoration:"inherit"},children:(0,r.jsx)(g.Z,{radius:"md",p:6,style:{display:"block",boxShadow:"0px 0px 5px 0px rgba(0,0,0,0.25)",width:"100%",transition:"background-color 0.2s","&:hover":{backgroundColor:"rgba(0,0,0,0.1)"}},children:(0,r.jsxs)(p.k,{align:"center",gap:"sm",children:[e.icon_image?(0,r.jsx)("div",{className:b.logoContainer,children:(0,r.jsx)(m.E,{alt:e.title,height:32,src:e.icon_image,width:32})}):(0,r.jsx)("div",{className:b.logoContainer,children:(0,r.jsx)(m.E,{alt:"bp logo",className:b.logoImage,height:32,width:32,src:"dark"===v.colorScheme?"/bpDarkLogo.png":"/bpLightLogo.png"})}),(0,r.jsx)(w.x,{fw:"bold",size:"sm",style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(0,j.decode)(e.title)}),(0,r.jsxs)(p.k,{direction:"column",gap:4,ml:"auto",mr:8,align:"end",children:[(0,r.jsx)(w.x,{size:"xs",style:{whiteSpace:"nowrap"},children:new Date(null==e?void 0:e.published_at).toLocaleDateString()}),(0,r.jsxs)(w.x,{size:"xs",style:{whiteSpace:"nowrap"},children:["Comments: ",e.commentsCount]})]})]})})})},e.id))})})}),(0,r.jsxs)(p.k,{justify:"center",gap:16,children:[!z&&(0,r.jsxs)(d.z,{variant:"light",color:"gray",style:{boxShadow:"0px 0px 5px 0px rgba(0,0,0,0.25)",color:"dark"===v.colorScheme?"white":"black"},onClick:()=>{H(M-1),P(Z,T,"prev")},disabled:z,children:[L(T)," News"]}),M<0&&!z&&(0,r.jsxs)(d.z,{variant:"light",color:"gray",style:{boxShadow:"0px 0px 5px 0px rgba(0,0,0,0.25)",color:"dark"===v.colorScheme?"white":"black"},onClick:()=>{H(M+1),P(X,O,"next")},disabled:z,children:[L(O)," News"]})]})]})]})}},9008:function(e,t,o){e.exports=o(37219)},80929:function(e,t,o){"use strict";o.d(t,{E:function(){return p}});var r=o(85893),n=o(67294),a=o(69429),i=o(13637),s=o(90987),l=o(46976),c=o(58278),h=o(43362),g={root:"m_9e117634"};let d={},x=(0,i.Z)((e,{radius:t,fit:o})=>({root:{"--image-radius":void 0===t?void 0:(0,a.H5)(t),"--image-object-fit":o}})),p=(0,h.b)((e,t)=>{let o=(0,s.w)("Image",d,e),{classNames:a,className:i,style:h,styles:p,unstyled:u,vars:w,onError:m,src:b,radius:f,fit:j,fallbackSrc:k,mod:y,...S}=o,[_,v]=(0,n.useState)(!b);(0,n.useEffect)(()=>v(!b),[b]);let N=(0,l.y)({name:"Image",classes:g,props:o,className:i,style:h,classNames:a,styles:p,unstyled:u,vars:w,varsResolver:x});return _&&k?(0,r.jsx)(c.x,{component:"img",ref:t,src:k,...N("root"),onError:m,mod:["fallback",y],...S}):(0,r.jsx)(c.x,{component:"img",ref:t,...N("root"),src:b,onError:e=>{m?.(e),v(!0)},mod:y,...S})});p.classes=g,p.displayName="@mantine/core/Image"}},function(e){e.O(0,[9111,2888,9774,179],function(){return e(e.s=23352)}),_N_E=e.O()}]);