Files
2024-10-19 18:17:42 +00:00

2 lines
1.5 KiB
JavaScript

import{O as C,bO as D,e6 as R,a3 as S,a4 as E,p as c,u as O,h as i,c as o,bP as k,ar as V,j as b,T as _,a6 as $,ds as w,bQ as Q,bR as U,av as q,ag as u,r as B,e as F,bs as H}from"./bundle.js";import{a as L}from"./bundle431.js";import"./bundle432.js";function G(){const{documentTitle:p,setDocumentTitle:j}=C("project"),{id:a}=D(),{data:s}=R({id:a}),m=S(),h=E(),f=L(),[e,l]=c.useState(),[T,r]=c.useState(),[n]=O();c.useEffect(()=>{s!=null&&s.name&&j(s.name),s&&l(s)},[s]);const g=[{name:n("projects"),href:"/projects"},{name:p,href:i("/projects/:id",{id:a})}],v=[{name:n("edit"),href:i("/projects/:id/edit",{id:a})},{name:n("documents"),href:i("/projects/:id/documents",{id:a}),enabled:m("view_project")||m("edit_project")||h(e),formatName:()=>{var t;return o(k,{numberOfDocuments:(t=e==null?void 0:e.documents)==null?void 0:t.length})}}],P=()=>{u.processing(),r(void 0),B("PUT",F("/api/v1/projects/:id",{id:a}),e).then(()=>{u.success("updated_project"),H(["projects"])}).catch(t=>{var d;((d=t.response)==null?void 0:d.status)==422&&(u.dismiss(),r(t.response.data))})},{changeTemplateVisible:x,setChangeTemplateVisible:y,changeTemplateResources:A}=V();return b(_,{title:p,breadcrumbs:g,disableSaveButton:!e,navigationTopRight:e&&o($,{resource:e,onSaveClick:P,actions:f,cypressRef:"projectActionDropdown"}),children:[b(w,{breadcrumbs:[],children:[o(Q,{tabs:v}),o(U,{context:{errors:T,setErrors:r,project:e,setProject:l}})]}),o(q,{entity:"project",entities:A,visible:x,setVisible:y,labelFn:t=>`${n("number")}: ${t.number}`,bulkUrl:"/api/v1/projects/bulk"})]})}export{G as default};