import{H as k}from"./HeaderBreadcrumbs.da67f38c.js";import{P as z}from"./Page.4c1db0aa.js";import{al as y,bi as C,aQ as O,a as R,ar as p,r as u,j as i,S as T,f as e,i as _,aq as b,P as H,as as W,g as q,ay as A,B as F,T as Q,az as G}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{B as V}from"./BasePagination.56fc59df.js";import{C as D}from"./Card.1ec83a31.js";import{T as X}from"./TableContainer.b8d5000e.js";import{T as Y,a as m,b as c,c as a}from"./TableRow.d2ef76cd.js";import"./jsx-runtime_commonjs-proxy.e03e6edd.js";function Z(){y();const{corporate_id:s}=C(),[d,v]=O();R();function B(t){const n=u.exports.useRef(null),[r,h]=u.exports.useState(""),j=o=>{var x;const $=(x=o.target.value)!=null?x:"";h($)},L=o=>{o.preventDefault(),t.onSearch(r)};return u.exports.useEffect(()=>{var o;h((o=d.get("search"))!=null?o:"")},[d]),e("form",{onSubmit:L,style:{width:"100%"},children:e(W,{id:"search-input",ref:n,label:"Search",variant:"outlined",fullWidth:!0,onChange:j,value:r})})}function P(t){const{row:n}=t,[r,h]=p.useState(!1);return i(p.Fragment,{children:[i(c,{sx:{"& > *":{borderBottom:"unset"}},children:[e(a,{children:e(q,{"aria-label":"expand row",size:"small",onClick:()=>h(!r),children:r?e(K,{}):e(M,{})})}),e(a,{align:"left",children:n.id}),e(a,{align:"left",children:n.code}),e(a,{align:"left",children:n.name}),e(a,{align:"left",children:n.description}),e(a,{align:"right",children:e(b,{variant:"outlined",color:"success",size:"small",children:"Active"})}),e(a,{align:"right",children:e(_,{to:`/corporates/${n.corporate_id}/divisions/${n.id}/edit`,children:e(b,{variant:"outlined",color:"success",size:"small",children:"Edit"})})})]}),e(c,{children:e(a,{style:{paddingBottom:0,paddingTop:0},colSpan:10,children:i(A,{in:r,timeout:"auto",unmountOnExit:!0,children:[e(F,{sx:{borderBottom:1},children:e(Q,{variant:"body2",gutterBottom:!0,component:"div",children:"No Extra Data"})}),!1]})})})]})}const[w,S]=p.useState(!0),[g,E]=p.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}),f=async(t=null)=>{S(!0);const n=t||Object.fromEntries([...d.entries()]),r=await G.get("/corporates/"+s+"/divisions",{params:n});S(!1),E(r.data)},l={fontWeight:"bold"},I=async t=>{await f({search:t}),v({search:t})},N=(t,n)=>{const r=Object.fromEntries([...d.entries(),["page",n]]);f(r),v(r)};return u.exports.useEffect(()=>{f()},[]),i(T,{children:[i(T,{direction:"row",spacing:2,sx:{p:2},children:[e(B,{onSearch:I}),e(_,{to:`/corporates/${s}/divisions/create`,children:e(b,{component:"button",id:"upload-button",variant:"outlined",startIcon:e(U,{}),sx:{p:1.8},children:"Create"})})]}),i(D,{children:[e(X,{component:H,children:i(Y,{"aria-label":"collapsible table",children:[e(m,{children:i(c,{children:[e(a,{style:l,align:"left"}),e(a,{style:l,align:"left",children:"ID"}),e(a,{style:l,align:"left",children:"Code"}),e(a,{style:l,align:"left",children:"Name"}),e(a,{style:l,align:"left",children:"Description"})]})}),w?e(m,{children:e(c,{children:e(a,{colSpan:8,align:"center",children:"Loading"})})}):g.data.length==0?e(m,{children:e(c,{children:e(a,{colSpan:8,align:"center",children:"No Data"})})}):e(m,{children:g.data.map(t=>e(P,{row:t},t.code))})]})}),e(V,{paginationData:g,onPageChange:N})]})]})}function he(){y();const{corporate_id:s}=C();return i(z,{title:"Division",children:[e(k,{heading:"Division",links:[{name:"Corporates",href:"/corporates"},{name:"Corporate Name",href:"/corporates/"+s},{name:"Division",href:"/corporates/"+s+"/divisions"}]}),i(D,{children:[e(J,{position:"divisions"}),e(Z,{})]})]})}export{he as default};
