window.open() neposílá JWT header, přepsáno na apiFetch() + blob download. 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 G}from"./vendor-animation-0s3FMHwK.js";import{r,h as ue,g as xe,u as je,L as ie}from"./vendor-react-BVs3cwbi.js";import{a as de,c as u,C as ce,u as ye,F as w,A as le}from"./index-Bay45BGf.js";import{F as fe}from"./Forbidden-D25jV3Oq.js";import"./vendor-utils-Dyr8OjFr.js";const E="/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(),S=r.useRef(null),[M,Q]=r.useState([]),[R,B]=r.useState(!0),[t,ne]=r.useState(""),[m,O]=r.useState([""]),[X,U]=r.useState(!1),[ee,W]=r.useState(!1),[ae,z]=r.useState(!1),[F,C]=r.useState(""),[L,H]=r.useState(!1),[Z,D]=r.useState(null),[_,I]=r.useState(""),[y,A]=r.useState(null),[J,K]=r.useState(!1),[T,q]=r.useState(null),x=b("projects.files"),g=r.useCallback(async(a="",n={})=>{B(!0),q(null);try{const p=new URLSearchParams({project_id:o});a&&p.set("path",a);const c=await u(`${E}/project-files.php?${p}`);if(n.ignore||c.status===401)return;const j=await c.json();j.success?(Q(j.data.items||[]),O(j.data.breadcrumb||[""]),ne(j.data.path||"")):c.status===404?(Q([]),O([""])):q(j.error||"Nepodařilo se načíst soubory")}catch{n.ignore||q("Chyba připojení")}finally{n.ignore||B(!1)}},[o]);r.useEffect(()=>{const a={ignore:!1};return g("",a),()=>{a.ignore=!0}},[g]);const Y=a=>{z(!1),D(null),g(a)},se=a=>{if(a===0){Y("");return}const n=m.slice(1,a+1).join("/");Y(n)},re=a=>{const n=t?`${t}/${a}`:a;Y(n)},N=async a=>{if(!a||a.length===0)return;W(!0);let n=0,p=null;for(const c of a){const j=new FormData;j.append("file",c);const V=new URLSearchParams({action:"upload",project_id:o});t&&V.set("path",t);try{const te=await(await u(`${E}/project-files.php?${V}`,{method:"POST",body:j})).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),g(t)}p&&l.error(p)},s=a=>{N(a.target.files),a.target.value=""},d=a=>{a.preventDefault(),U(!1),x&&N(a.dataTransfer.files)},h=a=>{a.preventDefault(),x&&U(!0)},v=a=>{a.preventDefault(),U(!1)},f=async()=>{const a=F.trim();if(a){H(!0);try{const n=new URLSearchParams({action:"create_folder",project_id:o}),c=await(await u(`${E}/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),C(""),g(t)):l.error(c.error||"Nepodařilo se vytvořit složku")}catch{l.error("Chyba připojení")}finally{H(!1)}}},me=async a=>{const n=t?`${t}/${a.name}`:a.name,p=new URLSearchParams({action:"download",project_id:o,path:n});try{const c=await u(`${E}/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 j=await c.blob(),V=URL.createObjectURL(j),k=document.createElement("a");k.href=V,k.download=a.name,document.body.appendChild(k),k.click(),k.remove(),URL.revokeObjectURL(V)}catch{l.error("Chyba připojení")}},he=async()=>{if(!y)return;K(!0);const a=t?`${t}/${y.name}`:y.name;try{const n=new URLSearchParams({project_id:o,path:a}),c=await(await u(`${E}/project-files.php?${n}`,{method:"DELETE"})).json();c.success?(l.success(y.type==="folder"?"Složka byla smazána":"Soubor byl smazán"),g(t)):l.error(c.error||"Nepodařilo se smazat")}catch{l.error("Chyba připojení")}finally{K(!1),A(null)}},oe=async a=>{const n=_.trim();if(!n||n===a.name){D(null);return}const p=t?`${t}/${a.name}`:a.name,c=t?`${t}/${n}`:n;try{const j=new URLSearchParams({action:"move",project_id:o}),k=await(await u(`${E}/project-files.php?${j}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({from_path:p,to_path:c})})).json();k.success?(l.success("Přejmenováno"),g(t)):l.error(k.error||"Nepodařilo se přejmenovat")}catch{l.error("Chyba připojení")}finally{D(null)}},pe=a=>{D(a.name),I(a.name)};return R&&M.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: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:()=>se(n),children:n===0?i:a})]},n))}),x&&e.jsxs("div",{className:"fm-toolbar-actions",children:[e.jsxs("button",{type:"button",className:"admin-btn admin-btn-secondary admin-btn-sm",onClick:()=>{z(!ae),C("")},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:ee,children:ee?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:s})]})]}),ae&&e.jsxs("div",{className:"fm-new-folder",children:[e.jsx("input",{type:"text",value:F,onChange:a=>C(a.target.value),className:"admin-form-input",placeholder:"Název složky...",autoFocus:!0,onKeyDown:a=>{a.key==="Enter"&&f(),a.key==="Escape"&&(z(!1),C(""))},style:{fontSize:"12px",padding:"6px 10px"}}),e.jsx("button",{type:"button",className:"admin-btn admin-btn-primary admin-btn-sm",onClick:f,disabled:L||!F.trim(),children:L?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),C("")},children:"Zrušit"})]}),e.jsxs("div",{className:`fm-content ${X?"fm-drag-over":""}`,onDrop:d,onDragOver:h,onDragLeave:v,children:[X&&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"})]}),M.length===0&&!R?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"}),x&&!$&&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"}),x&&e.jsx("th",{style:{width:"100px",textAlign:"right"},children:"Akce"})]})}),e.jsx("tbody",{children:M.map(a=>e.jsxs("tr",{children:[e.jsx("td",{style:{textAlign:"center"},children:ve(a.type,a.extension)}),e.jsx("td",{children:Z===a.name?e.jsx("input",{type:"text",value:_,onChange:n=>I(n.target.value),className:"admin-form-input",style:{fontSize:"11px",padding:"3px 8px",maxWidth:"300px"},autoFocus:!0,onKeyDown:n=>{n.key==="Enter"&&oe(a),n.key==="Escape"&&D(null)},onBlur:()=>oe(a)}):e.jsx(be,{item:a,onFolderClick:re})}),e.jsx("td",{className:"fm-meta",children:a.type==="file"?a.size_formatted:"—"}),e.jsx("td",{className:"fm-meta",children:a.modified||"—"}),x&&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:y!==null,onClose:()=>A(null),onConfirm:he,title:y?.type==="folder"?"Smazat složku":"Smazat soubor",message:`Opravdu chcete smazat "${y?.name}"?${y?.type==="folder"?" Složka bude smazána včetně veškerého obsahu.":""}`,confirmText:"Smazat",cancelText:"Zrušit",type:"danger",loading:J})]})}const P="/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(),S=String(i.getHours()).padStart(2,"0"),M=String(i.getMinutes()).padStart(2,"0");return`${b}. ${$}. ${l} ${S}:${M}`}function $e(){const{id:o}=ue(),i=de(),{hasPermission:b,isAdmin:$}=ye(),l=xe(),S=je(),[M,Q]=r.useState(!0),[R,B]=r.useState(!1),[t,ne]=r.useState(null),[m,O]=r.useState({name:"",status:"aktivni",start_date:"",end_date:"",responsible_user_id:""}),[X,U]=r.useState([]),[ee,W]=r.useState(!1),[ae,z]=r.useState(!1),[F,C]=r.useState(!1),[L,H]=r.useState([]),[Z,D]=r.useState(!0),[_,I]=r.useState(""),[y,A]=r.useState(!1),[J,K]=r.useState(null),T=r.useRef(!1);r.useEffect(()=>{S.state?.created&&!T.current&&(T.current=!0,i.success("Projekt byl vytvořen"),l(S.pathname,{replace:!0,state:{}}))},[S.state]);const q=async()=>{try{const s=await u(`${P}/projects.php?action=notes&id=${o}`);if(s.status===401)return;const d=await s.json();d.success&&H(d.data.notes||[])}catch{}finally{D(!1)}};if(r.useEffect(()=>{const s=async()=>{try{const h=await u(`${P}/projects.php?action=detail&id=${o}`);if(h.status===401)return;const v=await h.json();if(v.success){const f=v.data;ne(f),O({name:f.name||"",status:f.status||"aktivni",start_date:(f.start_date||"").substring(0,10),end_date:(f.end_date||"").substring(0,10),responsible_user_id:f.responsible_user_id||""})}else i.error(v.error||"Nepodařilo se načíst projekt"),l("/projects")}catch{i.error("Chyba připojení"),l("/projects")}finally{Q(!1)}},d=async()=>{try{const h=await u(`${P}/projects.php?action=users`);if(h.status===401)return;const v=await h.json();v.success&&U(v.data.users||[])}catch{}};s(),q(),d()},[o,i,l]),!b("projects.view"))return e.jsx(fe,{});const x=(s,d)=>O(h=>({...h,[s]:d})),g=async()=>{if(!m.name.trim()){i.error("Název projektu je povinný");return}B(!0);try{const d=await(await u(`${P}/projects.php?id=${o}`,{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?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{B(!1)}},Y=async()=>{z(!0);try{const d=await(await u(`${P}/projects.php?id=${o}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({delete_files:F})})).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{z(!1)}},se=async()=>{if(_.trim()){A(!0);try{const d=await(await u(`${P}/projects.php?action=add_note&id=${o}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:_.trim()})})).json();d.success?(H(h=>[d.data.note,...h]),I(""),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)}}},re=async s=>{K(s);try{const h=await(await u(`${P}/projects.php?action=delete_note¬eId=${s}`,{method:"DELETE"})).json();h.success?(H(v=>v.filter(f=>f.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{K(null)}};if(M)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(G.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]})})]}),N&&e.jsxs("div",{className:"admin-page-actions",children:[e.jsx("button",{onClick:g,className:"admin-btn admin-btn-primary",disabled:R,children:R?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:()=>W(!0),className:"admin-btn admin-btn-primary",children:"Smazat"})]})]}),e.jsx(G.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=>x("name",s.target.value),className:"admin-form-input",placeholder:"Název projektu",disabled:!N})})]}),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=>x("responsible_user_id",s.target.value),className:"admin-form-select",disabled:!N,children:[e.jsx("option",{value:"",children:"— Nevybráno —"}),X.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=>x("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(w,{label:"Datum zahájení",children:e.jsx(le,{mode:"date",value:m.start_date,onChange:s=>x("start_date",s),disabled:!N})}),e.jsx(w,{label:"Datum ukončení",children:e.jsx(le,{mode:"date",value:m.end_date,onChange:s=>x("end_date",s),disabled:!N})})]})]})]})}),e.jsx(G.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:_,onChange:s=>I(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&&_.trim()&&se()}}),e.jsx("div",{className:"mt-2",children:e.jsx("button",{onClick:se,className:"admin-btn admin-btn-secondary admin-btn-sm",disabled:y||!_.trim(),children:y?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})]}),Z&&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))}),!Z&&L.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"}),!Z&&(L.length>0||t.notes)&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:L.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:()=>re(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(G.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(G.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:["(",Ne[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(ce,{isOpen:ee,onClose:()=>{W(!1),C(!1)},onConfirm:Y,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:F,onChange:s=>C(s.target.checked)}),e.jsx("span",{children:"Smazat i soubory na disku"})]})]}),confirmText:"Smazat",cancelText:"Zrušit",type:"danger",loading:ae})]})}export{$e as default};
|