1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1922],{80651:function(e,t,s){(window.__NEXT_P=window.__NEXT_P||[]).push(["/blog/admin",function(){return s(12818)}])},43978:function(e,t,s){"use strict";s.d(t,{N:function(){return a},v:function(){return o}});let a=(e,t,s)=>{let a={value:t,expiry:new Date().getTime()+s};localStorage.setItem(e,JSON.stringify(a))},o=e=>{let t=localStorage.getItem(e);if(!t)return null;let s=JSON.parse(t);return new Date().getTime()>s.expiry?(localStorage.removeItem(e),null):s.value}},12818:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return m}});var a=s(85893),o=s(67294),n=s(34021),i=s.n(n),r=s(43978),l=s(77103),c=s(164),d=s(76159),p=s(84700);function m(){let[e,t]=(0,o.useState)(null),[s,n]=(0,o.useState)(null),[m,g]=(0,o.useState)(!1),[u,h]=(0,o.useState)(null),[_,f]=(0,o.useState)(1);async function b(){if(!e||!s){alert("Prrencha os campos");return}try{let t=await fetch("".concat("https://cm-back-redesing.vercel.app","/posts/blog-login"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({user:e,password:s})});200==t.status&&((0,r.N)("userLoggedIn",!0,36e5),await x())}catch(e){console.error("Erro ao buscar post:",e)}}async function x(){try{let e=await fetch("".concat("https://cm-back-redesing.vercel.app","/posts/get-posts")),t=await e.json();h(t),g(!0)}catch(e){console.error("Erro ao buscar post:",e)}}(0,o.useEffect)(()=>{(0,r.v)("userLoggedIn")&&x()},[]),(0,o.useEffect)(()=>{if(!(null==u?void 0:u.length))return;let e=Math.max(1,Math.ceil(u.length/10));_>e&&f(e)},[u,_]);let v=async e=>{try{let t;let s=[],a=/<img[^>]+src="([^">]+)"/g;for(;t=a.exec(e.content);)s.push(t[1]);for(let t of(e.poster&&s.push(e.poster),s))try{await fetch("https://files.chavemestra.net/blog-files/delete.php",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:t})})}catch(e){console.error("Erro ao deletar imagem:",t)}(await fetch("".concat("https://cm-back-redesing.vercel.app","/posts/delete-post"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({postId:e.postId})})).ok?(alert("Post deletado com sucesso!"),x()):alert("Erro ao deletar o post.")}catch(e){console.error("Erro geral ao deletar post:",e)}};function j(e,t){if(t){window.open("/blog/admin/edit-post/".concat(e.postId),"_blank");return}window.open((0,p.$n)(e),"_blank")}let y=(0,o.useMemo)(()=>(null==u?void 0:u.length)?Math.ceil(u.length/10):0,[u]),w=(_-1)*10,N=(0,o.useMemo)(()=>(null==u?void 0:u.length)?u.slice(w,w+10):[],[u,w]);return(0,a.jsx)("div",{className:i().wrapper,children:m?(0,a.jsxs)("div",{className:i().postList,children:[(0,a.jsx)("button",{onClick:function(){window.open("/blog/admin/create-post","_blank")},className:i().createPost,children:"Criar Postagem"}),(0,a.jsx)("div",{className:i().wrapperPosts,children:N.map(e=>{let{score:t,details:s}=function(e){var t,s;let a={title:{score:0,message:"",isGood:!1},description:{score:0,message:"",isGood:!1},tags:{score:0,message:"",isGood:!1},image:{score:0,message:"",isGood:!1}},o=(null===(t=e.title)||void 0===t?void 0:t.length)||0;o>=40&&o<=60?(a.title.score=30,a.title.message="T\xedtulo: Comprimento ideal (40-60 caracteres)",a.title.isGood=!0):o>0?(a.title.score=15,a.title.message="T\xedtulo: Comprimento n\xe3o ideal (".concat(o," caracteres, ideal: 40-60)")):a.title.message="T\xedtulo: Ausente";let n=(0,d.generateSeoDescription)(e.content).length;n>=120&&n<=160?(a.description.score=30,a.description.message="Descri\xe7\xe3o: Comprimento ideal (120-160 caracteres)",a.description.isGood=!0):n>0?(a.description.score=15,a.description.message="Descri\xe7\xe3o: Comprimento n\xe3o ideal (".concat(n," caracteres, ideal: 120-160)")):a.description.message="Descri\xe7\xe3o: Ausente";let i=(null===(s=e.tags)||void 0===s?void 0:s.length)||0;return i>=2&&i<=5?(a.tags.score=20,a.tags.message="Tags: Quantidade ideal (2-5 tags)",a.tags.isGood=!0):i>0?(a.tags.score=10,a.tags.message="Tags: Quantidade n\xe3o ideal (".concat(i," tags, ideal: 2-5)")):a.tags.message="Tags: Ausentes",e.poster?(a.image.score=20,a.image.message="Imagem: Banner presente",a.image.isGood=!0):a.image.message="Imagem: Banner ausente",{score:Math.min(a.title.score+a.description.score+a.tags.score
1+a.image.score,100),details:a}}(e);return(0,a.jsxs)("div",{className:i().post,children:[(0,a.jsxs)("div",{className:i().body,children:[(0,a.jsx)("span",{children:e.title}),"|",(0,a.jsx)("span",{children:function(e){var t;let s=(0,p.r_)(e);return(null===(t=p.o$.find(e=>e.value===s))||void 0===t?void 0:t.label)||"Gamificacao"}(e.blogType)}),"|",(0,a.jsxs)("span",{className:i().spanCalendar,children:[(0,a.jsx)(c.f,{color:"black"}),(0,l.Tu)(e.createdAt)]})]}),(0,a.jsxs)("div",{className:i().body,children:[(0,a.jsx)("div",{className:i().seoScore,children:(0,a.jsxs)("span",{style:{color:t>=75?"#00cc00":t>=50?"#ffaa00":"#ff3333",fontWeight:"bold",position:"relative"},children:["SEO: ",t,"/100",(0,a.jsx)("div",{className:i().tooltip,children:(0,a.jsxs)("ul",{children:[(0,a.jsx)("li",{style:{color:s.title.isGood?"#00cc00":"#ff3333"},children:s.title.message}),(0,a.jsx)("li",{style:{color:s.description.isGood?"#00cc00":"#ff3333"},children:s.description.message}),(0,a.jsx)("li",{style:{color:s.tags.isGood?"#00cc00":"#ff3333"},children:s.tags.message}),(0,a.jsx)("li",{style:{color:s.image.isGood?"#00cc00":"#ff3333"},children:s.image.message})]})})]})}),(0,a.jsx)("button",{onClick:()=>j(e,!1),className:i().btn,children:"Visualizar post"}),"|",(0,a.jsx)("button",{className:"".concat(i().btn," ").concat(i().edt),onClick:()=>j(e,!0),children:"Editar post"}),"|",(0,a.jsx)("button",{className:"".concat(i().btn," ").concat(i().delete),onClick:()=>v(e),children:"Deletar"})]})]},e.postId)})}),y>1&&(0,a.jsxs)("div",{className:i().pagination,children:[(0,a.jsx)("button",{onClick:()=>{_>1&&f(e=>e-1)},disabled:1===_,children:"Voltar"}),(0,a.jsxs)("span",{className:i().paginationMeta,children:["Pagina ",_," / ",y," -"," ",w+1,"-",Math.min(w+10,u.length)," ","de ",u.length]}),(0,a.jsx)("button",{onClick:()=>{_<y&&f(e=>e+1)},disabled:_===y,children:"Avancar"})]})]}):(0,a.jsxs)("div",{className:i().login,children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("input",{placeholder:"usuario",onChange:e=>t(e.target.value)}),(0,a.jsx)("input",{placeholder:"senha",type:"password",onChange:e=>n(e.target.value)})]}),(0,a.jsx)("button",{className:i().enterBtn,onClick:b,children:"Entrar"})]})})}},34021:function(e){e.exports={wrapper:"admin_wrapper__wRmFb",seoScore:"admin_seoScore__nCfXF",tooltip:"admin_tooltip__BFHDc",login:"admin_login__gZ5x6",enterBtn:"admin_enterBtn__35Xcx",postList:"admin_postList__vCMXi",createPost:"admin_createPost__sAyjY",wrapperPosts:"admin_wrapperPosts__dMUU_",post:"admin_post__HPXyW",body:"admin_body__Pd_au",spanCalendar:"admin_spanCalendar__U6YLw",btn:"admin_btn__EzQGm",edt:"admin_edt__BQ3XV",delete:"admin_delete__TfFT4",pagination:"admin_pagination__dWhyi",paginationMeta:"admin_paginationMeta__9h_WT"}}},function(e){e.O(0,[2678,4885,8133,195,2888,9774,179],function(){return e(e.s=80651)}),_N_E=e.O()}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.