import{Y as U,r as e,Z as W,$ as Z,a0 as k,j as s,G as P,a1 as c,f as q,a2 as z,T as H}from"./index.4524613b.js";import{P as J}from"./Page.b1f38576.js";import{T as K}from"./Table.b404960e.js";import{S as Q}from"./Stack.2fe98e42.js";import{G as C}from"./Grid.63392dc1.js";import"./Box.522fc68e.js";import"./TablePagination.a2995130.js";import"./KeyboardArrowRight.dfbe216b.js";import"./LastPage.928f2cf3.js";import"./TableRow.184bd340.js";import"./useId.5c752e65.js";import"./TextField.489cf1ea.js";import"./InputAdornment.c3b5c49a.js";import"./Search.a632f4d1.js";import"./TableContainer.e4a601db.js";import"./TableHead.2295a13e.js";function fe(){const{themeStretch:D}=U(),{corporateValue:l}=e.exports.useContext(W),p=new AbortController,[y,j]=e.exports.useState([]),[O,d]=e.exports.useState(!0),T={isLoading:O,setIsLoading:d},[t,m]=Z(),[n,o]=e.exports.useState({}),w={searchParams:t,setSearchParams:m,appliedParams:n,setAppliedParams:o},[u,E]=e.exports.useState("asc"),[g,I]=e.exports.useState("fullName"),_={order:u,setOrder:E,orderBy:g,setOrderBy:I},[B,f]=e.exports.useState(0),[A,S]=e.exports.useState(10),[x,v]=e.exports.useState({current_page:0,from:0,last_page:0,links:[],path:"",per_page:0,to:0,total:0}),G={page:B,setPage:f,rowsPerPage:A,setRowsPerPage:S,paginationTable:x,setPaginationTable:v},[h,N]=e.exports.useState(""),R={useSearchs:!1,searchText:h,setSearchText:N,handleSearchSubmit:async r=>{if(r.preventDefault(),h===""){t.delete("search");const a=Object.fromEntries([...t.entries()]);o(a)}else{const a=Object.fromEntries([...t.entries(),["search",h]]);o(a)}}},[V,Y]=e.exports.useState("all"),[$,L]=e.exports.useState([]),M={useFilter:!0,config:{label:"Division",divisionValue:V,divisionData:$,handleDivisionChange:r=>{if(Y(r.target.value),r.target.value==="all"){t.delete("division");const a=Object.fromEntries([...t.entries()]);o(a)}else{const a=Object.fromEntries([...t.entries(),["division",r.target.value]]);o(a)}}}},F=[{id:"memberId",align:"left",label:"Member ID",isSort:!0},{id:"fullName",align:"center",label:"Name",isSort:!0},{id:"division",align:"center",label:"Divisi",isSort:!0},{id:"status",align:"center",label:"Status",isSort:!0},{id:"action",align:"right",label:"",isSort:!1}];return e.exports.useEffect(()=>((async()=>{try{d(!0);const r=Object.keys(n).length!==0?n:Object.fromEntries([...t.entries(),["order",u],["orderBy",g]]),[a,b]=await Promise.all([k.get(`${l}/division`,{signal:p.signal}),k.get(`${l}/members`,{params:{...r},signal:p.signal})]);if(m(r),L(a.data),j(b.data.data.map(i=>({...i,status:i.status===1?s(P,{sx:{backgroundColor:"rgba(84, 214, 44, 0.16)",color:c.dark.success.dark,paddingY:0,"&:hover":{backgroundColor:"rgba(84, 214, 44, 0.32)",color:c.dark.success.darker}},children:"Active"}):s(P,{sx:{backgroundColor:"rgba(255, 72, 66, 0.16)",color:c.dark.error.dark,paddingY:0,"&:hover":{backgroundColor:"rgba(255, 72, 66, 0.32)",color:c.dark.error.darker}},children:"Inactive"})}))),v(b.data),S(b.data.per_page),t.get("page")){const i=parseInt(t.get("page"))-1;x.current_page=i,f(i)}d(!1)}catch(r){console.error("Error fetching data:",r.message)}})(),()=>{p.abort()}),[n,t,u,g,m,l]),s(J,{title:"Dashboard",children:q(z,{maxWidth:D?!1:"xl",children:[s(Q,{direction:"row",justifyContent:"space-between",children:s(H,{variant:"h3",component:"h1",paragraph:!0,children:"Dashboard"})}),s(C,{container:!0,spacing:2,children:s(C,{item:!0,xs:12,lg:12,md:12,children:s(K,{headCells:F,rows:y,orders:_,paginations:G,loadings:T,params:w,searchs:R,filters:M})})})]})})}export{fe as default};
