import{H as $}from"./HeaderBreadcrumbs.da67f38c.js";import{P as j}from"./Page.4c1db0aa.js";import{al as y,bi as P,aQ as R,a as G,ar as u,r as h,j as o,S as _,f as e,i as D,aq as f,P as H,as as O,g as A,ay as W,B as q,T as F,az as Q}from"./index.8f299a7d.js";import{C as J}from"./CorporateTabNavigations.42a351a3.js";import{d as K,a as M}from"./KeyboardArrowRight.3ee3e2fb.js";import{d as U}from"./Add.06de942b.js";import{C as b}from"./Card.1ec83a31.js";import{T as V}from"./TableContainer.b8d5000e.js";import{T as X,a as m,b as d,c as t}from"./TableRow.d2ef76cd.js";import{G as g}from"./Grid.358b274d.js";import"./jsx-runtime_commonjs-proxy.e03e6edd.js";function Y(a){return a==null?void 0:a.replace(/(<([^>]+)>)/gi,"")}function Z(a,i=50){return a==null?void 0:a.substring(0,i)}function ee(a,i=50){return Z(Y(a!=null?a:""),i)}function ae(){y();const{corporate_id:a}=P(),[i,S]=R();G();function B(r){const n=h.exports.useRef(null),[l,p]=h.exports.useState(""),k=s=>{var v;const L=(v=s.target.value)!=null?v:"";p(L)},z=s=>{s.preventDefault(),r.onSearch(l)};return h.exports.useEffect(()=>{var s;p((s=i.get("search"))!=null?s:"")},[i]),e("form",{onSubmit:z,style:{width:"100%"},children:e(O,{id:"search-input",ref:n,label:"Search",variant:"outlined",fullWidth:!0,onChange:k,value:l})})}function w(r){const{row:n}=r,[l,p]=u.useState(!1);return o(u.Fragment,{children:[o(d,{sx:{"& > *":{borderBottom:"unset"}},children:[e(t,{children:e(A,{"aria-label":"expand row",size:"small",onClick:()=>p(!l),children:l?e(K,{}):e(M,{})})}),e(t,{align:"left",children:n.id}),e(t,{align:"left",children:n.code}),e(t,{align:"left",children:n.name}),e(t,{align:"left",children:ee(n.description)}),n.active?e(t,{align:"right",children:e(f,{variant:"outlined",color:"success",size:"small",children:"Active"})}):e(t,{align:"right",children:e(f,{variant:"outlined",color:"error",size:"small",children:"Inactive"})}),e(t,{align:"right",children:e(D,{to:`/corporates/${n.corporate_id}/corporate-plans/${n.id}/edit`,children:e(f,{variant:"outlined",color:"success",size:"small",children:"Edit"})})})]}),e(d,{children:e(t,{style:{paddingBottom:0,paddingTop:0},colSpan:10,children:o(W,{in:l,timeout:"auto",unmountOnExit:!0,children:[e(q,{sx:{borderBottom:1},children:e(F,{variant:"body2",gutterBottom:!0,component:"div",children:"No Extra Data"})}),!1]})})})]})}const[E,x]=u.useState(!0),[T,I]=u.useState({current_page:1,data:[],path:"",first_page_url:"",last_page:1,last_page_url:"",next_page_url:"",prev_page_url:"",per_page:10,from:0,to:0,total:0}),C=async(r=null)=>{x(!0);const n=r||Object.fromEntries([...i.entries()]),l=await Q.get("/corporates/"+a+"/corporate-plans",{params:n});x(!1),I(l.data)},c={fontWeight:"bold"},N=async r=>{await C({search:r}),S({search:r})};return h.exports.useEffect(()=>{C()},[]),o(_,{children:[o(_,{direction:"row",spacing:2,sx:{p:2},children:[e(B,{onSearch:N}),e(D,{to:`/corporates/${a}/corporate-plans/create`,children:e(f,{component:"button",id:"upload-button",variant:"outlined",startIcon:e(U,{}),sx:{p:1.8},children:"Create"})})]}),e(b,{children:e(V,{component:H,children:o(X,{"aria-label":"collapsible table",children:[e(m,{children:o(d,{children:[e(t,{style:c,align:"left"}),e(t,{style:c,align:"left",children:"ID"}),e(t,{style:c,align:"left",children:"Code"}),e(t,{style:c,align:"left",children:"Name"}),e(t,{style:c,align:"left",children:"Description"})]})}),E?e(m,{children:e(d,{children:e(t,{colSpan:8,align:"center",children:"Loading"})})}):T.data.length==0?e(m,{children:e(d,{children:e(t,{colSpan:8,align:"center",children:"No Data"})})}):e(m,{children:T.data.map(r=>e(w,{row:r},r.code))})]})})})]})}function he(){y();const{corporate_id:a}=P();return o(j,{title:"Corporate Plan",children:[e($,{heading:"Corporate Plan",links:[{name:"Corporates",href:"/corporates"},{name:"Corporate Name",href:"/corporates/"+a},{name:"Corporate Plan",href:"/corporates/"+a+"/corporate-plans"}]}),o(g,{container:!0,spacing:2,children:[e(g,{item:!0,xs:8,children:o(b,{children:[e(J,{position:"corporate-plans"}),e(ae,{})]})}),e(g,{item:!0,xs:4,children:e(b,{sx:{p:2},children:"Corporate Detail Goes Here \xA0"})})]})]})}export{he as default};
