(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1538],{62924:function(e,t,o){(window.__NEXT_P=window.__NEXT_P||[]).push(["/news/tag/[slug]",function(){return o(76440)}])},76440:function(e,t,o){"use strict";o.r(t),o.d(t,{__N_SSP:function(){return S}});var r=o(85893),n=o(11163),a=o(67294),s=o(63991),i=o(9008),l=o.n(i),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 S=!0;t.default=e=>{let{initialNews:t,error:o,tagName:i}=e,{classes:b}=k(),[S,y]=(0,a.useState)(t),_=(0,c.rZ)(),v=(0,h.X)(),[N,E]=(0,a.useState)(new Date().getMonth()+1),[D,C]=(0,a.useState)(new Date().getFullYear()),[z,F]=(0,a.useState)(!1),[M,T]=(0,a.useState)(0),{slug:H}=(0,n.useRouter)().query,I=e=>{let t=new Date;return t.setMonth(e-1),t.toLocaleString("en-US",{month:"long"})},L=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(),s=H?a.filter(e=>e.post_tags_tag.some(e=>e.post_tags.tag_slug===H)):a;s.length>0?(y(s),E(t),C(e),r=!0):"prev"===o?--t<1&&(t=12,e--):++t>12&&(t=1,e++)}catch(e){console.log(e);break}}F(!1)},P=1===N?12:N-1,Z=1===N?D-1:D,O=12===N?1:N+1,X=12===N?D+1:D;return(0,a.useEffect)(()=>{if(0===t.length){let e=new Date;e.setMonth(e.getMonth()-1),L(e.getFullYear(),e.getMonth()+1,"prev")}},[]),(0,a.useEffect)(()=>{let e=async()=>{F(!0),y([]),await L(new Date().getFullYear(),new Date().getMonth()+1,"prev"),F(!1)};H&&e()},[H]),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l(),{children:(0,r.jsxs)("title",{children:[i," Tag 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)(s.D6v,{})," News"]})}),(0,r.jsxs)(x.D,{mb:32,children:["News with Tag: ",i]}),(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===S.length?(0,r.jsx)(w.x,{children:"No news available in this tag."}):(0,r.jsx)(r.Fragment,{children:S.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%"},sx:{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:()=>{T(M-1),L(Z,P,"prev")},disabled:z,children:[I(P)," 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:()=>{T(M+1),L(X,O,"next")},disabled:z,children:[I(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),s=o(13637),i=o(90987),l=o(46976),c=o(58278),h=o(43362),g={root:"m_9e117634"};let d={},x=(0,s.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,i.w)("Image",d,e),{classNames:a,className:s,style:h,styles:p,unstyled:u,vars:w,onError:m,src:b,radius:f,fit:j,fallbackSrc:k,mod:S,...y}=o,[_,v]=(0,n.useState)(!b);(0,n.useEffect)(()=>v(!b),[b]);let N=(0,l.y)({name:"Image",classes:g,props:o,className:s,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",S],...y}):(0,r.jsx)(c.x,{component:"img",ref:t,...N("root"),src:b,onError:e=>{m?.(e),v(!0)},mod:S,...y})});p.classes=g,p.displayName="@mantine/core/Image"}},function(e){e.O(0,[9111,2888,9774,179],function(){return e(e.s=62924)}),_N_E=e.O()}]);