import{aX as y,r as n,j as t,G as a,o as i,t as h,ac as p,ah as T,B as u,T as v,k as j}from"./vendor-BuNhBR-q.js";import{B as k,P as A}from"./ParentCard-DFHA8fzx.js";import{P as C}from"./index-DzxWaMzc.js";const B=()=>{const{id:r}=y(),[e,g]=n.useState(null),[c,o]=n.useState(""),[l,d]=n.useState(null),x=async()=>{const s=await j.get(`/api/tasks/${r}`);g(s.data)};n.useEffect(()=>{x()},[r]);const f=async()=>{const s=new FormData;s.append("type",l?"ATTACHMENT":"COMMENT"),s.append("message",c),l&&s.append("attachment",l),await j.post(`/api/tasks/${r}/activity`,s),o(""),d(null),x()};return e?t.jsxs(C,{children:[t.jsx(k,{title:"TASK DETAILS",items:[{to:"/",title:"Dashboard"},{to:"/tasks",title:"Tasks"},{title:"View"}]}),t.jsx(A,{children:t.jsxs(a,{container:!0,spacing:3,children:[t.jsxs(a,{item:!0,xs:12,children:[t.jsx(i,{variant:"h5",children:e.title}),t.jsx(i,{color:"text.secondary",children:e.description||"-"}),t.jsxs(h,{mt:1,children:[t.jsx(p,{label:e.status}),t.jsx(p,{label:e.priority,sx:{ml:1}})]})]}),t.jsx(a,{item:!0,xs:12,children:t.jsx(T,{})}),t.jsxs(a,{item:!0,xs:12,children:[t.jsx(i,{fontWeight:600,mb:1,children:"Activity"}),e.activities.map(s=>t.jsxs(h,{mb:2,children:[t.jsxs(i,{variant:"caption",children:[s.type," • ",s.created_at]}),s.message&&t.jsx(i,{children:s.message}),s.attachment_path&&t.jsx(u,{size:"small",href:`/storage/${s.attachment_path}`,target:"_blank",children:s.attachment_name})]},s.id))]}),t.jsxs(a,{item:!0,xs:12,children:[t.jsx(v,{fullWidth:!0,size:"small",placeholder:"Add comment",value:c,onChange:s=>o(s.target.value)}),t.jsx("input",{type:"file",onChange:s=>{var m;return d(((m=s.target.files)==null?void 0:m[0])||null)}}),t.jsx(u,{variant:"contained",sx:{mt:1},onClick:f,children:"Add Activity"})]})]})})]}):null};export{B as default};
