(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3459],{6429:function(e,a,s){(window.__NEXT_P=window.__NEXT_P||[]).push(["/login",function(){return s(6019)}])},9504:function(e,a,s){"use strict";s.d(a,{Z:function(){return u}});var t=s(5893),n=s(7294),o=s(1163),i=s(1226),r=s(1664),c=s.n(r);s(1206);var l=()=>{let[e,a]=(0,n.useState)([]),[s,o]=(0,n.useState)(!0),[i,r]=(0,n.useState)(0);return(0,n.useEffect)(()=>{let e=async()=>{try{let e=await fetch("".concat("https://b1-pt-br.buobe.com/","top5?key=").concat("g04xfHEuu5OF8wQiGRoQWJdZKGXacU0rx0qwYQWgG"));if(e.ok){let s=await e.json();a(s),o(!1)}else throw Error("Erro ao buscar top 5 posts")}catch(a){o(!1),r(i+1),setTimeout(e,Math.min(3e4,1e3*Math.pow(2,i)))}};e()},[i]),(0,t.jsx)("div",{className:"top5-container",children:s?(0,t.jsx)("div",{className:"loading",children:(0,t.jsx)("img",{src:"/loader.gif"})}):(0,t.jsxs)(t.Fragment,{children:[e&&e.length>0&&(0,t.jsx)("h3",{children:"TOP 10"}),(0,t.jsx)("ul",{className:"top5-list",children:Array.isArray(e)&&e.map(e=>(0,t.jsxs)("li",{className:"top5-listItem",children:[(0,t.jsxs)("h2",{className:"top5-title",children:[(0,t.jsx)("img",{src:"/idea.svg",className:"top5-image"}),(0,t.jsx)(c(),{href:"https://www.buobe.com/".concat(e.slug),children:e.title})]}),(0,t.jsx)(c(),{href:"https://www.buobe.com/topic/".concat(e.topico_id),children:(0,t.jsx)("small",{children:e.topico_nome})})," ","\xb7"," ",(0,t.jsx)(c(),{href:"https://www.buobe.com/subtopic/".concat(e.subtopico_id),children:(0,t.jsx)("small",{children:e.subtopico_nome})})]},e._id))})]})})};s(608);var u=function(){let e=(0,o.useRouter)();return(0,t.jsxs)("div",{className:"sidebar-menu-right mobile-hide",children:[(0,t.jsx)("div",{className:"search-container",children:(0,t.jsx)(i.Z,{defaultValue:e.query.q||""})}),(0,t.jsx)(l,{})]})}},6019:function(e,a,s){"use strict";s.r(a),s.d(a,{default:function(){return f}});var t=s(5893),n=s(7294),o=s(1955),i=s(1163),r=s(2594),c=s(9504),l=s(6333),u=s(7066),m=s(1664),d=s.n(m),h=s(9008),p=s.n(h);function x(){let[e,a]=(0,n.useState)(""),[s,r]=(0,n.useState)(""),[c,l]=(0,n.useState)(""),[m,h]=(0,n.useState)(!1),[x,b]=(0,n.useState)(!1),[f,j]=(0,n.useState)(""),[g,v]=(0,n.useState)(!1),w=(0,i.useRouter)(),N=async a=>{a.preventDefault(),h(!0);try{let{token:a}=(await u.Z.post("".concat("https://api-b3.buobe.com/","login"),{email:e,senha:s})).data;o.Z.set("token",a),w.push("/")}catch(e){var t,n,i;(null===(t=e.response)||void 0===t?void 0:t.status)===403?(b(!0),l("")):(l((null===(i=e.response)||void 0===i?void 0:null===(n=i.data)||void 0===n?void 0:n.message)||"Ocorreu um erro ao fazer login."),b(!1))}finally{h(!1)}},y=async()=>{v(!0);try{await u.Z.post("".concat("https://api-b3.buobe.com/","resend-activation-email"),{email:e}),b(!1),l(""),j("Acaba de ser enviado um e-mail de ativa\xe7\xe3o para sua caixa de entrada ".concat(e))}catch(e){l("Erro ao reenviar o e-mail de ativa\xe7\xe3o. Por favor, tente novamente mais tarde.")}finally{v(!1)}};return(0,t.jsxs)("div",{className:"content login-container",children:[(0,t.jsxs)(p(),{children:[(0,t.jsx)("link",{rel:"icon",href:"/buobe-icon.jpg",type:"image/x-icon"}),(0,t.jsx)("link",{rel:"shortcut icon",href:"/buobe-icon.jpg",type:"image/x-icon"}),(0,t.jsx)("title",{children:"Login na Buobe!"}),(0,t.jsx)("meta",{name:"description",content:"Acesse sua conta na Buobe para acompanhar os assuntos do seu interesse."})]}),(0,t.jsxs)("div",{className:"result_msg",children:[(0,t.jsx)("img",{className:"robot-image",src:"/buo.svg",alt:"Rob\xf4"}),(0,t.jsxs)("div",{className:"message-container",children:[(0,t.jsx)("h3",{children:"Login"}),(0,t.jsx)("p",{children:"Acesse sua conta para acompanhar os assuntos do seu interesse."})]})]}),x&&(0,t.jsx)(t.Fragment,{children:(0,t.jsxs)("p",{className:"error-message",children:["Por favor, ative sua conta atrav\xe9s do e-mail de ativa\xe7\xe3o de conta que foi enviado para sua caixa de entrada no momento da cria\xe7\xe3o da sua conta. Caso n\xe3o consiga encontrar o e-mail de ativa\xe7\xe3o, solicite novamente:",(0,t.jsx)("button",{className:"resend-button",onClick:y,disabled:g,children:g?"Enviando...":"Reenviar e-mail de ativa\xe7\xe3o"})]})}),c&&!x&&(0,t.jsx)("p",{className:"error-message",children:c})," ",f&&!x&&(0,t.jsx)("p",{className:"success-message",children:f})," ",(0,t.jsxs)("form",{className:"login-form",onSubmit:N,children:[(0,t.jsxs)("div",{className:"form-group",children:[(0,t.jsx)("label",{htmlFor:"email",children:"E-mail:"}),(0,t.jsx)("input",{type:"email",id:"email",className:"form-input",value:e,onChange:e=>a(e.target.value)})]}),(0,t.jsxs)("div",{className:"form-group",children:[(0,t.jsx)("label",{htmlFor:"password",children:"Senha:"}),(0,t.jsx)("input",{type:"password",id:"password",className:"form-input",value:s,onChange:e=>r(e.target.value)})]}),(0,t.jsxs)("button",{type:"submit",className:"submit-button",disabled:m,children:[m?"Carregando...":"Entrar"," "]}),(0,t.jsxs)("div",{className:"link-container",children:[(0,t.jsx)("p",{children:(0,t.jsx)(d(),{href:"/cadastrar",children:"N\xe3o tenho conta"})}),(0,t.jsx)("p",{children:(0,t.jsx)(d(),{href:"/recuperar-senha",children:"Esqueci minha senha"})})]})]})]})}s(8205);var b=s(3980);s(4298),s(1206),s(5110);var f=()=>{let[e,a]=(0,n.useState)(null),[s,u]=(0,n.useState)({userID:"",imagemPerfil:"",nome:"",sobrenome:""}),[m,d]=(0,n.useState)(!1),h=(0,i.useRouter)(),[p,f]=(0,n.useState)(0);(0,n.useEffect)(()=>{let e=o.Z.get("token");if(e){o.Z.remove("token"),h.push("/");return}let a=async()=>{try{let a=await fetch("".concat("https://api-b3.buobe.com/","perfil/").concat(e),{method:"GET",headers:{"Content-Type":"application/json"},credentials:"include"});if(a.ok){let e=await a.json();u({userID:e._id,imagemPerfil:e.imagem_perfil_url,nome:e.nome,sobrenome:e.sobrenome}),h.push("/")}}catch(e){console.error("Erro:",e),f(p+1),setTimeout(a,Math.min(3e4,1e3*Math.pow(2,p)))}};a()},[h,p]);let j=async()=>{try{let e=await fetch("".concat("https://b1-pt-br.buobe.com/","web?key=").concat("g04xfHEuu5OF8wQiGRoQWJdZKGXacU0rx0qwYQWgG"));if(e.ok){let s=await e.json();s.length>0&&a(s[0].data_hora)}}catch(e){}};return(0,n.useEffect)(()=>{j()},[]),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(b.c,{}),(0,t.jsx)(l.Z,{updateLastNewsDate:j,imagemPerfil:s.imagemPerfil,nome:s.nome,sobrenome:s.sobrenome}),(0,t.jsx)(r.Z,{updateLastNewsDate:j,user:s,imagemPerfil:s.imagemPerfil,nome:s.nome,sobrenome:s.sobrenome}),(0,t.jsx)(c.Z,{}),(0,t.jsx)(x,{lastNewsDate:e,user:s})]})}},8205:function(){},9008:function(e,a,s){e.exports=s(7219)}},function(e){e.O(0,[1664,4198,7066,3855,2888,9774,179],function(){return e(e.s=6429)}),_N_E=e.O()}]);