import{P as K}from"./Page.b1f38576.js";import{n as Q,r as a,Z as X,$ as ee,a0 as _,j as s,f as g,F as te,a4 as ae,S as re,m as O,Y as se,a2 as ne}from"./index.4524613b.js";import{T as oe}from"./Table.b404960e.js";import{f as P}from"./formatTime.0646b9d0.js";import{T as ie}from"./TableMoreMenu.fbaa38aa.js";import{d as ce}from"./VisibilityOutlined.7d63b3a6.js";import{L as j}from"./Label.c0ab61c4.js";import{H as le}from"./HeaderBreadcrumbs.f593a2a7.js";import{G as v}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";import"./index.49ea62c1.js";import"./jsx-runtime_commonjs-proxy.08daee49.js";function de(){const d=Q(),{corporateValue:m}=a.exports.useContext(X),[y,T]=a.exports.useState([]),[w,p]=a.exports.useState(!0),V={isLoading:w,setIsLoading:p},[t,S]=ee(),[i,n]=a.exports.useState({}),k={searchParams:t,setSearchParams:S,appliedParams:i,setAppliedParams:n},[u,I]=a.exports.useState("desc"),[h,F]=a.exports.useState("request_date"),L={order:u,setOrder:I,orderBy:h,setOrderBy:F},[M,x]=a.exports.useState(0),[A,D]=a.exports.useState(10),[b,E]=a.exports.useState({current_page:0,from:0,last_page:0,links:[],path:"",per_page:0,to:0,total:0}),B={page:M,setPage:x,rowsPerPage:A,setRowsPerPage:D,paginationTable:b,setPaginationTable:E},[f,G]=a.exports.useState(""),R={useSearchs:!0,searchText:f,setSearchText:G,handleSearchSubmit:async r=>{if(r.preventDefault(),f===""){t.delete("search");const e=Object.fromEntries([...t.entries()]);n(e)}else{const e=Object.fromEntries([...t.entries(),["search",f]]);n(e)}}},[C,N]=a.exports.useState("all"),[q,z]=a.exports.useState([]),H={useFilter:!1,config:{label:"Status",statusValue:C,statusData:q,handleStatusChange:r=>{if(N(r.target.value),r.target.value==="all"){t.delete("status");const e=Object.fromEntries([...t.entries()]);n(e)}else{const e=Object.fromEntries([...t.entries(),["status",r.target.value]]);n(e)}}}},[c,$]=a.exports.useState(""),U={useFilter:!0,startDate:c,setStartDate:$,handleStartDateChange:async r=>{if(r.preventDefault(),c===""){t.delete("start_date");const e=Object.fromEntries([...t.entries()]);n(e)}else{const e=Object.fromEntries([...t.entries(),["start_date",c]]);n(e)}}},[l,W]=a.exports.useState(""),Y={useFilter:!0,endDate:l,setEndDate:W,handleEndDateChange:async r=>{if(r.preventDefault(),l===""){t.delete("end_date");const e=Object.fromEntries([...t.entries()]);n(e)}else{const e=Object.fromEntries([...t.entries(),["end_date",l]]);n(e)}}},Z={useExport:!0,startDate:c,endDate:l,status:C,handleExportReport:async()=>{var r=Object.fromEntries([...t.entries()]);await _.get(m+"/claims/export",{params:r}).then(e=>{O("Data berhasil di Export",{variant:"success",anchorOrigin:{horizontal:"right",vertical:"top"}}),document.location.href=e.data.data.file_url}).catch(e=>O("Data Gagal di Export",{variant:"error",anchorOrigin:{horizontal:"right",vertical:"top"}}))}},J=[{id:"memberId",align:"left",label:"Member ID",isSort:!0},{id:"fullName",align:"left",label:"Name",isSort:!0},{id:"start_date",align:"center",label:"Start Date",isSort:!0},{id:"end_date",align:"center",label:"End Date",isSort:!0},{id:"action",align:"center",label:"",isSort:!1}];return a.exports.useEffect(()=>{(async()=>{p(!0),await new Promise(o=>setTimeout(o,250));const r=Object.keys(i).length!==0?i:Object.fromEntries([...t.entries(),["order",u],["orderBy",h]]),e=await _.get(`${m}/members?type=alarm-center`,{params:{...r}});if(z([{id:1,name:"Done"},{id:0,name:"On Going"}]),T(e.data.data.map(o=>({...o,start_date:s(j,{children:P(o.start_date)}),end_date:g(j,{children:[" ",P(o.end_date)]}),action:s(ie,{actions:s(te,{children:g(ae,{onClick:()=>d("member/"+o.id),children:[s(ce,{}),"View"]})})})}))),E(e.data),D(e.data.per_page),t.get("page")){const o=parseInt(t.get("page"))-1;b.current_page=o,x(o)}p(!1)})()},[i,t,u,h,S,m]),s(re,{children:s(oe,{headCells:J,rows:y,orders:L,paginations:B,loadings:V,params:k,searchs:R,filterStatus:H,filterStartDate:U,filterEndDate:Y,exportReport:Z})})}function Ge(){const{themeStretch:d}=se();return s(K,{title:"Alarm Center",children:g(ne,{maxWidth:d?!1:"xl",children:[s(le,{heading:"Alarm Center",links:[{name:"Case Management",href:"/alarm-center"},{name:"Alarm Center",href:"/alarm-center"}]}),s(v,{container:!0,children:s(v,{item:!0,xs:12,lg:12,md:12,children:s(de,{})})})]})})}export{Ge as default};
