PageSourceSearch

https://bjj-manager-pro.web.app/portal/assets/DisciplineManager-C3rHBXeW.js

js bjj-manager-pro.web.app collected 2026-10-03 12:19:27 UTC 11,035 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-tiptap-CRdka2py.js";import{u as L,b as x}from"./vendor-i18n-Do9jGewF.js";import{H as $,C as E}from"./HelpButton-Dht5BAjR.js";import"./index-Dm1QE6j5.js";import"./vendor-firebase-B7FTlnjY.js";const C=["#E50401","#10b981","#3b82f6","#f43f5e","#06b6d4","#ec4899","#6366f1","#71717a","#0ea5e9"];let R=1;const A=()=>`temp-${Date.now()}-${R++}`,F=({discipline:l,onSave:f,onClose:v})=>{const{t:n}=L(),[i,z]=x.useState(l?.name||""),[p,g]=x.useState(l?.color||C[0]),[c,m]=x.useState(l?.gradingType||"belt"),[o,j]=x.useState(l?.isActive??!0),[b,h]=x.useState(l?.rankLevels||[]),w=!l,N=()=>{h(r=>[...r,{id:A(),name:"",color:C[0],maxStripes:4,order:r.length}])},t=r=>{h(s=>s.filter(a=>a.id!==r).map((a,u)=>({...a,order:u})))},y=(r,s,a)=>{h(u=>u.map(d=>d.id===r?{...d,[s]:a}:d))},M=(r,s)=>{const a=r+s;a<0||a>=b.length||h(u=>{const d=[...u];return[d[r],d[a]]=[d[a],d[r]],d.map((T,D)=>({...T,order:D}))})},S=r=>{if(r.preventDefault(),!i.trim()){alert(n("disciplineManager.nameRequired"));return}f({name:i,color:p,gradingType:c,isActive:o,rankLevels:c==="none"?[]:b.map((s,a)=>({...s,order:a}))})},k="block text-sm font-bold text-zinc-500 dark:text-zinc-400 uppercase tracking-wider mb-1";return e.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50 p-4",children:e.jsx("div",{className:"bg-white dark:bg-dark-surface rounded-2xl shadow-xl w-full max-w-lg max-h-[90vh] flex flex-col border border-zinc-200 dark:border-zinc-800",children:e.jsxs("form",{onSubmit:S,className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"p-6 overflow-y-auto flex-grow custom-scrollbar",children:[e.jsx("h3",{className:"text-2xl font-black mb-4 text-zinc-900 dark:text-white",children:n(w?"disciplineManager.createDiscipline":"disciplineManager.editDiscipline")}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"disc-name",className:k,children:n("disciplineManager.name")}),e.jsx("input",{id:"disc-name",value:i,onChange:r=>z(r.target.value),placeholder:n("disciplineManager.namePlaceholder"),className:"mt-1 w-full p-3 rounded-xl bg-zinc-100 dark:bg-zinc-900 border border-zinc-300 dark:border-zinc-700 text-zinc-900 dark:text-white focus:ring-primary focus:border-primary",required:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:k,children:n("disciplineManager.colorCoding")}),e.jsx("div",{className:"flex flex-wrap gap-3",children:C.map(r=>e.jsx("button",{type:"button",onClick:()=>g(r),className:`w-8 h-8 rounded-full transition-transform ${p===r?"ring-2 ring-offset-2 ring-primary scale-110":"hover:scale-110"}`,style:{backgroundColor:r}},r))})]}),e.jsxs("div",{children:[e.jsx("label",{className:k,children:n("disciplineManager.gradingType")}),e.jsx("div",{className:"flex gap-2",children:["belt","level","none"].map(r=>e.jsx("button",{type:"button",onClick:()=>m(r),className:`flex-1 px-3 py-2.5 rounded-xl text-[11px] font-black uppercase tracking-wider border-2 transition-all ${c===r?"bg-primary border-primary text-white":"bg-zinc-50 dark:bg-zinc-900 border-zinc-200 dark:border-zinc-700 text-zinc-500 dark:text-zinc-400"}`,children:n(`disciplineManager.gradingType${r.charAt(0).toUpperCase()}${r.slice(1)}`)},r))})]}),e.jsx("div",{children:e.jsxs("label",{className:"flex items-center justify-between p-3 bg-zinc-50 dark:bg-zinc-900 rounded-xl border border-zinc-200 dark:border-zinc-800 cursor-pointer",onClick:()=>j(r=>!r),children:[e.jsx("span",{className:"text-sm font-bold text-zinc-700 dark:text-zinc-300",children:n(o?"disciplineManager.active":"disciplineManager.inactive")}),e.jsx("div",{className:`relative w-10 h-6 rounded-full transition-colors shrink-0 ${o?"bg-primary":"bg-zinc-300 dark:bg-zinc-700"}`,children:e.jsx("div",{className:`absolute top-1 left-1 w-4 h-4 bg-white rounded-full shadow transition-transform ${o?"translate-x-4":"translate-x-0"}`})})]})}),c!=="none"&&e.jsxs("div",{children:[e.jsx("label",{className:k,children:n("disciplineManager.rankLevels")}),e.jsx("p",{className:"text-xs text-zinc-400 mb-3",children:n("disciplineManager.rankLevelsHint")}),e.jsxs("div",{className:"space-y-2",children:[b.map((r,s)=>e.jsxs("div",{className:"flex items-center gap-2 bg-zinc-50 dark:bg-zinc-900 p-2 rounded-xl border border-zinc-200 dark:border-zinc-800",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("button",{type:"button",onClick:()=>M(s,-1),disabled:s===0,className:"text-zinc-400 hover:text-primary disabled:opacity-20 disabled:hover:text-zinc-400",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"3",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 15l7-7 7 7"})})}),e.jsx("button",{type:"button",onClick:()=>M(s,1),disabled:s===b.length-1,className:"text-zinc-400 hover:text-primary disabled:opacity-20 disabled:hover:text-zinc-400",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"3",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})})]}),e.jsx("input",{type:"color",value:r.color||"#FFFFFF",onChange:a=>y(r.id,"color",a.target.value),className:"w-8 h-8 rounded cursor-pointer border border-zinc-300 dark:border-zinc-700 shrink-0"}),e.jsx("input",{value:r.name,onChange:a=>y(r.id,"name",a.target.value),placeholder:n("disciplineManager.rankLevelNamePlaceholder"),className:"flex-grow p-2 rounded-lg bg-white dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 text-sm text-zinc-900 dark:text-white"}),c==="belt"&&e.jsx("input",{type:"number",min:"0",value:r.maxStripes??4,onChange:a=>y(r.id,"maxStripes",parseInt(a.target.value)||0),title:n("disciplineManager.maxStripes"),className:"w-16 p-2 rounded-lg bg-white dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 text-sm text-zinc-900 dark:text-white"}),e.jsx("button",{type:"button",onClick:()=>t(r.id),className:"text-red-400 hover:text-red-600 shrink-0",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]},r.id)),b.length===0&&e.jsx("p",{className:"text-xs text-zinc-400 italic text-center py-3",children:n("disciplineManager.noRankLevelsYet")})]}),e.jsx("button",{type:"button",onClick:N,className:"mt-3 w-full py-2.5 rounded-xl border-2 border-dashed border-zinc-300 dark:border-zinc-700 text-zinc-500 dark:text-zinc-400 text-[11px] font-black uppercase tracking-wider hover:border-primary hover:text-primary transition-colors",children:n("disciplineManager.addRankLevel")})]})]})]}),e.jsxs("div",{className:"bg-zinc-50 dark:bg-zinc-900/50 px-6 py-4 flex justify-end gap-3 rounded-b-2xl border-t border-zinc-200 dark:border-zinc-800",children:[e.jsx("button",{type:"button",onClick:v,className:"bg-zinc-200 hover:bg-zinc-300 dark:bg-zinc-800 dark:hover:bg-zinc-700 text-zinc-800 dark:text-white font-bold py-2 px-4 roun
1ded-xl transition-colors text-sm uppercase tracking-wide",children:n("common.cancel")}),e.jsx("button",{type:"submit",className:"bg-primary hover:bg-primary-hover text-white font-bold py-2 px-4 rounded-xl transition-colors text-sm uppercase tracking-wide shadow-lg shadow-red-900/20",children:n("common.save")})]})]})})})},W=({disciplines:l,addDiscipline:f,updateDiscipline:v,deleteDiscipline:n})=>{const{t:i}=L(),[z,p]=x.useState(!1),[g,c]=x.useState(null),[m,o]=x.useState(null),j=async t=>{g?await v({...g,...t}):await f(t),p(!1),c(null)},b=t=>{c(t),p(!0)},h=t=>{o(t)},w=async()=>{m&&(await n(m.id),o(null))},N=t=>i(`disciplineManager.gradingType${t.charAt(0).toUpperCase()}${t.slice(1)}`);return e.jsxs("div",{className:"bg-white dark:bg-dark-surface p-6 rounded-2xl shadow-sm border border-zinc-200 dark:border-zinc-800",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-center border-b border-zinc-200 dark:border-zinc-800 pb-4 mb-6 gap-4",children:[e.jsxs("h3",{className:"text-2xl md:text-4xl font-black text-zinc-900 dark:text-white uppercase tracking-tight flex items-center gap-3",children:[i("disciplineManager.title")," ",e.jsx($,{section:"training_disciplines"})]}),e.jsx("button",{onClick:()=>{c(null),p(!0)},className:"bg-green-600 hover:bg-green-700 text-white font-bold py-2 px-4 rounded-xl transition-colors w-full sm:w-auto uppercase tracking-wide text-sm",children:i("disciplineManager.newDiscipline")})]}),e.jsx("div",{className:"max-h-[70vh] overflow-y-auto pr-2 custom-scrollbar",children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:l.length>0?l.map(t=>e.jsxs("div",{className:"p-6 rounded-[2.2rem] border border-zinc-200 dark:border-zinc-800 bg-zinc-50 dark:bg-zinc-900/50 flex flex-col h-full transition-all hover:border-primary/30 group",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl flex-shrink-0 shadow-sm flex items-center justify-center bg-white dark:bg-zinc-800 border border-zinc-100 dark:border-zinc-700",children:e.jsx("div",{className:"w-6 h-6 rounded-full",style:{backgroundColor:t.color||"#ccc"}})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h4",{className:"font-bold text-lg text-zinc-900 dark:text-white truncate group-hover:text-primary transition-colors",children:t.name}),e.jsx("span",{className:`text-[10px] font-black uppercase tracking-widest ${t.isActive?"text-green-600":"text-zinc-400"}`,children:t.isActive?i("disciplineManager.active"):i("disciplineManager.inactive")})]})]}),e.jsxs("div",{className:"flex-grow mb-6 space-y-1",children:[e.jsx("p",{className:"text-xs text-zinc-500 dark:text-zinc-400",children:N(t.gradingType)}),e.jsxs("p",{className:"text-xs text-zinc-400",children:[i("disciplineManager.rankLevels"),": ",t.rankLevels.length]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-auto pt-4 border-t border-zinc-100 dark:border-zinc-800/50",children:[e.jsx("button",{onClick:()=>b(t),className:"bg-zinc-900 dark:bg-white text-white dark:text-black font-black py-2.5 rounded-xl text-[9px] uppercase tracking-widest transition-all hover:scale-105 active:scale-95 shadow-sm",children:i("common.edit")}),e.jsx("button",{onClick:()=>h(t),className:"bg-red-50 dark:bg-red-900/20 text-red-600 dark:text-red-400 font-black py-2.5 rounded-xl text-[9px] uppercase tracking-widest border border-red-100 dark:border-red-900/50 transition-all active:scale-95",children:i("common.delete")})]})]},t.id)):e.jsx("p",{className:"col-span-full text-center text-zinc-500 dark:text-zinc-400 py-12 italic border-2 border-dashed border-zinc-200 dark:border-zinc-800 rounded-xl",children:i("disciplineManager.noDisciplinesYet")})})}),z&&e.jsx(F,{discipline:g,onSave:j,onClose:()=>p(!1)}),m&&e.jsx(E,{isOpen:!!m,onClose:()=>o(null),onConfirm:w,title:i("disciplineManager.deleteTitle"),message:i("disciplineManager.deleteMessage",{name:m.name}),confirmText:i("common.delete")})]})};export{W as DisciplineManager};

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.