1import{c as L,u as A,a as E,r,B as _,a1 as b,z as d,j as t}from"./index-C-TaAGmN.js";import{A as P}from"./AppShell-Q1pZnWHm.js";import{u as B}from"./usePageTitle-CEBpYjDi.js";import{A as z}from"./arrow-left-BETh3RQS.js";import{S as I}from"./search-Dc78BcFh.js";import{S as R}from"./save-CtJ9lCxN.js";import"./useMediaQuery-BotE5nYp.js";import"./crown-BPCHVQg4.js";import"./credit-card-Dt4NydP0.js";import"./shield-check-Cz_0e103.js";import"./dateFormat-Bk-Flexx.js";import"./trophy-PecPrR9l.js";import"./award-D22YU6tU.js";import"./chart-no-axes-column-DNi2on0A.js";import"./target-BWCUukSP.js";import"./users-B_d8OqAX.js";import"./info-BK4a7HNe.js";import"./chevron-left-BcdrX4IQ.js";function te(){const{t:s}=L("admin");B(s("teamstrans.page_title","Tradução de Times"));const y=A(),[N]=E(),p=N.get("competitionId"),[v,j]=r.useState([]),[i,w]=r.useState(p?Number(p):""),[S,c]=r.useState([]),[m,x]=r.useState({}),[u,h]=r.useState({}),[C,g]=r.useState(!1),[l,T]=r.useState("");r.useEffect(()=>{_.list().then(j).catch(()=>{})},[]),r.useEffect(()=>{if(!i){c([]);return}g(!0),b.listByCompetition(Number(i)).then(e=>{c(e);const o={};e.forEach(a=>{o[a.id]=a.ptName??""}),x(o)}).catch(()=>d.error(s("teamstrans.toast.load_error","Erro ao carregar times"))).finally(()=>g(!1))},[i]);const k=async e=>{const o=m[e.id]?.trim()||null;h(a=>({...a,[e.id]:!0}));try{await b.updatePtName(e.id,o),d.success(s("teamstrans.toast.saved",{name:e.name,defaultValue:'"{{name}}" atualizado'})),c(a=>a.map(n=>n.id===e.id?{...n,ptName:o??void 0}:n))}catch{d.error(s("teamstrans.toast.save_error","Erro ao salvar"))}finally{h(a=>({...a,[e.id]:!1}))}},f=S.filter(e=>e.name.toLowerCase().includes(l.toLowerCase())||(e.ptName??"").toLowerCase().includes(l.toLowerCase())||e.code3.toLowerCase().includes(l.toLowerCase()));return t.jsx(P,{children:t.jsxs("div",{className:"max-w-2xl mx-auto",children:[t.jsxs("button",{onClick:()=>y(-1),className:"flex items-center gap-2 text-primary-600 hover:text-primary-700 mb-4 transition-colors font-medium",children:[t.jsx(z,{className:"w-5 h-5"}),s("teamstrans.back","Voltar")]}),t.jsx("h1",{className:"text-xl font-extrabold text-gray-900 mb-1",children:s("teamstrans.page_title","Tradução de Times")}),t.jsx("p",{className:"text-sm text-gray-500 mb-5",children:s("teamstrans.header_subtitle","Associe um nome em PT-BR a cada time/seleção da competição.")}),t.jsxs("div",{className:"mb-4",children:[t.jsx("label",{className:"block text-sm font-semibold text-gray-700 mb-1",children:s("teamstrans.competition","Competição")}),t.jsxs("select",{value:i,onChange:e=>w(e.target.value?Number(e.target.value):""),className:"w-full px-3 py-2 border border-gray-300 rounded-xl text-sm focus:ring-2 focus:ring-black",children:[t.jsx("option",{value:"",children:s("teamstrans.select_competition","Selecione uma competição...")}),v.map(e=>t.jsx("option",{value:e.id,children:e.name},e.id))]})]}),i&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative mb-4",children:[t.jsx(I,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),t.jsx("input",{type:"text",value:l,onChange:e=>T(e.target.value),placeholder:s("teamstrans.search_placeholder","Buscar time..."),className:"w-full pl-9 pr-3 py-2 border border-gray-300 rounded-xl text-sm focus:ring-2 focus:ring-black"})]}),C?t.jsx("div",{className:"text-center py-10 text-gray-400 text-sm",children:s("teamstrans.loading","Carregando times...")}):f.length===0?t.jsx("div",{className:"text-center py-10 text-gray-400 text-sm",children:s("teamstrans.empty","Nenhum time encontrado")}):t.jsx("div",{className:"space-y-2",children:f.map(e=>{const o=(m[e.id]??"")!==(e.ptName??"");return t.jsxs("div",{className:"flex items-center gap-3 p-3 bg-white rounded-xl border border-gray-200",children:[e.flagUrl?t.jsx("img",{src:e.flagUrl,alt:e.code3,className:"w-8 h-6 object-cover rounded flex-shrink-0"}):t.jsx("div",{className:"w-8 h-6 bg-gray-100 rounded flex-shrink-0 flex items-center justify-center text-xs text-gray-400",children:e.code3}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("p",{className:"text-xs text-gray-400",children:[e.name," ",t.jsxs("span",{className:"font-mono",children:["(",e.code3,")"]})]}
1),t.jsx("input",{type:"text",value:m[e.id]??"",onChange:a=>x(n=>({...n,[e.id]:a.target.value})),placeholder:s("teamstrans.name_placeholder","Nome em PT-BR..."),className:"w-full px-2 py-1 border border-gray-300 rounded-lg text-sm mt-0.5 focus:ring-2 focus:ring-black"})]}),t.jsxs("button",{onClick:()=>k(e),disabled:!o||u[e.id],className:"flex items-center gap-1 px-3 py-1.5 bg-black text-white text-xs font-semibold rounded-lg hover:bg-gray-800 transition disabled:opacity-40",children:[t.jsx(R,{className:"w-3 h-3"}),u[e.id]?"...":s("teamstrans.save","Salvar")]})]},e.id)})})]})]})})}export{te as default}; 2//# sourceMappingURL=TeamsTranslationAdmin-ySyiweHg.js.map
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.