PageSourceSearch

https://freelacerto.com/assets/AdminTermos-mLHiaMYh.js

js freelacerto.com collected 2026-10-02 01:32:18 UTC 12,684 bytes, 3 lines download raw bytes

1import{j as e,u as D,V as T,S as A,bp as U,b as q}from"./index-D0NFXJHP.js";import{r as n}from"./react-vendor-B-clOVnp.js";import{R as V}from"./RichTextEditor-EJ8W4TeQ.js";import{q as L,n as _,aP as G,ay as E,X as Y,cW as J,k as Q,b9 as X,p as K,S as Z}from"./icons-l1P0DWf7.js";import"./with-selector-zmmuMwI5.js";const u="#031D44",ee="#00C4D4",te=[{v:"freelancer",l:"Termos do Freelancer"},{v:"contratante",l:"Termos do Contratante"}];function he(){const[t,o]=n.useState("termos");return e.jsxs("div",{style:{padding:20,maxWidth:1e3,margin:"0 auto"},children:[e.jsxs("div",{style:ae,children:[e.jsx(L,{size:18,color:ee}),e.jsx("h1",{style:{margin:0,fontSize:17},children:"Termos & Aceites"})]}),e.jsxs("div",{style:{display:"flex",gap:6,marginBottom:16},children:[e.jsx("button",{onClick:()=>o("termos"),style:B(t==="termos"),children:"Termos de Uso"}),e.jsx("button",{onClick:()=>o("aceites"),style:B(t==="aceites"),children:"Aceites registrados"})]}),t==="termos"?e.jsx(oe,{}):e.jsx(re,{})]})}function oe(){const{token:t}=D(),[o,i]=n.useState("freelancer"),[a,y]=n.useState(null),[p,m]=n.useState(""),[d,x]=n.useState(""),[f,h]=n.useState(""),[b,v]=n.useState(!1),[g,S]=n.useState(null),[j,z]=n.useState(!1);async function s(){x(""),h("");const r=await fetch(`/api/termos/${o}`,{headers:{Authorization:`Bearer ${t}`}}),c=await r.json();if(!r.ok){x(c.error||"Erro");return}y(c),m(c.conteudo||"")}n.useEffect(()=>{s()},[o]);async function w(){if(!p.trim()){x("Conteúdo obrigatório");return}if(await q(`Publicar nova versão dos termos do ${o}?
2
3A versão atual será arquivada no histórico e os usuários terão que aceitar de novo.`)){v(!0),x(""),h("");try{const r=await fetch(`/api/admin/termos/${o}`,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({conteudo:p})}),c=await r.json();if(!r.ok)throw new Error(c.error||"Erro");h(c.semMudanca?"Nenhuma mudança detectada — versão mantida.":`Publicada versão ${c.termo.versao}.`),s()}catch(r){x(r.message)}finally{v(!1)}}}async function C(){z(!0);try{const r=await fetch(`/api/admin/termos/${o}/historico`,{headers:{Authorization:`Bearer ${t}`}}),c=await r.json();if(!r.ok){x(c.error||"Erro");return}S(c)}finally{z(!1)}}return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"flex",gap:6,marginBottom:12},children:te.map(r=>e.jsx("button",{onClick:()=>i(r.v),style:{padding:"8px 16px",borderRadius:999,border:"1px solid "+(o===r.v?u:"#d1d5db"),background:o===r.v?u:"#fff",color:o===r.v?"#fff":"#374151",fontSize:13,fontWeight:600,cursor:"pointer"},children:r.l},r.v))}),d&&e.jsx("div",{style:M,children:d}),f&&e.jsx("div",{style:de,children:f}),a&&e.jsxs("div",{style:W,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:10,flexWrap:"wrap"},children:[e.jsxs("span",{style:k("#0ea5e9"),children:["Versão atual: ",a.versao]}),a.publicadoEm&&e.jsxs("span",{style:{fontSize:12,color:"#6b7280"},children:["Publicado em ",T(a.publicadoEm)]}),a.contentHash&&e.jsxs("span",{title:"SHA-256 do conteúdo desta versão",style:P,children:["hash ",a.contentHash.slice(0,12),"…"]}),e.jsx("button",{onClick:C,disabled:j,style:{...I,marginLeft:"auto"},children:j?e.jsxs(e.Fragment,{children:[e.jsx(A,{size:13})," Carregando…"]}):e.jsxs(e.Fragment,{children:[e.jsx(_,{size:13})," Histórico"]})})]}),e.jsx(V,{value:p,onChange:m,minHeight:400,placeholder:"Digite ou cole o texto integral dos termos e use a barra de formatação acima…"}),e.jsx("button",{onClick:w,disabled:b,style:{...N,marginTop:10},children:b?e.jsxs(e.Fragment,{children:[e.jsx(A,{size:14})," Publicando…"]}):e.jsxs(e.Fragment,{children:[e.jsx(G,{size:14})," ",`Publicar versão ${(a.versao||0)+1}`]})})]}),g&&e.jsxs(O,{onClose:()=>S(null),titulo:`Histórico — ${o}`,children:[(g.historico||[]).length===0&&e.jsx("div",{style:$,children:"Sem versões anteriores."}),(g.historico||[]).map(r=>e.jsxs("div",{style:{marginBottom:10,padding:10,background:"#f9fafb",borderRadius:6},children:[e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:6,flexWrap:"wrap",alignItems:"center"},children:[e.jsxs("span",{style:k("#6b7280"),children:["v",r.versao]}),e.jsx("span",{style:{fontSize:11,color:"#6b7280"},children:T(r.publicadoEm)}),r.contentHash&&e.jsxs("span",{style:P,children:["hash ",r.contentHash.slice(0,12),"…"]})]}),e.jsxs("details",{children:[e.jsx("summary",{style:{cursor:"pointer",fontSize:12,color:u},children:"Ver conteúdo"}),e.jsx(U,{conteudo:r.conteudo,style:{marginTop:6,fontSize:12,color:"#374151"}})]})]},r._id))]})]})}const se=[{v:"",l:"Todos"},{v:"termos_uso",l:"Termos de Uso"},{v:"contrato_campanha",l:"Contratos de campanha"}];function re(){const{token:t}=D(),[o,i]=n.useState(""),[a,y]=n.useState(""),[p,m]=n.useState(1),[d,x]=n.useState({itens:[],total:0,paginas:1}),[f,h]=n.useState(!1),[b,v]=n.useState(""),[g,S]=n.useState(null),j=n.useCallback(async()=>{h(!0),v("");try{const s=new URLSearchParams({busca:o,tipo:a,page:String(p),limit:"25"}),w=await fetch(`/api/admin/aceites?${s}`,{headers:{Authorization:`Bearer ${t}`}}),C=await w.json();if(!w.ok)throw new Error(C.error||"Erro ao carregar aceites");x(C)}catch(s){v(s.message)}finally{h(!1)}},[t,o,a,p]);n.useEffect(()=>{j()},[j]);function z(s){s.preventDefault(),m(1),j()}return e.jsxs(e.Fragment,{children:[e.jsxs("form",{onSubmit:z,style:{display:"flex",gap:8,marginBottom:12,flexWrap:"wrap"},children:[e.jsxs("div",{style:{position:"relative",flex:1,minWidth:220},children:[e.jsx(E,{size:15,style:{position:"absolute",left:10,top:11,color:"#9ca3af"}}),e.jsx("input",{value:o,onChange:s=>i(s.target.value),placeholder:"Buscar por nome, e-mail ou documento…",style:{...le,paddingLeft:32}})]}),e.jsx("button",{type:"submit",disabled:f,style:N,children:f?e.jsxs(e.Fragment,{children:[e.jsx(A,{size:14})," Buscando…"]}):e.jsxs(e.Fragment,{children:[e.jsx(E,{size:14})," Buscar"]})})]}),e.jsx("div",{style:{display:"flex",gap:6,marginBottom:12,flexWrap:"wrap"},children:se.map(s=>e.jsx("button",{onClick:()=>{y(s.v),m(1)},style:B(a===s.v),children:s.l},s.v))}),b&&e.jsx("div",{style:M,children:b}),e.jsx("div",{style:W,children:f&&d.itens.length===0?e.jsxs("div",{style:$,children:[e.jsx(A,{size:16})," Carregando…"]}):d.itens.length===0?e.jsx("div",{style:$,children:"Nenhum aceite encontrado."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{fontSize:12,color:"#6b7280",marginBottom:8},children:[d.total," aceite(s) encontrado(s)"]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:d.itens.map(s=>e.jsxs("button",{onClick:()=>S(s),style:ce,children:[e.jsxs("div",{style:{flex:1,minWidth:0,textAlign:"left"},children:[e.jsx("div",{style:{fontWeight:700,color:u,fontSize:14,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:s.usuarioNome||"—"}),e.jsx("div",{style:{fontSize:12,color:"#6b7280",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:s.usuarioEmail||"—"})]}),e.jsxs("div",{style:{textAlign:"right",flexShrink:0},children:[e.jsxs("div",{style:{fontSize:12,color:"#374151"},children:[F(s)," v",s.versao]}),e.jsx("div",{style:{fontSize:11,color:"#6b7280"},children:T(s.aceitoEm)})]}),e.jsx(H,{integridade:s.integridade})]},s._id))}),d.paginas>1&&e.jsxs("div",{style:{display:"flex",justifyContent:"center",gap:8,marginTop:14,alignItems:"center"},children:[e.jsx("button",{disabled:p<=1||f,onClick:()=>m(s=>s-1),style:I,children:"Anterior"}),e.jsxs("span",{style:{fontSize:12,color:"#6b7280"},children:["Página ",p," de ",d.paginas]}),e.jsx("button",{disabled:p>=d.paginas||f,onClick:()=>m(s=>s+1),style:I,children:"Próxima"})]})]})}),g&&e.jsx(ie,{aceite:g,onClose:()=>S(null)})]})}function F(t){return t.tipo==="termos_uso"?t.termoTipo==="contratante"?"Termos (contratante)":"Termos (freelancer)":`Contrato ${t.campanhaSlug||""}`.trim()}function H({integridade:t}){const o=t||{};return o.indisponivel?e.jsxs("span",{style:{...k("#6b7280"),display:"inline-flex",alignItems:"center",gap:4},children:[e.jsx(J,{size:12})," N/D"]}
3):o.integro?e.jsxs("span",{style:{...k("#16a34a"),display:"inline-flex",alignItems:"center",gap:4},children:[e.jsx(Q,{size:12})," Íntegro"]}):e.jsxs("span",{style:{...k("#dc2626"),display:"inline-flex",alignItems:"center",gap:4},children:[e.jsx(X,{size:12})," Alterado"]})}function ne(t){if(!t||!t.fonte)return"Não disponível";const o=[t.cidade,t.regiao,t.pais].filter(Boolean).join(", "),i=t.lat!=null&&t.lng!=null?`${Number(t.lat).toFixed(5)}, ${Number(t.lng).toFixed(5)}`:"";return t.fonte==="gps"?`GPS${i?` (${i})`:""}${t.accuracy?` ±${Math.round(t.accuracy)}m`:""}`:`Por IP${o?` — ${o}`:""}${i?` (${i})`:""}`}function ie({aceite:t,onClose:o}){const i=t.integridade||{};return e.jsx(O,{onClose:o,titulo:"Detalhes do aceite",children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(H,{integridade:i}),e.jsx("span",{style:{fontSize:12,color:"#6b7280"},children:i.detalhe||""})]}),e.jsx(l,{rotulo:"Nome",valor:t.usuarioNome||"—"}),e.jsx(l,{rotulo:"E-mail",valor:t.usuarioEmail||"—"}),t.usuarioDocumento&&e.jsx(l,{rotulo:"Documento",valor:t.usuarioDocumento}),e.jsx(l,{rotulo:"Perfil",valor:t.perfilUsuario||"—"}),e.jsx(l,{rotulo:"Documento aceito",valor:`${F(t)} — versão ${t.versao}`}),e.jsx(l,{rotulo:"Data/hora",valor:T(t.aceitoEm)}),e.jsx(l,{rotulo:"Texto do aceite",valor:t.acceptanceText||"—"}),e.jsx("div",{style:R}),e.jsx(l,{icon:e.jsx(K,{size:13}),rotulo:"Localização",valor:ne(t.geo)}),e.jsx(l,{rotulo:"IP",valor:t.ip||"—"}),e.jsx(l,{icon:e.jsx(Z,{size:13}),rotulo:"Dispositivo (UUID)",valor:t.deviceUuid||"—",mono:!0}),t.userAgent&&e.jsx(l,{rotulo:"Navegador",valor:t.userAgent,pequeno:!0}),e.jsx("div",{style:R}),e.jsx(l,{rotulo:"Hash do conteúdo (SHA-256)",valor:t.acceptedContentHash||"—",mono:!0,pequeno:!0}),e.jsx(l,{rotulo:"Assinatura de integridade (HMAC)",valor:t.integritySignature||"—",mono:!0,pequeno:!0})]})})}function l({rotulo:t,valor:o,mono:i,pequeno:a,icon:y}){return e.jsxs("div",{style:{display:"flex",gap:10,alignItems:"flex-start"},children:[e.jsxs("div",{style:{width:200,flexShrink:0,fontSize:12,color:"#6b7280",display:"flex",alignItems:"center",gap:5},children:[y,t]}),e.jsx("div",{style:{flex:1,minWidth:0,color:"#1f2937",fontSize:a?11:13.5,fontFamily:i?"ui-monospace, SFMono-Regular, Menlo, monospace":"inherit",wordBreak:i?"break-all":"normal"},children:o})]})}const ae={display:"flex",alignItems:"center",gap:10,background:u,color:"#fff",padding:"10px 16px",borderRadius:999,marginBottom:16,width:"fit-content"},W={background:"#fff",padding:14,borderRadius:10,border:"1px solid #e5e7eb"},le={padding:"10px",border:"1px solid #d1d5db",borderRadius:6,fontSize:14,width:"100%",boxSizing:"border-box"},N={display:"inline-flex",alignItems:"center",gap:6,background:u,color:"#fff",padding:"8px 14px",borderRadius:6,border:"none",cursor:"pointer",fontWeight:600},I={display:"inline-flex",alignItems:"center",gap:4,background:"#fff",color:u,padding:"6px 12px",borderRadius:6,border:"1px solid #d1d5db",cursor:"pointer",fontSize:12},$={padding:14,color:"#6b7280",textAlign:"center",display:"flex",alignItems:"center",justifyContent:"center",gap:8},M={background:"#fee2e2",color:"#991b1b",padding:10,borderRadius:8,marginBottom:10},de={background:"#dcfce7",color:"#166534",padding:10,borderRadius:8,marginBottom:10},P={fontFamily:"ui-monospace, monospace",fontSize:11,color:"#475569",background:"#f1f5f9",padding:"2px 8px",borderRadius:6},R={height:1,background:"#e5e7eb",margin:"4px 0"},ce={display:"flex",alignItems:"center",gap:12,padding:"10px 12px",background:"#f9fafb",border:"1px solid #eef2f7",borderRadius:8,cursor:"pointer",width:"100%"};function B(t){return{padding:"8px 16px",borderRadius:999,border:"1px solid "+(t?u:"#d1d5db"),background:t?u:"#fff",color:t?"#fff":"#374151",fontSize:13,fontWeight:600,cursor:"pointer"}}function k(t){return{background:t+"22",color:t,padding:"3px 10px",borderRadius:999,fontSize:11,fontWeight:700}}function O({titulo:t,children:o,onClose:i}){return e.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:200,padding:16},children:e.jsxs("div",{style:{background:"#fff",borderRadius:10,padding:18,maxWidth:700,width:"100%",maxHeight:"90vh",overflowY:"auto"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:10},children:[e.jsx("h2",{style:{margin:0,fontSize:16,color:u,flex:1},children:t}),e.jsx("button",{onClick:i,style:{background:"transparent",border:"none",cursor:"pointer"},children:e.jsx(Y,{size:16})})]}),o]})})}export{he 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.