PageSourceSearch

https://tmjbrazil.com.br/assets/AdminCoverAudit-CLQXtAnv.js

js tmjbrazil.com.br collected 2026-10-04 08:02:10 UTC 13,399 bytes, 1 lines download raw bytes

1import{r as t,j as e}from"./react-DJiDbFd1.js";import{L as Y}from"./router-B1PQ6IJb.js";import{a as ke,b as Ee}from"./AdminLayout-LtSYF8Pv.js";import{B as c}from"./logo-transparent-CZDvx9Bt.js";import{C as E,a as q,b as M,d as P}from"./card-ds-IxSNr.js";import{I as Pe}from"./input-B_LyOOrv.js";import{L as U}from"./label-BVvAKgpt.js";import{S as ee,a as se,b as te,c as ae,d as g}from"./select-C1iN6NfO.js";import{j as oe,i as Ie,s as h,x as Ae}from"./index-CUcKvafI.js";import{U as re}from"./upload-DLJS9S3m.js";import{T as Le}from"./trash-2-BMHyXYQz.js";import{P as ie}from"./pencil-yg43rbU2.js";import{E as le}from"./external-link-CbLdxgUf.js";import"./sparkles-DIJgoCaP.js";import"./radix-CNUJXOwZ.js";import"./check-BpXzW8Jo.js";import"./query-Df3p_a-z.js";import"./supabase-CfLgG-5A.js";const ce=oe("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);const ne=oe("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),F=50,de="article-images",Qe=()=>{const{toast:n}=Ie(),[m,v]=t.useState(""),[V,D]=t.useState(""),[N,H]=t.useState("all"),[b,I]=t.useState("all"),[j,p]=t.useState(0),[d,A]=t.useState([]),[L,me]=t.useState(0),[_,K]=t.useState(!1),[xe,ue]=t.useState(null),[he,pe]=t.useState([]),[T,C]=t.useState(null),[B,ge]=t.useState({a:0,b:0,c:0}),G=t.useRef({}),O=t.useRef(null),[u,y]=t.useState(null),[z,R]=t.useState(null),[je,W]=t.useState(!1),o=t.useMemo(()=>u?d.findIndex(s=>s.id===u):-1,[d,u]),a=o>=0?d[o]:null;t.useEffect(()=>{(async()=>{const{data:s}=await h.from("categories").select("id,name").order("name");pe(s??[])})()},[]);const w=t.useCallback(async()=>{const{data:s,error:r}=await h.rpc("articles_cover_audit_stats");!r&&s&&s[0]&&ue(s[0])},[]),$=t.useCallback(async()=>{K(!0);try{const{data:s,error:r}=await h.rpc("articles_cover_audit_priority",{_search:m.trim()||null,_category_id:N==="all"?null:N,_priority:b==="all"?null:b,_limit:F,_offset:j*F});if(r)throw r;const l=s??[];A(l),me(Number(l[0]?.total_count??0)),l[0]&&ge({a:Number(l[0].total_a??0),b:Number(l[0].total_b??0),c:Number(l[0].total_c??0)})}catch(s){n({title:"Erro ao carregar",description:s.message,variant:"destructive"})}finally{K(!1)}},[m,N,b,j,n]);t.useEffect(()=>{$()},[$]),t.useEffect(()=>{w()},[w]);const Z=t.useMemo(()=>Math.max(1,Math.ceil(L/F)),[L]),J=()=>{p(0),v(V)},fe=()=>{D(""),v(""),H("all"),I("all"),p(0)},ve=async()=>{await Promise.all([$(),w()])};t.useEffect(()=>{if(!u){R(null);return}let s=!1;return R(null),W(!0),(async()=>{const{data:r}=await h.from("articles").select("excerpt,cover_image_url").eq("id",u).maybeSingle();s||(R(r?.excerpt??""),r?.cover_image_url!==void 0&&A(l=>l.map(x=>x.id===u?{...x,cover_image_url:r.cover_image_url??null}:x)),W(!1))})(),()=>{s=!0}},[u]);const Ne=()=>{o>0&&y(d[o-1].id)},be=()=>{o>=0&&o<d.length-1&&y(d[o+1].id)},_e=()=>{I("A"),p(0),y(null)},Ce=async s=>{if(confirm(`Remover capa da matéria "${s.title}"?`)){C(s.id);try{const{error:r}=await h.from("articles").update({cover_image_url:null}).eq("id",s.id);if(r)throw r;n({title:"Capa removida"}),await ve()}catch(r){n({title:"Erro",description:r.message,variant:"destructive"})}finally{C(null)}}},Q=async(s,r)=>{C(s.id);try{const l=await Ae(r),x=Date.now().toString(36),i=`audit/${s.slug||s.id}-${x}.webp`,{error:f}=await h.storage.from(de).upload(i,l,{cacheControl:"31536000",upsert:!1,contentType:"image/webp"});if(f)throw f;const{data:ye}=h.storage.from(de).getPublicUrl(i),{error:X}=await h.from("articles").update({cover_image_url:ye.publicUrl}).eq("id",s.id);if(X)throw X;n({title:"Capa atualizada",description:s.title}),A(we=>we.filter(Se=>Se.id!==s.id)),await w()}catch(l){n({title:"Erro no upload",description:l.message,variant:"destructive"})}finally{C(null)}};return e.jsxs(ke,{children:[e.jsx(Ee,{title:"Central de capas",description:"Fila editorial priorizada das TOP 398 matérias sem capa válida. A = 100 mais críticas, B = 100 seguintes, C = 198 restantes."}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 mb-6",children:[e.jsx("button",{type:"button",onClick:_e,className:"text-left",children:e.jsx(S,{label:"Prioridade A (clique)",value:B.a,accent:!0})}
1),e.jsx(S,{label:"Prioridade B",value:B.b}),e.jsx(S,{label:"Prioridade C",value:B.c}),e.jsx(S,{label:"Corrigidas hoje",value:xe?.corrected_today,accent:!0})]}),e.jsxs(E,{className:"mb-4",children:[e.jsx(q,{children:e.jsx(M,{className:"text-base",children:"Filtros"})}),e.jsxs(P,{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"md:col-span-2",children:[e.jsx(U,{className:"text-xs",children:"Buscar no título"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Pe,{placeholder:"ex: Madonna",value:V,onChange:s=>D(s.target.value),onKeyDown:s=>s.key==="Enter"&&J()}),e.jsx(c,{onClick:J,children:"Aplicar"}),e.jsx(c,{variant:"ghost",onClick:fe,children:"Limpar"})]})]}),e.jsxs("div",{children:[e.jsx(U,{className:"text-xs",children:"Prioridade"}),e.jsxs(ee,{value:b,onValueChange:s=>{p(0),I(s)},children:[e.jsx(se,{children:e.jsx(te,{})}),e.jsxs(ae,{children:[e.jsx(g,{value:"all",children:"Todas (A+B+C)"}),e.jsx(g,{value:"A",children:"A — Top 100"}),e.jsx(g,{value:"B",children:"B — Top 101–200"}),e.jsx(g,{value:"C",children:"C — Top 201–398"})]})]})]}),e.jsxs("div",{children:[e.jsx(U,{className:"text-xs",children:"Categoria"}),e.jsxs(ee,{value:N,onValueChange:s=>{p(0),H(s)},children:[e.jsx(se,{children:e.jsx(te,{})}),e.jsxs(ae,{children:[e.jsx(g,{value:"all",children:"Todas"}),he.map(s=>e.jsx(g,{value:s.id,children:s.name},s.id))]})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-[1fr_420px] gap-4",children:[e.jsxs(E,{children:[e.jsxs(q,{className:"flex flex-row items-center justify-between",children:[e.jsx(M,{className:"text-base",children:_?"Carregando…":`${L.toLocaleString("pt-BR")} matéria(s) sem capa`}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(c,{variant:"outline",size:"sm",disabled:j===0||_,onClick:()=>p(s=>Math.max(0,s-1)),children:e.jsx(ce,{className:"w-4 h-4"})}),e.jsxs("span",{className:"text-muted-foreground",children:[j+1," / ",Z]}),e.jsx(c,{variant:"outline",size:"sm",disabled:j+1>=Z||_,onClick:()=>p(s=>s+1),children:e.jsx(ne,{className:"w-4 h-4"})})]})]}),e.jsx(P,{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted/50 text-left",children:e.jsxs("tr",{children:[e.jsx("th",{className:"p-2 w-12",children:"#"}),e.jsx("th",{className:"p-2 w-16",children:"Prio"}),e.jsx("th",{className:"p-2 w-16",children:"Capa"}),e.jsx("th",{className:"p-2",children:"Título"}),e.jsx("th",{className:"p-2",children:"Categoria"}),e.jsx("th",{className:"p-2 text-right",children:"Views"}),e.jsx("th",{className:"p-2 text-right",children:"Impr."}),e.jsx("th",{className:"p-2 text-right",children:"Cliques"}),e.jsx("th",{className:"p-2 text-right",children:"Ações"})]})}),e.jsxs("tbody",{children:[!_&&d.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:9,className:"p-6 text-center text-muted-foreground",children:"Nenhuma matéria encontrada com esses filtros."})}),d.map(s=>{const r=(s.tags??[]).find(i=>!["terranoticias","r7","cb","tupi","uai"].includes(i)),l=s.priority==="A"?"bg-red-100 text-red-700 border-red-200":s.priority==="B"?"bg-amber-100 text-amber-700 border-amber-200":"bg-slate-100 text-slate-700 border-slate-200",x=i=>i==null||i===0?"—":Number(i).toLocaleString("pt-BR");return e.jsxs("tr",{className:`border-t align-top cursor-pointer hover:bg-muted/40 ${u===s.id?"bg-muted/60":""}`,onClick:()=>y(s.id),children:[e.jsx("td",{className:"p-2 text-xs text-muted-foreground",children:s.rank_position??"—"}),e.jsx("td",{className:"p-2",children:e.jsx("span",{className:`inline-block px-2 py-0.5 rounded border text-[11px] font-semibold ${l}`,children:s.priority??"—"})}),e.jsx("td",{className:"p-2",children:s.cover_image_url?e.jsx("img",{src:s.cover_image_url,alt:"",className:"w-12 h-12 rounded object-cover bg-muted",loading:"lazy"}):e.jsx("div",{className:"w-12 h-12 rounded bg-muted flex items-center justify-center text-[10px] text-muted-foreground",children:"sem capa"})}),e.jsxs("td",{className:"p-2",children:[e.jsx("div",{className:"font-medium text-foreground",children:s.title}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["/",s.slug]}),r&&e.jsxs("div",{className:"text-xs text-muted-foreground mt-0.5",children:["🎤 ",r]}),e.jsxs("div",{className:"text-[10px] text-muted-foreground mt-0.5",children:["Discover score: ",e.jsx("span",{className:"tabular-nums",children:s.priority_score!=null?Number(s.priority_score).toLocaleStr
1ing("pt-BR"):"—"})]})]}),e.jsxs("td",{className:"p-2 text-xs",children:[e.jsx("div",{children:s.category_name??"—"}),e.jsx("div",{className:"text-muted-foreground",children:s.author_name??"—"})]}),e.jsx("td",{className:"p-2 text-xs text-right tabular-nums",children:x(s.view_count)}),e.jsx("td",{className:"p-2 text-xs text-right tabular-nums",children:x(s.gsc_impressions_30d)}),e.jsx("td",{className:"p-2 text-xs text-right tabular-nums",children:x(s.gsc_clicks_30d)}),e.jsx("td",{className:"p-2",onClick:i=>i.stopPropagation(),children:e.jsxs("div",{className:"flex justify-end items-center gap-1",children:[e.jsx("input",{ref:i=>{G.current[s.id]=i},type:"file",accept:"image/*",className:"hidden",onChange:i=>{const f=i.target.files?.[0];f&&Q(s,f),i.target.value=""}}),e.jsx(c,{size:"sm",variant:"secondary",disabled:T===s.id,onClick:()=>G.current[s.id]?.click(),title:"Enviar capa",children:e.jsx(re,{className:"w-3.5 h-3.5"})}),s.cover_image_url&&e.jsx(c,{size:"sm",variant:"ghost",disabled:T===s.id,onClick:()=>Ce(s),title:"Remover capa atual",children:e.jsx(Le,{className:"w-3.5 h-3.5"})}),e.jsx(c,{size:"sm",variant:"ghost",asChild:!0,title:"Editar matéria",children:e.jsx(Y,{to:`/admin/articles/${s.id}/edit`,children:e.jsx(ie,{className:"w-3.5 h-3.5"})})}),e.jsx(c,{size:"sm",variant:"ghost",asChild:!0,title:"Ver no site",children:e.jsx("a",{href:`/article/${s.slug}`,target:"_blank",rel:"noreferrer",children:e.jsx(le,{className:"w-3.5 h-3.5"})})})]})})]},s.id)})]})]})})]}),e.jsxs(E,{className:"xl:sticky xl:top-4 self-start",children:[e.jsxs(q,{className:"flex flex-row items-center justify-between gap-2",children:[e.jsx(M,{className:"text-base",children:"Preview editorial"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(c,{size:"sm",variant:"outline",onClick:Ne,disabled:!a||o<=0,title:"Anterior",children:e.jsx(ce,{className:"w-4 h-4"})}),e.jsx("span",{className:"text-xs text-muted-foreground tabular-nums w-16 text-center",children:a?`${o+1} / ${d.length}`:"— / —"}),e.jsx(c,{size:"sm",variant:"outline",onClick:be,disabled:!a||o>=d.length-1,title:"Próximo",children:e.jsx(ne,{className:"w-4 h-4"})})]})]}),e.jsxs(P,{className:"space-y-3",children:[!a&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Selecione uma matéria na lista para revisar e enviar a capa."}),a&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"aspect-[16/9] w-full rounded bg-muted overflow-hidden flex items-center justify-center",children:a.cover_image_url?e.jsx("img",{src:a.cover_image_url,alt:a.title,className:"w-full h-full object-cover"}):e.jsx("span",{className:"text-xs text-muted-foreground",children:"Sem capa atual"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-xs text-muted-foreground",children:["#",a.rank_position??"—"," · Prioridade ",a.priority??"—"," · ",a.category_name??"—"]}),e.jsx("div",{className:"font-semibold leading-snug mt-1",children:a.title}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["/",a.slug]})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-2 text-center",children:[e.jsx(k,{label:"Views",value:a.view_count}),e.jsx(k,{label:"Impr.",value:a.gsc_impressions_30d}),e.jsx(k,{label:"Cliques",value:a.gsc_clicks_30d}),e.jsx(k,{label:"Score",value:a.priority_score})]}),e.jsx("div",{className:"rounded border bg-muted/30 p-2 text-xs text-muted-foreground max-h-40 overflow-auto",children:je?"Carregando resumo…":z&&z.trim().length>0?z:"Sem resumo cadastrado."}),e.jsxs("div",{className:"flex flex-wrap gap-2 pt-1",children:[e.jsx("input",{ref:O,type:"file",accept:"image/*",className:"hidden",onChange:s=>{const r=s.target.files?.[0];r&&a&&Q(a,r),s.target.value=""}}),e.jsxs(c,{size:"sm",disabled:T===a.id,onClick:()=>O.current?.click(),children:[e.jsx(re,{className:"w-4 h-4 mr-1"})," Upload capa"]}),e.jsx(c,{size:"sm",variant:"outline",asChild:!0,children:e.jsxs("a",{href:`/article/${a.slug}`,target:"_blank",rel:"noreferrer",children:[e.jsx(le,{className:"w-4 h-4 mr-1"})," Abrir matéria"]})}),e.jsx(c,{size:"sm",variant:"ghost",asChild:!0,children:e.jsxs(Y,{to:`/admin/articles/${a.id}/edit`,children:[e.jsx(ie,{className:"w-4 h-4 mr-1"})," Editar"]})})]})]})]})]})]})]})},S=({label:n,value:m,accent:v})=>e.jsx(E,{children:e.jsxs(P,{className:"p-4",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:n}),e.jsx("div",{className:`text-2xl font-semibold ${v?"text-primary":"text-foreground"}
1`,children:m===void 0?"…":m.toLocaleString("pt-BR")})]})}),k=({label:n,value:m})=>e.jsxs("div",{className:"rounded border p-2",children:[e.jsx("div",{className:"text-[10px] uppercase text-muted-foreground",children:n}),e.jsx("div",{className:"text-sm font-semibold tabular-nums",children:m==null||m===0?"—":Number(m).toLocaleString("pt-BR")})]});export{Qe as default};

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.