1import{l as q,L as K,r as o,p as U,a5 as k,j as e,O as h,a4 as N,a9 as V,N as W,K as c,W as p,aa as C,t as X,q as Y,s as Z,w as R,a1 as _,X as G}from"./index-CzVFKpC-.js";import{s as J}from"./hallOrder-CcFl3lVw.js";import{P as Q}from"./plus-BQmbj2H1.js";import{P as ee}from"./pen-95SW1Yft.js";import{T as ae}from"./trash-2-5BX15yNU.js";const g=["#FF7D00","#3b82f6","#10b981","#f59e0b","#ef4444","#ec4899","#06b6d4","#84cc16"];function ie(){const{schoolId:n}=q(),{branches:v,hasBranches:u,activeBranchId:w,isAll:b,branchName:z,filterByBranch:B}=K(),[D,I]=o.useState([]),[S,P]=o.useState(!0),[A,l]=o.useState(!1),[i,j]=o.useState(null),[F,f]=o.useState(!1),[s,t]=o.useState({name:"",capacity:20,color:g[0],amenities:"",branchId:"",hourlyRate:"",offersRental:!0,offersBirthday:!0}),O=()=>{var a;return b?((a=v[0])==null?void 0:a.id)??"":w};o.useEffect(()=>n?U(k(n),r=>{I(J(r.docs.map(x=>({id:x.id,...x.data()})))),P(!1)}):void 0,[n]);const L=()=>{j(null),t({name:"",capacity:20,color:g[0],amenities:"",branchId:O(),hourlyRate:"",offersRental:!0,offersBirthday:!0}),l(!0)},$=a=>{j(a),t({name:a.name,capacity:a.capacity,color:a.color,amenities:a.amenities.join(", "),branchId:a.branchId??"",hourlyRate:a.hourlyRate?String(a.hourlyRate):"",offersRental:a.offersRental!==!1,offersBirthday:a.offersBirthday!==!1}),l(!0)},E=async()=>{if(!n||!s.name){c.error("Vnesite ime dvorane.");return}f(!0);try{const a={name:s.name,capacity:s.capacity,color:s.color,amenities:s.amenities.split(",").map(r=>r.trim()).filter(Boolean),branchId:s.branchId||null,hourlyRate:parseFloat(s.hourlyRate.replace(",","."))||null,offersRental:s.offersRental,offersBirthday:s.offersBirthday};if(i){if(await p(C(n,i.id),a),i.name!==a.name||i.color!==a.color){const r=new Date,x=`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}-${String(r.getDate()).padStart(2,"0")}`,M=await X(Y(Z(n),R("hallId","==",i.id),R("date",">=",x)));await Promise.all(M.docs.map(T=>p(T.ref,{hallName:a.name,hallColor:a.color})))}c.success("Dvorana posodobljena.")}else await _(k(n),{...a,isActive:!0,createdAt:G()}),c.success("Dvorana dodana.");l(!1)}catch{c.error("Napaka pri shranjevanju.")}finally{f(!1)}},H=async a=>{if(!(!n||!confirm(`Deaktiviram dvorano "${a.name}"? 2 3Dvorana se ne izbriÅ¡e: že vpisani termini in skupine jo obdržijo, novih pa vanjo ni veÄ mogoÄe naÄrtovati. Znova jo lahko vklopite kadar koli.`)))try{await p(C(n,a.id),{isActive:!1}),c.success("Dvorana deaktivirana.")}catch{c.error("Napaka pri brisanju.")}},m="w-full px-3 py-2 rounded-lg border border-gray-300 dark:bg-gray-700 dark:text-gray-100 dark:border-gray-600 text-sm focus:outline-none focus:ring-2 focus:ring-brand-500",d="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",y=B(D.filter(a=>a.isActive));return e.jsxs("div",{className:"space-y-5",children:[e.jsx("div",{className:"flex justify-end",children:e.jsx(h,{variant:"primary",size:"sm",icon:e.jsx(Q,{size:14}),onClick:L,children:"Dodaj dvorano"})}),S?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx("div",{className:"w-7 h-7 border-2 border-brand-200 dark:border-brand-800 border-t-brand-600 rounded-full animate-spin"})}):y.length===0?e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-2xl border border-gray-100 dark:border-gray-700 shadow-sm py-16 text-center",children:[e.jsx(N,{size:40,className:"mx-auto text-gray-200 mb-3"}),e.jsx("p",{className:"text-gray-400 text-sm",children:u&&!b?"Ni dvoran v tej podružnici.":"Ni dodanih dvoran. Dodajte prvo dvorano."})]}):e.jsx("div",{className:"grid sm:grid-cols-2 lg:grid-cols-3 gap-4",children:y.map(a=>e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-2xl border border-gray-100 dark:border-gray-700 shadow-sm overflow-hidden",children:[e.jsx("div",{className:"h-2",style:{backgroundColor:a.color}}),e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"w-9 h-9 rounded-xl flex items-center justify-center",style:{backgroundColor:a.color+"20",color:a.color},children:e.jsx(N,{size:18})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-gray-900 dark:text-gray-100",children:a.name}),e.jsxs("p",{className:"text-xs text-gray-400",children:["do ",a.capacity," oseb",a.hourlyRate?` · ${a.hourlyRate.toFixed(2)} â¬/uro`:""]}),u&&e.jsxs("p",{className:"text-xs text-brand-600 dark:text-brand-400 flex items-center gap-1 mt-0.5",children:[e.jsx(V,{size:11})," ",a.branchId?z(a.branchId):"Brez podružnice"]})]})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:()=>$(a),className:"p-1.5 rounded-lg text-gray-400 hover:text-brand-600 hover:bg-brand-50 dark:hover:bg-brand-900/30 transition",children:e.jsx(ee,{size:14})}),e.jsx("button",{onClick:()=>H(a),className:"p-1.5 rounded-lg text-gray-400 hover:text-red-600 hover:bg-red-50 dark:hover:bg-red-900/30 transition",children:e.jsx(ae,{size:14})})]})]}),a.amenities.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:a.amenities.map(r=>e.jsx("span",{className:"text-xs bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-300 px-2 py-0.5 rounded-full",children:r},r))})]})]},a.id))}),e.jsx(W,{open:A,onClose:()=>
3l(!1),title:i?"Uredi dvorano":"Nova dvorana",footer:e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"secondary",size:"sm",onClick:()=>l(!1),children:"PrekliÄi"}),e.jsx(h,{variant:"primary",size:"sm",loading:F,onClick:E,children:"Shrani"})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:d,children:"Ime dvorane *"}),e.jsx("input",{className:m,value:s.name,onChange:a=>t(r=>({...r,name:a.target.value})),placeholder:"Dvorana 1"})]}),u&&e.jsxs("div",{children:[e.jsx("label",{className:d,children:"Podružnica"}),e.jsxs("select",{className:m,value:s.branchId,onChange:a=>t(r=>({...r,branchId:a.target.value})),children:[e.jsx("option",{value:"",children:"â brez podružnice â"}),v.map(a=>e.jsx("option",{value:a.id,children:a.name},a.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:d,children:"Kapaciteta (oseb)"}),e.jsx("input",{type:"number",className:m,value:s.capacity,min:1,onChange:a=>t(r=>({...r,capacity:parseInt(a.target.value)||1}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:d,children:"Cena najema (â¬/uro)"}),e.jsx("input",{type:"number",min:0,step:1,className:m,value:s.hourlyRate,onChange:a=>t(r=>({...r,hourlyRate:a.target.value})),placeholder:"npr. 25"}),e.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Prazno = uporabi se skupna postavka iz cenika dogodkov v nastavitvah. Cena, dogovorjena pri posameznem najemu, vedno prevlada nad obema."})]}),e.jsxs("div",{className:"pt-2 border-t border-gray-100 dark:border-gray-700",children:[e.jsx("p",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-1",children:"Ponudba v tej dvorani"}),e.jsx("p",{className:"text-xs text-gray-400 mb-3",children:"Odkljukajte, Äesa v tej dvorani ne ponujate â npr. Äe jo Å¡ola sama najema po urah. Lokacija se na javnih obrazcih ponudi le, Äe to omogoÄa vsaj ena njena dvorana."}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"flex items-center gap-2.5 text-sm text-gray-700 dark:text-gray-300 cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"rounded border-gray-300 text-brand-600 focus:ring-brand-500",checked:s.offersRental,onChange:a=>t(r=>({...r,offersRental:a.target.checked}))}),"Oddaja dvorane v najem"]}),e.jsxs("label",{className:"flex items-center gap-2.5 text-sm text-gray-700 dark:text-gray-300 cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"rounded border-gray-300 text-brand-600 focus:ring-brand-500",checked:s.offersBirthday,onChange:a=>t(r=>({...r,offersBirthday:a.target.checked}))}),"Rojstnodnevne zabave"]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:d,children:"Barva v urniku"}),e.jsx("div",{className:"flex gap-2 flex-wrap mt-1",children:g.map(a=>e.jsx("button",{onClick:()=>t(r=>({...r,color:a})),className:`w-8 h-8 rounded-lg transition ${s.color===a?"ring-2 ring-offset-2 ring-gray-400":""}`,style:{backgroundColor:a}},a))})]}),e.jsxs("div",{children:[e.jsx("label",{className:d,children:"Oprema (loÄena z vejico)"}),e.jsx("input",{className:m,value:s.amenities,onChange:a=>t(r=>({...r,amenities:a.target.value})),placeholder:"ogledala, zvok, balet barre"})]})]})})]})}export{ie 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.