2 lines
6.9 KiB
JavaScript
2 lines
6.9 KiB
JavaScript
import{H as ee}from"./HeaderBreadcrumbs.72d014d8.js";import{P as te}from"./Page.0794b7b5.js";import{ak as z,bg as A,bj as ae,r as h,aq as m,j as r,S as v,f as e,P as ne,ay as j,ap as f,bl as le,aw as $,B as S,g as re,ax as ie,T as oe,ar as se}from"./index.c6caea74.js";import{C as ce}from"./CorporateTabNavigations.6fca605a.js";import{d as de,a as pe}from"./KeyboardArrowRight.9a4a7a08.js";import{d as he}from"./Add.a61e4a70.js";import{d as ue}from"./Upload.d90b1ada.js";import{B as me,d as fe}from"./Cancel.db4eedbc.js";import{B as ge}from"./BasePagination.e17a7f3e.js";import{C as O}from"./Card.efaf006e.js";import{T as be,a as _e,b as T,c as _,d as a}from"./TableRow.4334ace3.js";import"./jsx-runtime_commonjs-proxy.c42f6aa5.js";function xe(){z();const{corporate_id:g}=A(),[x,D]=ae(),[b,H]=h.exports.useState(null),[U,P]=m.useState(!0),[I,q]=m.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}),y=async(n=null)=>{P(!0);const t=n||Object.fromEntries([...x.entries()]),i=await j.get("/corporates/"+g+"/members",{params:t});P(!1),q(i.data)},G=async n=>{await y({search:n}),D({search:n})},K=(n,t)=>{const i=Object.fromEntries([...x.entries(),["page",t]]);y(i),D(i)};h.exports.useEffect(()=>{y()},[]);function J(n){const t=h.exports.useRef(null),[i,d]=h.exports.useState(""),l=o=>{var c;const u=(c=o.target.value)!=null?c:"";d(u)},s=o=>{o.preventDefault(),n.onSearch(i)};return h.exports.useEffect(()=>{var o;d((o=x.get("search"))!=null?o:"")},[x]),e("form",{onSubmit:s,style:{width:"100%"},children:e(se,{id:"search-input",ref:t,label:"Search",variant:"outlined",fullWidth:!0,onChange:l,value:i})})}function Q(n){var W,E,N,R,F;const[t,i]=m.useState(null),d=Boolean(t),l=h.exports.useRef(null),[s,o]=h.exports.useState(null),u=p=>{i(p.currentTarget)},c=()=>{i(null)},k=()=>{l!=null&&l.current?(c(),l.current?l.current.click():console.log("No File selected")):alert("No file selected")},B=()=>{l.current.value="",l.current.dispatchEvent(new Event("change",{bubbles:!0}))},Y=p=>{p.target.files[0]?o(p.target.files[0].name):o(null)},Z=()=>{var p,L;if((p=l.current)!=null&&p.files.length){const M=new FormData;M.append("file",(L=l.current)==null?void 0:L.files[0]),j.post(`corporates/${g}/members/import`,M).then(w=>{B(),y(),H(w.data)}).catch(w=>{alert("Looks like something went wrong. Please check your data and try again. "+w.message)})}else alert("No File Selected")};return r("div",{children:[e("input",{type:"file",id:"file",ref:l,style:{display:"none"},onChange:Y,accept:".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/plain"}),!s&&r(v,{direction:"row",spacing:2,sx:{p:2},children:[e(J,{onSearch:G}),e(f,{id:"import-button",variant:"outlined",startIcon:e(he,{}),sx:{p:1.8},"aria-controls":d?"basic-menu":void 0,"aria-haspopup":"true","aria-expanded":d?"true":void 0,onClick:u,children:"Import"}),r(le,{id:"import-button",anchorEl:t,open:d,onClose:c,MenuListProps:{"aria-labelledby":"basic-button"},children:[e($,{onClick:k,children:"Import"}),e($,{onClick:c,children:"Download Template"})]})]}),s&&r(v,{direction:"row",spacing:2,sx:{p:2},children:[r(me,{variant:"outlined","aria-label":"outlined button group",fullWidth:!0,children:[e(f,{onClick:k,fullWidth:!0,children:s!=null?s:"No File Selected"}),e(f,{onClick:B,size:"small",fullWidth:!1,sx:{p:1.8},children:e(fe,{color:"error"})})]}),e(f,{id:"upload-button",variant:"outlined",startIcon:e(ue,{}),sx:{p:1.8},onClick:Z,children:"Upload"})]}),b&&e(v,{direction:"row",sx:{px:2,pb:2},children:r(S,{sx:{color:"text.secondary"},children:["Last Import Result : ",e(S,{sx:{color:"success.main",display:"inline"},children:(W=b.total_success_row)!=null?W:0})," Row Processed, ",e(S,{sx:{color:"error.main",display:"inline"},children:b.total_failed_row})," Failed, Report : ",e("a",{href:(N=(E=b.result_file)==null?void 0:E.url)!=null?N:"#",children:(F=(R=b.result_file)==null?void 0:R.name)!=null?F:"-"})]})})]})}const[V,ye]=m.useState([{id:"member_id",label:"MemberID",minWidth:100,align:"left"},{id:"principal_id",label:"Mapping ID",minWidth:100,align:"left"},{id:"nik",label:"NIK",minWidth:100,align:"left"},{id:"current_policy.policy_number",label:"Policy Number",minWidth:100,align:"left"},{id:"effective_date",label:"Effective Date",minWidth:100,align:"left"},{id:"name",label:"Name",minWidth:100,align:"left"},{id:"nric",label:"NRIC",minWidth:100,align:"left"},{id:"email",label:"E-mail",minWidth:100,align:"left"},{id:"plan_id",label:"PlanID",minWidth:100,align:"left"},{id:"activation_date",label:"Activation Date",minWidth:100,align:"right"},{id:"termination_date",label:"Termination Date",minWidth:100,align:"right"}]);function X(n){var l,s,o,u,c;const{row:t}=n,[i,d]=m.useState(!1);return r(m.Fragment,{children:[r(_,{sx:{"& > *":{borderBottom:"unset"}},children:[e(a,{children:e(re,{"aria-label":"expand row",size:"small",onClick:()=>d(!i),children:i?e(de,{}):e(pe,{})})}),e(a,{align:"left",children:t.member_id}),e(a,{align:"left",children:t.principal_id}),e(a,{align:"left",children:(l=t.employeds[0])==null?void 0:l.nik}),e(a,{align:"left",children:(s=t.current_policy)==null?void 0:s.policy_id}),e(a,{align:"left",children:(o=t.current_policy)==null?void 0:o.start}),e(a,{align:"left",children:t.name}),e(a,{align:"left",children:t.nric}),e(a,{align:"left",children:t.email}),e(a,{align:"left",children:t.plan_id}),e(a,{align:"left",children:(u=t.current_policy)==null?void 0:u.start}),e(a,{align:"left",children:(c=t.current_policy)==null?void 0:c.end}),t.active?e(a,{align:"right",children:e(f,{variant:"outlined",color:"success",size:"small",children:"Active"})}):e(a,{align:"right",children:e(f,{variant:"outlined",color:"error",size:"small",children:"Inactive"})})]}),e(_,{children:e(a,{style:{paddingBottom:0,paddingTop:0},colSpan:10,children:r(ie,{in:i,timeout:"auto",unmountOnExit:!0,children:[e(S,{sx:{borderBottom:1},children:e(oe,{variant:"body2",gutterBottom:!0,component:"div",children:"No Extra Data"})}),!1]})})})]})}const C={fontWeight:"bold"};return r(v,{children:[e(Q,{}),r(O,{children:[e(be,{component:ne,children:r(_e,{"aria-label":"collapsible table",children:[e(T,{children:r(_,{children:[e(a,{style:C,align:"left"}),V.map((n,t)=>e(a,{style:C,align:n.align,children:n.label},t)),e(a,{style:C,align:"right",children:"Status"}),e(a,{style:C,align:"right",children:"Action"})]})}),U?e(T,{children:e(_,{children:e(a,{colSpan:8,align:"center",children:"Loading"})})}):I.data.length==0?e(T,{children:e(_,{children:e(a,{colSpan:8,align:"center",children:"No Data"})})}):e(T,{children:I.data.map((n,t)=>e(X,{row:n},t))})]})}),e(ge,{paginationData:I,onPageChange:K})]})]})}function Ne(){z();const{corporate_id:g}=A();return r(te,{title:"Corporate Plan",children:[e(ee,{heading:"Corporate Plan",links:[{name:"Corporates",href:"/corporates"},{name:"Corporate Name",href:"/corporates/"+g},{name:"Member",href:"/corporates/"+g+"/members"}]}),r(O,{children:[e(ce,{position:"members"}),e(xe,{})]})]})}export{Ne as default};
|