PageSourceSearch

https://ps.ismart.org.br/assets/AdminMedalVerifications-Db4Djnfq.js

js ismart.org.br collected 2026-09-25 19:50:53 UTC 15,189 bytes, 1 lines download raw bytes

1import{u as ne,b as L,c as Q,j as e}from"./vendor-query-C5CkDKs-.js";import{r as l}from"./recharts-DwXsdKts.js";import{A as le}from"./AdminLayout-Ce1PmZLc.js";import{B as y}from"./badge-DHD5lgF_.js";import{B as d}from"./button-BfXBMGXv.js";import{I as oe}from"./input-D_I_KHkU.js";import{T as de}from"./textarea-C2tVJrct.js";import{S as ce,a as me,b as xe,c as pe,d as P}from"./select-UJpi995A.js";import{T as ue,a as he,b as D,c as u,d as je,e as c}from"./table-DAbVH7Kq.js";import{D as $,a as M,b as U,c as O,d as V,e as H}from"./dialog-C5L-hoY7.js";import{S as fe}from"./skeleton-y1Gmv1Vv.js";import{a as ge,s as _,L as T,X as G}from"./index-DCAs_njX.js";import{o as ve}from"./candidateQuestionnaire-DJ7JzpH1.js";import{T as X}from"./trophy-B--s1N7-.js";import{S as Ne}from"./search-BsyljqEz.js";import{F as ee}from"./file-text-D95eV0gv.js";import{E as be}from"./eye-n55MRGf4.js";import{C as Z}from"./check-BCQD_7xc.js";import{E as ye}from"./external-link-CcYOH-og.js";import"./vendor-react-DvTSBsD5.js";import"./useLocalStorageState-DzFN2lhj.js";import"./log-out-DTrhn7gM.js";import"./chevron-right-BD0hxh-_.js";import"./users-ZxqjNxMI.js";import"./graduation-cap-BGQCohCp.js";import"./map-pin-Bm3_OAE1.js";import"./chart-column-Rrf1uahv.js";import"./user-check-D-tvkYwl.js";import"./award-Zdjva58J.js";import"./star-CUpkulEu.js";import"./video-_uFxN2qa.js";import"./users-round-Mg_N68aL.js";import"./landmark-zT8FNZvC.js";import"./target-Bc1tpXo7.js";import"./trending-up-BlvjGEFp.js";import"./mail-6EPpZFbN.js";import"./message-circle-UPx_Ax6n.js";import"./calendar-clock-IAayS6FF.js";import"./key-round-C6J2J8pH.js";import"./vendor-radix-CuI5f0xj.js";import"./vendor-supabase-92svyh75.js";import"./chevron-down-BeWmhHP1.js";import"./chevron-up-DfEBMl-n.js";import"./applicationValidation-BOaGvpna.js";import"./emailDomainValidation-RfMPn4_Y.js";import"./application-B0hZ9tAO.js";const J=20,_e="medal-proofs",W=t=>{var i;return((i=ve.find(n=>n.value===t))==null?void 0:i.label)??t},R=t=>/^https?:\/\//i.test(t),we=t=>/\.(jpe?g|png|webp|gif)$/i.test(t);function A(t){if(!t)return"—";try{return new Date(t).toLocaleString("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return t}}function Ce(t,i){const[n,x]=l.useState(t);return l.useEffect(()=>{const h=setTimeout(()=>x(t),i);return()=>clearTimeout(h)},[t,i]),n}function Y({status:t}){const n={pending:{label:"Pendente",cls:"bg-muted text-muted-foreground"},submitted:{label:"Aguardando revisão",cls:"bg-amber-100 text-amber-800"},approved:{label:"Aprovada",cls:"bg-emerald-100 text-emerald-800"},rejected:{label:"Não aprovada",cls:"bg-destructive/10 text-destructive"}}[t]??{label:t,cls:"bg-muted text-muted-foreground"};return e.jsx(y,{className:`${n.cls} hover:${n.cls}`,children:n.label})}function Se({url:t}){var h;const[i,n]=l.useState(R(t)?t:null),x=((h=t.split("/").pop())==null?void 0:h.replace(/^\d+_/,""))??t;return l.useEffect(()=>{let w=!1;if(!R(t))return _.storage.from(_e).createSignedUrl(t,60*60).then(({data:p})=>{!w&&(p!=null&&p.signedUrl)&&n(p.signedUrl)}),()=>{w=!0}},[t]),R(t)?e.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-primary hover:underline max-w-[200px]",title:t,children:[e.jsx(ye,{className:"w-3 h-3 shrink-0"}),e.jsx("span",{className:"truncate",children:t})]}):we(t)&&i?e.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",title:x,children:e.jsx("img",{src:i,alt:x,className:"w-14 h-14 object-cover rounded border border-border hover:opacity-80 transition-opacity"})}):e.jsxs("a",{href:i??"#",target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-xs text-primary hover:underline max-w-[180px] ${i?"":"opacity-50 pointer-events-none"}`,title:x,children:[e.jsx(ee,{className:"w-3 h-3 shrink-0"}),e.jsx("span",{className:"truncate",children:x})]})}function vs(){var K;const{toast:t}=ge(),i=ne(),[n,x]=l.useState("submitted"),[h,w]=l.useState(""),p=Ce(h,300),[o,C]=l.useState(null),v=l.useRef([]),S=`${n}|${p}`,q=l.useRef(S);l.useEffect(()=>{q.current!==S&&(q.current=S,v.current=[],C(null))},[S]);const j=L({queryKey:["admin-medal-verifications",n,p,o==null?void 0:o.created_at,o==null?void 0:o.id],queryFn:async()=>{const{data:s,error:r}=await _.rpc("admin_list_medal_verifications",{p_status:n==="all"?void 0:n,p_search:p.trim()||void 0,p_cursor_created_at:o==null?void 0:o.created_at,p_cursor_id:o==null?void 0:o.id,p_page_size:J});if(r)throw r;return s??[]}}),B=L({queryKey:["admin-medal-verifications-pending-count"],queryFn:async()=>{const{data:s,error:r}=await _.rpc("admin_list_medal_verifications",{p_status:"submitted",p_page_size:1e3});if(r)throw r;return(s??[]).length}}),f=Q({mutationFn:async s=>{const{error:r}=await _.rpc("admin_approve_medal_verification",{p_user_id:s});if(r)throw r},onSuccess:()=>{t({title:"Comprovação aprovada"}),i.invalidateQueries({queryKey:["admin-medal-verifications"]}),i.invalidateQueries({queryKey:["admin-medal-verifications-pending-count"]})},onError:s=>{const r=s instanceof Error?s.message:"Tente novamente.";t({title:"Erro ao aprovar",description:r,variant:"destructive"})}}),[m,N]=l.useState(null),[I,k]=l.useState(""),[a,E]=l.useState(null);l.useEffect(()=>{if(!a)return;const s=(j.data??[]).find(r=>
1r.user_id===a.user_id);s&&s!==a&&E(s)},[j.data,a]);const F=Q({mutationFn:async({userId:s,notes:r})=>{const{error:g}=await _.rpc("admin_reject_medal_verification",{p_user_id:s,p_notes:r.trim()||void 0});if(g)throw g},onSuccess:()=>{t({title:"Comprovação rejeitada"}),N(null),k(""),i.invalidateQueries({queryKey:["admin-medal-verifications"]}),i.invalidateQueries({queryKey:["admin-medal-verifications-pending-count"]})},onError:s=>{const r=s instanceof Error?s.message:"Tente novamente.";t({title:"Erro ao rejeitar",description:r,variant:"destructive"})}}),b=j.data??[],se=b.length===J,te=v.current.length>0,ae=()=>{const s=b[b.length-1];s&&(v.current.push(o??{created_at:"",id:""}),C({created_at:s.created_at,id:s.user_id}))},re=()=>{const s=v.current.pop();if(!s){C(null);return}C(s.created_at?s:null)},ie=l.useMemo(()=>v.current.length+1,[o]);return e.jsxs(le,{children:[e.jsxs("div",{className:"p-6 lg:p-8 space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(X,{className:"w-7 h-7 text-ismart-gold"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"Comprovações de Medalha"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Revise as comprovações enviadas pelos candidatos medalhistas."})]})]}),B.data!==void 0&&e.jsxs(y,{className:"bg-amber-100 text-amber-800 hover:bg-amber-100 text-sm py-1.5 px-3",children:[B.data," aguardando revisão"]})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs(ce,{value:n,onValueChange:s=>x(s),children:[e.jsx(me,{className:"w-[220px]",children:e.jsx(xe,{})}),e.jsxs(pe,{children:[e.jsx(P,{value:"all",children:"Todos"}),e.jsx(P,{value:"submitted",children:"Aguardando revisão"}),e.jsx(P,{value:"approved",children:"Aprovadas"}),e.jsx(P,{value:"rejected",children:"Não aprovadas"})]})]}),e.jsxs("div",{className:"relative flex-1 min-w-[240px] max-w-md",children:[e.jsx(Ne,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(oe,{value:h,onChange:s=>w(s.target.value),placeholder:"Buscar por nome ou email...",className:"pl-9"})]})]}),e.jsx("div",{className:"border border-border rounded-lg overflow-hidden bg-card",children:e.jsxs(ue,{children:[e.jsx(he,{children:e.jsxs(D,{children:[e.jsx(u,{children:"Candidato"}),e.jsx(u,{children:"Olimpíadas"}),e.jsx(u,{children:"Descrição"}),e.jsx(u,{children:"Provas"}),e.jsx(u,{children:"Status"}),e.jsx(u,{children:"Enviado em"}),e.jsx(u,{children:"Revisado em"}),e.jsx(u,{className:"text-right",children:"Ações"})]})}),e.jsx(je,{children:j.isLoading?Array.from({length:5}).map((s,r)=>e.jsx(D,{children:e.jsx(c,{colSpan:8,children:e.jsx(fe,{className:"h-10 w-full"})})},r)):b.length===0?e.jsx(D,{children:e.jsx(c,{colSpan:8,className:"text-center py-10 text-muted-foreground",children:"Nenhuma comprovação encontrada."})}):b.map(s=>{var z;const r=s.proof_urls??[],g=Array.isArray(s.olympiad_details)?s.olympiad_details:[];return e.jsxs(D,{className:"align-middle",children:[e.jsx(c,{className:"py-2",children:e.jsxs("div",{className:"flex flex-col min-w-0 max-w-[200px]",children:[e.jsx("span",{className:"font-semibold text-sm text-foreground truncate",title:s.name??"",children:s.name??"—"}),e.jsx("span",{className:"text-xs text-muted-foreground truncate",title:s.email??"",children:s.email??"—"})]})}),e.jsx(c,{className:"py-2",children:e.jsx("div",{className:"flex items-center gap-1 max-w-[160px]",children:g.length===0?e.jsx("span",{className:"text-xs text-muted-foreground",children:"—"}):e.jsxs(e.Fragment,{children:[e.jsx(y,{variant:"outline",className:"text-[10px] py-0 truncate max-w-[120px]",children:W(g[0])}),g.length>1&&e.jsxs("span",{className:"text-[10px] text-muted-foreground shrink-0",children:["+",g.length-1]})]})})}),e.jsx(c,{className:"py-2",children:e.jsx("p",{className:"text-xs text-foreground line-clamp-1 max-w-[260px]",title:s.description??"",children:((z=s.description)==null?void 0:z.trim())||"—"})}),e.jsx(c,{className:"py-2",children:r.length===0?e.jsx("span",{className:"text-xs text-muted-foreground",children:"—"}):e.jsxs(y,{variant:"outline",className:"text-[10px] py-0 gap-1",children:[e.jsx(ee,{className:"w-3 h-3"}),r.length," ",r.length===1?"arquivo":"arquivos"]})}),e.jsx(c,{className:"py-2",children:e.jsx(Y,{status:s.status})}),e.jsx(c,{className:"py-2 text-xs whitespace-nowrap",children:A(s.created_at)}),e.jsx(c,{className:"py-2 text-xs whitespace-nowrap",children:A(s.reviewed_at)}),e.jsx(c,{className:"py-2 text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(d,{size:"sm",variant:"outline",onClick:()=>E(s),title:"Ver detalhes",children:e.jsx(be,{className:"w-3.5 h-3.5"})}),s.status==="submitted"&&e.jsxs(e.Fragment,{children:[e.jsxs(d,{size:"sm",variant:"outline",className:"text-emerald-700 border-emerald-300 hover:bg-emerald-50",onClick:()=>
1f.mutate(s.user_id),disabled:f.isPending,children:[f.isPending&&f.variables===s.user_id?e.jsx(T,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(Z,{className:"w-3.5 h-3.5"}),"Aprovar"]}),e.jsxs(d,{size:"sm",variant:"outline",className:"text-destructive border-destructive/40 hover:bg-destructive/10",onClick:()=>{N(s),k("")},children:[e.jsx(G,{className:"w-3.5 h-3.5"}),"Rejeitar"]})]})]})})]},s.user_id)})})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Página ",ie," ",j.isFetching&&"• atualizando..."]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(d,{variant:"outline",size:"sm",onClick:re,disabled:!te||j.isFetching,children:"Anterior"}),e.jsx(d,{variant:"outline",size:"sm",onClick:ae,disabled:!se||j.isFetching,children:"Próxima"})]})]})]}),e.jsx($,{open:!!m,onOpenChange:s=>!s&&N(null),children:e.jsxs(M,{children:[e.jsxs(U,{children:[e.jsx(O,{children:"Rejeitar comprovação"}),e.jsxs(V,{children:[(m==null?void 0:m.name)??"Candidato"," — ",(m==null?void 0:m.email)??""]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-semibold text-foreground",children:"Motivo da rejeição (opcional, visível apenas internamente)"}),e.jsx(de,{value:I,onChange:s=>k(s.target.value),placeholder:"Descreva o motivo internamente...",rows:4,maxLength:1500})]}
1),e.jsxs(H,{children:[e.jsx(d,{variant:"outline",onClick:()=>N(null),disabled:F.isPending,children:"Cancelar"}),e.jsx(d,{variant:"destructive",onClick:()=>m&&F.mutate({userId:m.user_id,notes:I}),disabled:F.isPending,children:F.isPending?e.jsxs(e.Fragment,{children:[e.jsx(T,{className:"w-3.5 h-3.5 animate-spin mr-2"})," Rejeitando..."]}):"Confirmar rejeição"})]})]})}),e.jsx($,{open:!!a,onOpenChange:s=>!s&&E(null),children:e.jsxs(M,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(U,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(X,{className:"w-5 h-5 text-ismart-gold"}),e.jsx(O,{children:"Detalhes da comprovação"})]}),e.jsxs(V,{children:[(a==null?void 0:a.name)??"Candidato"," — ",(a==null?void 0:a.email)??""]})]}),a&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx(Y,{status:a.status}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Enviado em ",A(a.created_at)]}),a.reviewed_at&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["• Revisado em ",A(a.reviewed_at)]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground mb-2",children:"Olimpíadas declaradas"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:(a.olympiad_details??[]).length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"—"}):(a.olympiad_details??[]).map(s=>e.jsx(y,{variant:"outline",className:"text-xs",children:W(s)},s))}),a.olympiad_awards&&e.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["Premiações declaradas: ",e.jsx("span",{className:"text-foreground",children:a.olympiad_awards})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground mb-2",children:"Descrição do candidato"}),e.jsx("p",{className:"text-sm whitespace-pre-wrap text-foreground",children:((K=a.description)==null?void 0:K.trim())||e.jsx("span",{className:"text-muted-foreground",children:"Nenhuma descrição."})})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground mb-2",children:["Provas enviadas (",(a.proof_urls??[]).length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-3",children:(a.proof_urls??[]).length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"Nenhuma prova enviada."}):(a.proof_urls??[]).map((s,r)=>e.jsx(Se,{url:s},`${s}-${r}`))})]}),a.reviewer_notes&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground mb-2",children:"Notas internas"}),e.jsx("p",{className:"text-sm whitespace-pre-wrap text-foreground bg-muted/50 rounded p-3",children:a.reviewer_notes})]})]}
1),e.jsxs(H,{className:"gap-2",children:[e.jsx(d,{variant:"outline",onClick:()=>E(null),children:"Fechar"}),(a==null?void 0:a.status)==="submitted"&&e.jsxs(e.Fragment,{children:[e.jsxs(d,{variant:"outline",className:"text-destructive border-destructive/40 hover:bg-destructive/10",onClick:()=>{N(a),k("")},children:[e.jsx(G,{className:"w-3.5 h-3.5 mr-1"})," Rejeitar"]}),e.jsxs(d,{className:"bg-emerald-600 hover:bg-emerald-700 text-white",onClick:()=>a&&f.mutate(a.user_id),disabled:f.isPending,children:[f.isPending?e.jsx(T,{className:"w-3.5 h-3.5 animate-spin mr-1"}):e.jsx(Z,{className:"w-3.5 h-3.5 mr-1"}),"Aprovar"]})]})]})]})})]})}export{vs 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.