- NasFileManager.php - filesystem helper (browse, upload, download, delete, rename, mkdir) - project-files.php API - CRUD operace nad soubory projektu - ProjectFileManager.jsx - React komponenta v detailu projektu - Automaticke vytvoreni slozky pri vytvoreni projektu (rucne i z objednavky) - Prejmenovani slozky pri zmene nazvu projektu - Checkbox "Smazat i soubory na disku" pri mazani projektu/objednavky - Path traversal ochrana, MIME validace, blocklist nebezpecnych typu - Bily spinner v primary tlacitkach, ConfirmModal message jako div - Case-insensitive rename fix pro Windows filesystem Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2 lines
25 KiB
JavaScript
2 lines
25 KiB
JavaScript
import{j as e,m as q}from"./vendor-animation-0s3FMHwK.js";import{r,h as ue,g as xe,u as je,L as re}from"./vendor-react-BVs3cwbi.js";import{a as de,c as x,C as ce,u as ye,F as k,A as le}from"./index-BrM8fzBu.js";import{F as fe}from"./Forbidden-D25jV3Oq.js";import"./vendor-utils-Dyr8OjFr.js";const V="/api/admin";function ve(o,i){if(o==="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=(i||"").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 be({item:o,onFolderClick:i}){return o.type==="folder"?e.jsxs("button",{type:"button",className:"fm-folder-link",onClick:()=>i(o.name),children:[o.name,o.item_count!==void 0&&e.jsx("span",{className:"fm-item-count",children:o.item_count})]}):e.jsx("span",{className:"fm-file-name",children:o.name})}function ge({projectId:o,projectNumber:i,hasPermission:b,hasNasFolder:_}){const l=de(),w=r.useRef(null),[$,Y]=r.useState([]),[L,E]=r.useState(!0),[t,ae]=r.useState(""),[c,B]=r.useState([""]),[G,R]=r.useState(!1),[Q,O]=r.useState(!1),[X,S]=r.useState(!1),[P,z]=r.useState(""),[F,H]=r.useState(!1),[W,M]=r.useState(null),[C,U]=r.useState(""),[j,A]=r.useState(null),[Z,I]=r.useState(!1),[T,J]=r.useState(null),u=b("projects.files"),g=r.useCallback(async(a="",n={})=>{E(!0),J(null);try{const p=new URLSearchParams({project_id:o});a&&p.set("path",a);const m=await x(`${V}/project-files.php?${p}`);if(n.ignore||m.status===401)return;const v=await m.json();v.success?(Y(v.data.items||[]),B(v.data.breadcrumb||[""]),ae(v.data.path||"")):m.status===404?(Y([]),B([""])):J(v.error||"Nepodařilo se načíst soubory")}catch{n.ignore||J("Chyba připojení")}finally{n.ignore||E(!1)}},[o]);r.useEffect(()=>{const a={ignore:!1};return g("",a),()=>{a.ignore=!0}},[g]);const K=a=>{S(!1),M(null),g(a)},ee=a=>{if(a===0){K("");return}const n=c.slice(1,a+1).join("/");K(n)},se=a=>{const n=t?`${t}/${a}`:a;K(n)},N=async a=>{if(!a||a.length===0)return;O(!0);let n=0,p=null;for(const m of a){const v=new FormData;v.append("file",m);const te=new URLSearchParams({action:"upload",project_id:o});t&&te.set("path",t);try{const oe=await(await x(`${V}/project-files.php?${te}`,{method:"POST",body:v})).json();oe.success?n++:p=oe.error||"Chyba při nahrávání"}catch{p="Chyba připojení"}}if(O(!1),n>0){const m=n===1?"Soubor byl nahrán":`Nahráno ${n} souborů`;l.success(m),g(t)}p&&l.error(p)},s=a=>{N(a.target.files),a.target.value=""},d=a=>{a.preventDefault(),R(!1),u&&N(a.dataTransfer.files)},h=a=>{a.preventDefault(),u&&R(!0)},f=a=>{a.preventDefault(),R(!1)},y=async()=>{const a=P.trim();if(a){H(!0);try{const n=new URLSearchParams({action:"create_folder",project_id:o}),m=await(await x(`${V}/project-files.php?${n}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t,folder_name:a})})).json();m.success?(l.success("Složka byla vytvořena"),S(!1),z(""),g(t)):l.error(m.error||"Nepodařilo se vytvořit složku")}catch{l.error("Chyba připojení")}finally{H(!1)}}},me=a=>{const n=t?`${t}/${a.name}`:a.name,p=new URLSearchParams({action:"download",project_id:o,path:n});window.open(`${V}/project-files.php?${p}`,"_blank")},he=async()=>{if(!j)return;I(!0);const a=t?`${t}/${j.name}`:j.name;try{const n=new URLSearchParams({project_id:o,path:a}),m=await(await x(`${V}/project-files.php?${n}`,{method:"DELETE"})).json();m.success?(l.success(j.type==="folder"?"Složka byla smazána":"Soubor byl smazán"),g(t)):l.error(m.error||"Nepodařilo se smazat")}catch{l.error("Chyba připojení")}finally{I(!1),A(null)}},ie=async a=>{const n=C.trim();if(!n||n===a.name){M(null);return}const p=t?`${t}/${a.name}`:a.name,m=t?`${t}/${n}`:n;try{const v=new URLSearchParams({action:"move",project_id:o}),ne=await(await x(`${V}/project-files.php?${v}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({from_path:p,to_path:m})})).json();ne.success?(l.success("Přejmenováno"),g(t)):l.error(ne.error||"Nepodařilo se přejmenovat")}catch{l.error("Chyba připojení")}finally{M(null)}},pe=a=>{M(a.name),U(a.name)};return L&&$.length===0&&!T?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))})]})}):T?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:T})]})]})}):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:c.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===c.length-1?"active":""}`,onClick:()=>ee(n),children:n===0?i:a})]},n))}),u&&e.jsxs("div",{className:"fm-toolbar-actions",children:[e.jsxs("button",{type:"button",className:"admin-btn admin-btn-secondary admin-btn-sm",onClick:()=>{S(!X),z("")},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:()=>w.current?.click(),disabled:Q,children:Q?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:w,type:"file",multiple:!0,style:{display:"none"},onChange:s})]})]}),X&&e.jsxs("div",{className:"fm-new-folder",children:[e.jsx("input",{type:"text",value:P,onChange:a=>z(a.target.value),className:"admin-form-input",placeholder:"Název složky...",autoFocus:!0,onKeyDown:a=>{a.key==="Enter"&&y(),a.key==="Escape"&&(S(!1),z(""))},style:{fontSize:"12px",padding:"6px 10px"}}),e.jsx("button",{type:"button",className:"admin-btn admin-btn-primary admin-btn-sm",onClick:y,disabled:F||!P.trim(),children:F?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:()=>{S(!1),z("")},children:"Zrušit"})]}),e.jsxs("div",{className:`fm-content ${G?"fm-drag-over":""}`,onDrop:d,onDragOver:h,onDragLeave:f,children:[G&&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"})]}),$.length===0&&!L?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"}),u&&!_&&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"}),u&&e.jsx("th",{style:{width:"100px",textAlign:"right"},children:"Akce"})]})}),e.jsx("tbody",{children:$.map(a=>e.jsxs("tr",{children:[e.jsx("td",{style:{textAlign:"center"},children:ve(a.type,a.extension)}),e.jsx("td",{children:W===a.name?e.jsx("input",{type:"text",value:C,onChange:n=>U(n.target.value),className:"admin-form-input",style:{fontSize:"11px",padding:"3px 8px",maxWidth:"300px"},autoFocus:!0,onKeyDown:n=>{n.key==="Enter"&&ie(a),n.key==="Escape"&&M(null)},onBlur:()=>ie(a)}):e.jsx(be,{item:a,onFolderClick:se})}),e.jsx("td",{className:"fm-meta",children:a.type==="file"?a.size_formatted:"—"}),e.jsx("td",{className:"fm-meta",children:a.modified||"—"}),u&&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:()=>me(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:()=>pe(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:()=>A(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(ce,{isOpen:j!==null,onClose:()=>A(null),onConfirm:he,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:Z})]})}const D="/api/admin",Ne={aktivni:"Aktivní",dokonceny:"Dokončený",zruseny:"Zrušený"};function ke(o){if(!o)return"";const i=new Date(o),b=i.getDate(),_=i.getMonth()+1,l=i.getFullYear(),w=String(i.getHours()).padStart(2,"0"),$=String(i.getMinutes()).padStart(2,"0");return`${b}. ${_}. ${l} ${w}:${$}`}function $e(){const{id:o}=ue(),i=de(),{hasPermission:b,isAdmin:_}=ye(),l=xe(),w=je(),[$,Y]=r.useState(!0),[L,E]=r.useState(!1),[t,ae]=r.useState(null),[c,B]=r.useState({name:"",status:"aktivni",start_date:"",end_date:"",responsible_user_id:""}),[G,R]=r.useState([]),[Q,O]=r.useState(!1),[X,S]=r.useState(!1),[P,z]=r.useState(!1),[F,H]=r.useState([]),[W,M]=r.useState(!0),[C,U]=r.useState(""),[j,A]=r.useState(!1),[Z,I]=r.useState(null),T=r.useRef(!1);r.useEffect(()=>{w.state?.created&&!T.current&&(T.current=!0,i.success("Projekt byl vytvořen"),l(w.pathname,{replace:!0,state:{}}))},[w.state]);const J=async()=>{try{const s=await x(`${D}/projects.php?action=notes&id=${o}`);if(s.status===401)return;const d=await s.json();d.success&&H(d.data.notes||[])}catch{}finally{M(!1)}};if(r.useEffect(()=>{const s=async()=>{try{const h=await x(`${D}/projects.php?action=detail&id=${o}`);if(h.status===401)return;const f=await h.json();if(f.success){const y=f.data;ae(y),B({name:y.name||"",status:y.status||"aktivni",start_date:(y.start_date||"").substring(0,10),end_date:(y.end_date||"").substring(0,10),responsible_user_id:y.responsible_user_id||""})}else i.error(f.error||"Nepodařilo se načíst projekt"),l("/projects")}catch{i.error("Chyba připojení"),l("/projects")}finally{Y(!1)}},d=async()=>{try{const h=await x(`${D}/projects.php?action=users`);if(h.status===401)return;const f=await h.json();f.success&&R(f.data.users||[])}catch{}};s(),J(),d()},[o,i,l]),!b("projects.view"))return e.jsx(fe,{});const u=(s,d)=>B(h=>({...h,[s]:d})),g=async()=>{if(!c.name.trim()){i.error("Název projektu je povinný");return}E(!0);try{const d=await(await x(`${D}/projects.php?id=${o}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:c.name,status:c.status,start_date:c.start_date||null,end_date:c.end_date||null,responsible_user_id:c.responsible_user_id||null})})).json();d.success?i.success(d.message||"Projekt byl aktualizován"):i.error(d.error||"Nepodařilo se uložit projekt")}catch{i.error("Chyba připojení")}finally{E(!1)}},K=async()=>{S(!0);try{const d=await(await x(`${D}/projects.php?id=${o}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({delete_files:P})})).json();d.success?(l("/projects"),setTimeout(()=>i.success("Projekt byl smazán"),300)):i.error(d.error||"Nepodařilo se smazat projekt")}catch{i.error("Chyba připojení")}finally{S(!1)}},ee=async()=>{if(C.trim()){A(!0);try{const d=await(await x(`${D}/projects.php?action=add_note&id=${o}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:C.trim()})})).json();d.success?(H(h=>[d.data.note,...h]),U(""),i.success("Poznámka byla přidána")):i.error(d.error||"Nepodařilo se přidat poznámku")}catch{i.error("Chyba připojení")}finally{A(!1)}}},se=async s=>{I(s);try{const h=await(await x(`${D}/projects.php?action=delete_note¬eId=${s}`,{method:"DELETE"})).json();h.success?(H(f=>f.filter(y=>y.id!==s)),i.success("Poznámka byla smazána")):i.error(h.error||"Nepodařilo se smazat poznámku")}catch{i.error("Chyba připojení")}finally{I(null)}};if($)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 N=b("projects.edit");return e.jsxs("div",{children:[e.jsxs(q.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(re,{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]})})]}),N&&e.jsxs("div",{className:"admin-page-actions",children:[e.jsx("button",{onClick:g,className:"admin-btn admin-btn-primary",disabled:L,children:L?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:()=>O(!0),className:"admin-btn admin-btn-primary",children:"Smazat"})]})]}),e.jsx(q.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(k,{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(k,{label:"Název",children:e.jsx("input",{type:"text",value:c.name,onChange:s=>u("name",s.target.value),className:"admin-form-input",placeholder:"Název projektu",disabled:!N})})]}),e.jsxs("div",{className:"admin-form-row",children:[e.jsx(k,{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(k,{label:"Zodpovědná osoba",children:e.jsxs("select",{value:c.responsible_user_id,onChange:s=>u("responsible_user_id",s.target.value),className:"admin-form-select",disabled:!N,children:[e.jsx("option",{value:"",children:"— Nevybráno —"}),G.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(k,{label:"Stav",children:e.jsxs("select",{value:c.status,onChange:s=>u("status",s.target.value),className:"admin-form-select",disabled:!N,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(k,{label:"Datum zahájení",children:e.jsx(le,{mode:"date",value:c.start_date,onChange:s=>u("start_date",s),disabled:!N})}),e.jsx(k,{label:"Datum ukončení",children:e.jsx(le,{mode:"date",value:c.end_date,onChange:s=>u("end_date",s),disabled:!N})})]})]})]})}),e.jsx(q.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:C,onChange:s=>U(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&&C.trim()&&ee()}}),e.jsx("div",{className:"mt-2",children:e.jsx("button",{onClick:ee,className:"admin-btn admin-btn-secondary admin-btn-sm",disabled:j||!C.trim(),children:j?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})]}),W&&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))}),!W&&F.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"}),!W&&(F.length>0||t.notes)&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:F.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:ke(s.created_at)})]}),e.jsx("div",{style:{whiteSpace:"pre-wrap",fontSize:"0.875rem",lineHeight:1.5},children:s.content})]}),_&&e.jsx("button",{onClick:()=>se(s.id),className:"admin-btn-icon",title:"Smazat poznámku",disabled:Z===s.id,style:{flexShrink:0,opacity:Z===s.id?.5:1},children:Z===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(q.div,{style:{marginBottom:"1rem"},initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.4,delay:.2},children:e.jsx(ge,{projectId:o,projectNumber:t.project_number,hasPermission:b,hasNasFolder:t.has_nas_folder})}),e.jsx(q.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(k,{label:"Objednávka",children:e.jsx("div",{children:t.order_id?e.jsxs(re,{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:["(",Ne[t.order_status]||t.order_status,")"]})]}):"—"})}),e.jsx(k,{label:"Nabídka",children:e.jsx("div",{children:t.quotation_id?e.jsx(re,{to:`/offers/${t.quotation_id}`,className:"link-accent",children:t.quotation_number}):"—"})})]})]})}),e.jsx(ce,{isOpen:Q,onClose:()=>{O(!1),z(!1)},onConfirm:K,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:P,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{$e as default};
|