2 lines
26 KiB
JavaScript
2 lines
26 KiB
JavaScript
import{j as e,m as Y}from"./vendor-animation-0s3FMHwK.js";import{r,h as ye,g as fe,u as ve,L as ie}from"./vendor-react-BVs3cwbi.js";import{a as me,c as x,C as he,u as be,F as w,A as de}from"./index-fMsy8JiX.js";import{F as ge}from"./Forbidden-D25jV3Oq.js";import"./vendor-utils-Dyr8OjFr.js";const B="/api/admin";function ke(i,o){if(i==="folder")return e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#e6a817",strokeWidth:"1.5",children:e.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z",fill:"rgba(230, 168, 23, 0.15)"})});const b=(o||"").toLowerCase(),l={pdf:{color:"#e74c3c",path:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"},doc:{color:"#3498db",path:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"},docx:{color:"#3498db",path:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"},xls:{color:"#27ae60",path:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"},xlsx:{color:"#27ae60",path:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"},ppt:{color:"#e67e22",path:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"},pptx:{color:"#e67e22",path:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"},jpg:{color:"#3498db",path:"M19 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2z"},jpeg:{color:"#3498db",path:"M19 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2z"},png:{color:"#3498db",path:"M19 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2z"},gif:{color:"#3498db",path:"M19 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2z"},zip:{color:"#e67e22",path:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"},rar:{color:"#e67e22",path:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"},"7z":{color:"#e67e22",path:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"},dwg:{color:"#8e44ad",path:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"},dxf:{color:"#8e44ad",path:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"},step:{color:"#8e44ad",path:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"},stp:{color:"#8e44ad",path:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}}[b]||{color:"var(--text-muted)",path:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"};return e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:l.color,strokeWidth:"1.5",children:[e.jsx("path",{d:l.path}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]})}function ce({target:i}){return e.jsx("span",{className:"fm-symlink-badge",title:i||"Odkaz",children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),e.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})})}function Ne({item:i,onFolderClick:o}){return i.type==="folder"?e.jsxs("span",{className:"fm-name-cell",children:[e.jsx("button",{type:"button",className:"fm-folder-link",onClick:()=>o(i.name),children:i.name}),i.is_symlink&&e.jsx(ce,{target:i.link_target}),i.item_count!==void 0&&e.jsx("span",{className:"fm-item-count",children:i.item_count})]}):e.jsxs("span",{className:"fm-name-cell",children:[e.jsx("span",{className:"fm-file-name",children:i.name}),i.is_symlink&&e.jsx(ce,{target:i.link_target})]})}function we({projectId:i,projectNumber:o,hasPermission:b,hasNasFolder:$}){const l=me(),S=r.useRef(null),[D,G]=r.useState([]),[E,R]=r.useState(!0),[t,ne]=r.useState(""),[m,O]=r.useState([""]),[U,re]=r.useState(""),[Q,H]=r.useState(!1),[X,W]=r.useState(!1),[Z,z]=r.useState(!1),[P,g]=r.useState(""),[A,ee]=r.useState(!1),[F,C]=r.useState(null),[I,J]=r.useState(""),[j,T]=r.useState(null),[ae,se]=r.useState(!1),[k,K]=r.useState(null),_=b("projects.files"),y=r.useCallback(async(a="",n={})=>{R(!0),K(null);try{const p=new URLSearchParams({project_id:i});a&&p.set("path",a);const c=await x(`${B}/project-files.php?${p}`);if(n.ignore||c.status===401)return;const u=await c.json();u.success?(G(u.data.items||[]),O(u.data.breadcrumb||[""]),ne(u.data.path||""),re(u.data.full_path||"")):c.status===404?(G([]),O([""])):K(u.error||"Nepodařilo se načíst soubory")}catch{n.ignore||K("Chyba připojení")}finally{n.ignore||R(!1)}},[i]);r.useEffect(()=>{const a={ignore:!1};return y("",a),()=>{a.ignore=!0}},[y]);const q=a=>{z(!1),C(null),y(a)},M=a=>{if(a===0){q("");return}const n=m.slice(1,a+1).join("/");q(n)},s=a=>{const n=t?`${t}/${a}`:a;q(n)},d=async a=>{if(!a||a.length===0)return;W(!0);let n=0,p=null;for(const c of a){const u=new FormData;u.append("file",c);const V=new URLSearchParams({action:"upload",project_id:i});t&&V.set("path",t);try{const te=await(await x(`${B}/project-files.php?${V}`,{method:"POST",body:u})).json();te.success?n++:p=te.error||"Chyba při nahrávání"}catch{p="Chyba připojení"}}if(W(!1),n>0){const c=n===1?"Soubor byl nahrán":`Nahráno ${n} souborů`;l.success(c),y(t)}p&&l.error(p)},h=a=>{d(a.target.files),a.target.value=""},f=a=>{a.preventDefault(),H(!1),_&&d(a.dataTransfer.files)},v=a=>{a.preventDefault(),_&&H(!0)},pe=a=>{a.preventDefault(),H(!1)},oe=async()=>{const a=P.trim();if(a){ee(!0);try{const n=new URLSearchParams({action:"create_folder",project_id:i}),c=await(await x(`${B}/project-files.php?${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t,folder_name:a})})).json();c.success?(l.success("Složka byla vytvořena"),z(!1),g(""),y(t)):l.error(c.error||"Nepodařilo se vytvořit složku")}catch{l.error("Chyba připojení")}finally{ee(!1)}}},ue=async a=>{const n=t?`${t}/${a.name}`:a.name,p=new URLSearchParams({action:"download",project_id:i,path:n});try{const c=await x(`${B}/project-files.php?${p}`);if(!c.ok){const te=await c.json().catch(()=>null);l.error(te?.error||"Chyba při stahování");return}const u=await c.blob(),V=URL.createObjectURL(u),N=document.createElement("a");N.href=V,N.download=a.name,document.body.appendChild(N),N.click(),N.remove(),URL.revokeObjectURL(V)}catch{l.error("Chyba připojení")}},xe=async()=>{if(!j)return;se(!0);const a=t?`${t}/${j.name}`:j.name;try{const n=new URLSearchParams({project_id:i,path:a}),c=await(await x(`${B}/project-files.php?${n}`,{method:"DELETE"})).json();c.success?(l.success(j.type==="folder"?"Složka byla smazána":"Soubor byl smazán"),y(t)):l.error(c.error||"Nepodařilo se smazat")}catch{l.error("Chyba připojení")}finally{se(!1),T(null)}},le=async a=>{const n=I.trim();if(!n||n===a.name){C(null);return}const p=t?`${t}/${a.name}`:a.name,c=t?`${t}/${n}`:n;try{const u=new URLSearchParams({action:"move",project_id:i}),N=await(await x(`${B}/project-files.php?${u}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({from_path:p,to_path:c})})).json();N.success?(l.success("Přejmenováno"),y(t)):l.error(N.error||"Nepodařilo se přejmenovat")}catch{l.error("Chyba připojení")}finally{C(null)}},je=a=>{C(a.name),J(a.name)};return E&&D.length===0&&!k?e.jsx("div",{className:"admin-card",children:e.jsxs("div",{className:"admin-card-body",children:[e.jsx("h3",{className:"admin-card-title",children:"Soubory"}),e.jsx("div",{className:"admin-skeleton",style:{padding:0,gap:"0.5rem"},children:[0,1,2,3].map(a=>e.jsxs("div",{className:"admin-skeleton-row",children:[e.jsx("div",{className:"admin-skeleton-line",style:{width:"18px",height:"18px",borderRadius:"4px",flexShrink:0}}),e.jsx("div",{className:"admin-skeleton-line",style:{width:`${60+a*10}%`}})]},a))})]})}):k?e.jsx("div",{className:"admin-card",children:e.jsxs("div",{className:"admin-card-body",children:[e.jsx("h3",{className:"admin-card-title",children:"Soubory"}),e.jsxs("div",{className:"fm-empty",children:[e.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"1.5",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),e.jsx("span",{children:k})]})]})}):e.jsxs("div",{className:"admin-card",children:[e.jsxs("div",{className:"admin-card-body",children:[e.jsx("h3",{className:"admin-card-title",children:"Soubory"}),e.jsxs("div",{className:"fm-toolbar",children:[e.jsx("div",{className:"fm-breadcrumb",children:m.map((a,n)=>e.jsxs("span",{className:"fm-breadcrumb-segment",children:[n>0&&e.jsx("span",{className:"fm-breadcrumb-sep",children:"/"}),e.jsx("button",{type:"button",className:`fm-breadcrumb-btn ${n===m.length-1?"active":""}`,onClick:()=>M(n),children:n===0?o:a})]},n))}),U&&e.jsx("span",{className:"fm-full-path",title:U,children:U}),_&&e.jsxs("div",{className:"fm-toolbar-actions",children:[e.jsxs("button",{type:"button",className:"admin-btn admin-btn-secondary admin-btn-sm",onClick:()=>{z(!Z),g("")},children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"}),e.jsx("line",{x1:"12",y1:"11",x2:"12",y2:"17"}),e.jsx("line",{x1:"9",y1:"14",x2:"15",y2:"14"})]}),"Složka"]}),e.jsx("button",{type:"button",className:"admin-btn admin-btn-primary admin-btn-sm",onClick:()=>S.current?.click(),disabled:X,children:X?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"admin-spinner admin-spinner-sm"}),"Nahrávání..."]}):e.jsxs(e.Fragment,{children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"17 8 12 3 7 8"}),e.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]}),"Nahrát"]})}),e.jsx("input",{ref:S,type:"file",multiple:!0,style:{display:"none"},onChange:h})]})]}),Z&&e.jsxs("div",{className:"fm-new-folder",children:[e.jsx("input",{type:"text",value:P,onChange:a=>g(a.target.value),className:"admin-form-input",placeholder:"Název složky...",autoFocus:!0,onKeyDown:a=>{a.key==="Enter"&&oe(),a.key==="Escape"&&(z(!1),g(""))},style:{fontSize:"12px",padding:"6px 10px"}}),e.jsx("button",{type:"button",className:"admin-btn admin-btn-primary admin-btn-sm",onClick:oe,disabled:A||!P.trim(),children:A?e.jsx("div",{className:"admin-spinner admin-spinner-sm"}):"Vytvořit"}),e.jsx("button",{type:"button",className:"admin-btn admin-btn-secondary admin-btn-sm",onClick:()=>{z(!1),g("")},children:"Zrušit"})]}),e.jsxs("div",{className:`fm-content ${Q?"fm-drag-over":""}`,onDrop:f,onDragOver:v,onDragLeave:pe,children:[Q&&e.jsxs("div",{className:"fm-dropzone-overlay",children:[e.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"17 8 12 3 7 8"}),e.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]}),e.jsx("span",{children:"Přetáhněte soubory sem"})]}),D.length===0&&!E?e.jsxs("div",{className:"fm-empty",children:[e.jsx("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"1.5",children:e.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})}),e.jsx("span",{children:$?"Složka je prázdná":"Složka projektu zatím neexistuje"}),_&&!$&&e.jsx("span",{style:{fontSize:"11px"},children:"Nahrání souboru ji automaticky vytvoří"})]}):e.jsx("div",{className:"admin-table-responsive",children:e.jsxs("table",{className:"admin-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:{width:"30px"}}),e.jsx("th",{children:"Název"}),e.jsx("th",{style:{width:"90px"},children:"Velikost"}),e.jsx("th",{style:{width:"120px"},children:"Změněno"}),_&&e.jsx("th",{style:{width:"100px",textAlign:"right"},children:"Akce"})]})}),e.jsx("tbody",{children:D.map(a=>e.jsxs("tr",{children:[e.jsx("td",{style:{textAlign:"center"},children:ke(a.type,a.extension)}),e.jsx("td",{children:F===a.name?e.jsx("input",{type:"text",value:I,onChange:n=>J(n.target.value),className:"admin-form-input",style:{fontSize:"11px",padding:"3px 8px",maxWidth:"300px"},autoFocus:!0,onKeyDown:n=>{n.key==="Enter"&&le(a),n.key==="Escape"&&C(null)},onBlur:()=>le(a)}):e.jsx(Ne,{item:a,onFolderClick:s})}),e.jsx("td",{className:"fm-meta",children:a.type==="file"?a.size_formatted:"—"}),e.jsx("td",{className:"fm-meta",children:a.modified||"—"}),_&&e.jsx("td",{style:{textAlign:"right"},children:e.jsxs("div",{className:"fm-actions",children:[a.type==="file"&&e.jsx("button",{type:"button",className:"admin-btn-icon",title:"Stáhnout",onClick:()=>ue(a),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"7 10 12 15 17 10"}),e.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}),e.jsx("button",{type:"button",className:"admin-btn-icon",title:"Přejmenovat",onClick:()=>je(a),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),e.jsx("button",{type:"button",className:"admin-btn-icon danger",title:"Smazat",onClick:()=>T(a),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("polyline",{points:"3 6 5 6 21 6"}),e.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),e.jsx("path",{d:"M10 11v6M14 11v6"})]})})]})})]},a.name))})]})})]})]}),e.jsx(he,{isOpen:j!==null,onClose:()=>T(null),onConfirm:xe,title:j?.type==="folder"?"Smazat složku":"Smazat soubor",message:`Opravdu chcete smazat "${j?.name}"?${j?.type==="folder"?" Složka bude smazána včetně veškerého obsahu.":""}`,confirmText:"Smazat",cancelText:"Zrušit",type:"danger",loading:ae})]})}const L="/api/admin",Se={aktivni:"Aktivní",dokonceny:"Dokončený",zruseny:"Zrušený"};function ze(i){if(!i)return"";const o=new Date(i),b=o.getDate(),$=o.getMonth()+1,l=o.getFullYear(),S=String(o.getHours()).padStart(2,"0"),D=String(o.getMinutes()).padStart(2,"0");return`${b}. ${$}. ${l} ${S}:${D}`}function Pe(){const{id:i}=ye(),o=me(),{hasPermission:b,isAdmin:$}=be(),l=fe(),S=ve(),[D,G]=r.useState(!0),[E,R]=r.useState(!1),[t,ne]=r.useState(null),[m,O]=r.useState({name:"",status:"aktivni",start_date:"",end_date:"",responsible_user_id:""}),[U,re]=r.useState([]),[Q,H]=r.useState(!1),[X,W]=r.useState(!1),[Z,z]=r.useState(!1),[P,g]=r.useState([]),[A,ee]=r.useState(!0),[F,C]=r.useState(""),[I,J]=r.useState(!1),[j,T]=r.useState(null),ae=r.useRef(!1);r.useEffect(()=>{S.state?.created&&!ae.current&&(ae.current=!0,o.success("Projekt byl vytvořen"),l(S.pathname,{replace:!0,state:{}}))},[S.state]);const se=async()=>{try{const s=await x(`${L}/projects.php?action=notes&id=${i}`);if(s.status===401)return;const d=await s.json();d.success&&g(d.data.notes||[])}catch{}finally{ee(!1)}};if(r.useEffect(()=>{const s=async()=>{try{const h=await x(`${L}/projects.php?action=detail&id=${i}`);if(h.status===401)return;const f=await h.json();if(f.success){const v=f.data;ne(v),O({name:v.name||"",status:v.status||"aktivni",start_date:(v.start_date||"").substring(0,10),end_date:(v.end_date||"").substring(0,10),responsible_user_id:v.responsible_user_id||""})}else o.error(f.error||"Nepodařilo se načíst projekt"),l("/projects")}catch{o.error("Chyba připojení"),l("/projects")}finally{G(!1)}},d=async()=>{try{const h=await x(`${L}/projects.php?action=users`);if(h.status===401)return;const f=await h.json();f.success&&re(f.data.users||[])}catch{}};s(),se(),d()},[i,o,l]),!b("projects.view"))return e.jsx(ge,{});const k=(s,d)=>O(h=>({...h,[s]:d})),K=async()=>{if(!m.name.trim()){o.error("Název projektu je povinný");return}R(!0);try{const d=await(await x(`${L}/projects.php?id=${i}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:m.name,status:m.status,start_date:m.start_date||null,end_date:m.end_date||null,responsible_user_id:m.responsible_user_id||null})})).json();d.success?o.success(d.message||"Projekt byl aktualizován"):o.error(d.error||"Nepodařilo se uložit projekt")}catch{o.error("Chyba připojení")}finally{R(!1)}},_=async()=>{W(!0);try{const d=await(await x(`${L}/projects.php?id=${i}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({delete_files:Z})})).json();d.success?(l("/projects"),setTimeout(()=>o.success("Projekt byl smazán"),300)):o.error(d.error||"Nepodařilo se smazat projekt")}catch{o.error("Chyba připojení")}finally{W(!1)}},y=async()=>{if(F.trim()){J(!0);try{const d=await(await x(`${L}/projects.php?action=add_note&id=${i}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:F.trim()})})).json();d.success?(g(h=>[d.data.note,...h]),C(""),o.success("Poznámka byla přidána")):o.error(d.error||"Nepodařilo se přidat poznámku")}catch{o.error("Chyba připojení")}finally{J(!1)}}},q=async s=>{T(s);try{const h=await(await x(`${L}/projects.php?action=delete_note¬eId=${s}`,{method:"DELETE"})).json();h.success?(g(f=>f.filter(v=>v.id!==s)),o.success("Poznámka byla smazána")):o.error(h.error||"Nepodařilo se smazat poznámku")}catch{o.error("Chyba připojení")}finally{T(null)}};if(D)return e.jsxs("div",{className:"admin-skeleton",style:{padding:0,gap:"1.5rem"},children:[e.jsxs("div",{className:"admin-skeleton-row",style:{justifyContent:"space-between"},children:[e.jsxs("div",{className:"flex-row-gap",children:[e.jsx("div",{className:"admin-skeleton-line",style:{width:"32px",height:"32px",borderRadius:"8px"}}),e.jsx("div",{className:"admin-skeleton-line h-8",style:{width:"200px"}})]}),e.jsxs("div",{className:"admin-skeleton-row",style:{gap:"0.5rem"},children:[e.jsx("div",{className:"admin-skeleton-line h-10",style:{width:"100px",borderRadius:"8px"}}),e.jsx("div",{className:"admin-skeleton-line h-10",style:{width:"100px",borderRadius:"8px"}})]})]}),e.jsx("div",{className:"admin-card",children:e.jsx("div",{className:"admin-skeleton",style:{gap:"1.25rem"},children:[0,1,2,3].map(s=>e.jsxs("div",{className:"admin-skeleton-row",children:[e.jsx("div",{className:"admin-skeleton-line w-1/4"}),e.jsx("div",{className:"admin-skeleton-line w-1/2"})]},s))})}),e.jsx("div",{className:"admin-card",children:e.jsx("div",{className:"admin-skeleton",style:{gap:"1.25rem"},children:[0,1,2].map(s=>e.jsxs("div",{className:"admin-skeleton-row",children:[e.jsx("div",{className:"admin-skeleton-line w-1/3",style:{marginBottom:"0.5rem"}}),e.jsx("div",{className:"admin-skeleton-line w-full"})]},s))})})]});if(!t)return null;const M=b("projects.edit");return e.jsxs("div",{children:[e.jsxs(Y.div,{className:"admin-page-header",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.4},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"1rem"},children:[e.jsx(ie,{to:"/projects",className:"admin-btn-icon",title:"Zpět","aria-label":"Zpět",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M19 12H5M12 19l-7-7 7-7"})})}),e.jsx("div",{children:e.jsxs("h1",{className:"admin-page-title",children:["Projekt ",t.project_number]})})]}),M&&e.jsxs("div",{className:"admin-page-actions",children:[e.jsx("button",{onClick:K,className:"admin-btn admin-btn-primary",disabled:E,children:E?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"admin-spinner admin-spinner-sm"}),"Ukládání..."]}):"Uložit"}),!t.order_id&&e.jsx("button",{onClick:()=>H(!0),className:"admin-btn admin-btn-primary",children:"Smazat"})]})]}),e.jsx(Y.div,{className:"admin-card",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.4,delay:.1},children:e.jsxs("div",{className:"admin-card-body",children:[e.jsx("h3",{className:"admin-card-title",children:"Základní údaje"}),e.jsxs("div",{className:"admin-form",children:[e.jsxs("div",{className:"admin-form-row",children:[e.jsx(w,{label:"Číslo projektu",children:e.jsx("input",{type:"text",value:t.project_number,className:"admin-form-input",readOnly:!0,style:{backgroundColor:"var(--bg-secondary)",cursor:"default"}})}),e.jsx(w,{label:"Název",children:e.jsx("input",{type:"text",value:m.name,onChange:s=>k("name",s.target.value),className:"admin-form-input",placeholder:"Název projektu",disabled:!M})})]}),e.jsxs("div",{className:"admin-form-row",children:[e.jsx(w,{label:"Zákazník",children:e.jsx("input",{type:"text",value:t.customer_name||"—",className:"admin-form-input",readOnly:!0,style:{backgroundColor:"var(--bg-secondary)",cursor:"default"}})}),e.jsx(w,{label:"Zodpovědná osoba",children:e.jsxs("select",{value:m.responsible_user_id,onChange:s=>k("responsible_user_id",s.target.value),className:"admin-form-select",disabled:!M,children:[e.jsx("option",{value:"",children:"— Nevybráno —"}),U.map(s=>e.jsx("option",{value:s.id,children:s.name},s.id))]})})]}),e.jsxs("div",{className:"admin-form-row admin-form-row-3",children:[e.jsx(w,{label:"Stav",children:e.jsxs("select",{value:m.status,onChange:s=>k("status",s.target.value),className:"admin-form-select",disabled:!M,children:[e.jsx("option",{value:"aktivni",children:"Aktivní"}),e.jsx("option",{value:"dokonceny",children:"Dokončený"}),e.jsx("option",{value:"zruseny",children:"Zrušený"})]})}),e.jsx(w,{label:"Datum zahájení",children:e.jsx(de,{mode:"date",value:m.start_date,onChange:s=>k("start_date",s),disabled:!M})}),e.jsx(w,{label:"Datum ukončení",children:e.jsx(de,{mode:"date",value:m.end_date,onChange:s=>k("end_date",s),disabled:!M})})]})]})]})}),e.jsx(Y.div,{className:"admin-card",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.4,delay:.15},children:e.jsxs("div",{className:"admin-card-body",children:[e.jsx("h3",{className:"admin-card-title",children:"Poznámky"}),e.jsxs("div",{className:"mb-4",children:[e.jsx("textarea",{value:F,onChange:s=>C(s.target.value),className:"admin-form-input",rows:2,placeholder:"Napište poznámku...",style:{resize:"vertical",width:"100%"},onKeyDown:s=>{s.key==="Enter"&&s.ctrlKey&&F.trim()&&y()}}),e.jsx("div",{className:"mt-2",children:e.jsx("button",{onClick:y,className:"admin-btn admin-btn-secondary admin-btn-sm",disabled:I||!F.trim(),children:I?e.jsx("div",{className:"admin-spinner admin-spinner-sm"}):"Přidat poznámku"})})]}),t.notes&&e.jsxs("div",{style:{padding:"0.75rem",background:"var(--bg-secondary)",borderRadius:"0.5rem",marginBottom:"0.5rem",fontSize:"0.85rem",color:"var(--text-secondary)"},children:[e.jsx("div",{style:{fontSize:"0.75rem",color:"var(--text-tertiary)",marginBottom:"0.25rem"},children:"Starší poznámka (před zavedením systému)"}),e.jsx("div",{style:{whiteSpace:"pre-wrap"},children:t.notes})]}),A&&e.jsx("div",{className:"admin-skeleton",style:{gap:"0.75rem"},children:[0,1,2].map(s=>e.jsx("div",{className:"admin-skeleton-line",style:{height:"52px",borderRadius:"8px"}},s))}),!A&&P.length===0&&!t.notes&&e.jsx("div",{style:{color:"var(--text-tertiary)",fontSize:"0.875rem",textAlign:"center",padding:"1rem 0"},children:"Zatím žádné poznámky"}),!A&&(P.length>0||t.notes)&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:P.map(s=>e.jsx("div",{style:{padding:"0.75rem",background:"var(--bg-secondary)",borderRadius:"0.5rem",position:"relative"},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"0.5rem"},children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"0.25rem"},children:[e.jsx("span",{style:{fontWeight:600,fontSize:"0.85rem"},children:s.user_name}),e.jsx("span",{style:{color:"var(--text-tertiary)",fontSize:"0.75rem"},children:ze(s.created_at)})]}),e.jsx("div",{style:{whiteSpace:"pre-wrap",fontSize:"0.875rem",lineHeight:1.5},children:s.content})]}),$&&e.jsx("button",{onClick:()=>q(s.id),className:"admin-btn-icon",title:"Smazat poznámku",disabled:j===s.id,style:{flexShrink:0,opacity:j===s.id?.5:1},children:j===s.id?e.jsx("div",{className:"admin-spinner",style:{width:14,height:14,borderWidth:2}}):e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("polyline",{points:"3 6 5 6 21 6"}),e.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),e.jsx("path",{d:"M10 11v6M14 11v6"})]})})]})},s.id))})]})}),e.jsx(Y.div,{style:{marginBottom:"1rem"},initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.4,delay:.2},children:e.jsx(we,{projectId:i,projectNumber:t.project_number,hasPermission:b,hasNasFolder:t.has_nas_folder})}),e.jsx(Y.div,{className:"admin-card",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.4,delay:.25},children:e.jsxs("div",{className:"admin-card-body",children:[e.jsx("h3",{className:"admin-card-title",children:"Propojení"}),e.jsxs("div",{className:"admin-form-row",children:[e.jsx(w,{label:"Objednávka",children:e.jsx("div",{children:t.order_id?e.jsxs(ie,{to:`/orders/${t.order_id}`,className:"link-accent",children:[t.order_number,t.order_status&&e.jsxs("span",{className:"text-tertiary",style:{fontWeight:400,marginLeft:"0.5rem"},children:["(",Se[t.order_status]||t.order_status,")"]})]}):"—"})}),e.jsx(w,{label:"Nabídka",children:e.jsx("div",{children:t.quotation_id?e.jsx(ie,{to:`/offers/${t.quotation_id}`,className:"link-accent",children:t.quotation_number}):"—"})})]})]})}),e.jsx(he,{isOpen:Q,onClose:()=>{H(!1),z(!1)},onConfirm:_,title:"Smazat projekt",message:e.jsxs(e.Fragment,{children:['Opravdu chcete smazat projekt "',t.project_number," – ",t.name,'"? Tato akce je nevratná.',t.has_nas_folder&&e.jsxs("label",{className:"admin-form-checkbox",style:{marginTop:"1rem",display:"flex"},children:[e.jsx("input",{type:"checkbox",checked:Z,onChange:s=>z(s.target.checked)}),e.jsx("span",{children:"Smazat i soubory na disku"})]})]}),confirmText:"Smazat",cancelText:"Zrušit",type:"danger",loading:X})]})}export{Pe as default};
|