import{d as Z,r as n,b8 as q,a as $,qJ as w,j as t,B as J,I as S,qM as j,uZ as h,eK as K,R as U,T as Y,U as C,u_ as p,$ as G,u$ as H}from"./index-60657852.js";import{M as Q}from"./MasterPageTitle-4d4d4430.js";import{A as W}from"./add.stage-7d97f6af.js";import{C as X}from"./index-61d7dc47.js";import{T}from"./Tooltip-1a5db018.js";import{Z as v}from"./Zoom-a3ca5f9d.js";import{P as L}from"./Select-7d2a5359.js";import{T as tt}from"./TextField-6b778b78.js";import{I as et}from"./InputAdornment-12fc79ce.js";import"./index.esm-5fae0aa9.js";import"./index.esm-509a598d.js";import"./yup-75ad371b.js";import"./Divider-6555f8d4.js";import"./dividerClasses-590294d7.js";import"./FilterFilled-e5a9bf0e.js";import"./AntdIcon-53906b68.js";import"./objectSpread2-b46e5e65.js";import"./index-980acb6c.js";import"./GenericThumbnailView-f8b17afa.js";import"./createClass-2b895736.js";import"./popper-f3391c26.js";import"./Grow-a21bdd26.js";import"./ScrollableList-ef4c85dc.js";import"./FormInput-6b018fe9.js";import"./FormControlLabel-95d4d7bb.js";import"./Checkbox-026acf65.js";import"./SwitchBase-3b306fc6.js";import"./componentStyles-19763afb.js";import"./TableRow-0ab1e69a.js";import"./TextArea-d897dbf9.js";import"./DialogContent-d5183bd6.js";import"./DialogTitle-66c21479.js";import"./DialogContentText-e3f3f7dd.js";import"./DialogActions-1dfa5a01.js";import"./LoadingButton-c619bdb5.js";import"./LastPage-71f2133b.js";import"./KeyboardArrowRight-450d5bb8.js";import"./TableContainer-c3087864.js";import"./TableHead-1ba4d27d.js";import"./TablePagination-dd506b19.js";import"./KeyboardArrowRight-5039311c.js";import"./LastPage-c4cc7e5b.js";import"./Toolbar-e6f520d9.js";import"./MenuItem-64348b57.js";import"./listItemTextClasses-81f8effc.js";import"./listItemIconClasses-39f47a05.js";import"./isMuiElement-82a67859.js";const Ht=()=>{const a=Z(),[M,u]=n.useState(""),i=q(),[x,f]=n.useState(null),y=!!x,[l,z]=n.useState(null),{stages:{stagesList:m,pageParams:r,loading:I,stagesCount:P,model:b},system:{userAccessList:s}}=$(e=>w(e)),_=[{title:"S.No",width:100},{title:"Name",width:100},{title:"Remarks",width:100},{title:"Actions",width:100}];function k(e,o,d,g){return{index:e,name:o,remarks:d,actions:g}}const B=(e,o)=>{z(o),f(e.currentTarget)},c=()=>{f(null)},D=e=>{a(H({id:e,clearDataFn:()=>{c()},pageParams:r}))},O=m==null?void 0:m.map((e,o)=>{const d=(r.page-1)*r.page_size+(o+1),g=t.jsxs(J,{sx:{display:"flex",gap:2,justifyContent:"start"},children:[(s==null?void 0:s.indexOf("Masters.change_stage"))!==-1&&t.jsx(T,{TransitionComponent:v,title:"Edit Stage",children:t.jsx(S,{onClick:()=>{a(j(e)),a(h(!0))},children:t.jsx(K,{style:{cursor:"pointer",color:"#fc6f03",fontSize:16}})})}),(s==null?void 0:s.indexOf("Masters.delete_stage"))!==-1&&t.jsxs(t.Fragment,{children:[t.jsx(T,{TransitionComponent:v,title:"Delete Stage",children:t.jsx(S,{onClick:V=>B(V,e==null?void 0:e.id),children:t.jsx(U,{style:{cursor:"pointer",color:"#fc6f03",fontSize:16}})})}),t.jsx(L,{id:l?String(l):void 0,open:y,anchorEl:x,onClose:c,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:t.jsxs("div",{style:{padding:"15px"},children:[t.jsx(Y,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),t.jsx(C,{variant:"contained",type:"submit",color:"primary",onClick:()=>{D(l)},autoFocus:!0,children:"Yes"}),t.jsx(C,{variant:"outlined",size:"small",onClick:c,style:{marginLeft:"20px"},children:"No"})]})})]})]});return k(d,e.name,e.remarks,g)}),E=(e,o)=>{a(p({...r,search:"",page:o+1}))},A=e=>{a(p({...r,search:"",page:1,page_size:parseInt(e.target.value)}))};n.useEffect(()=>{a(p({...r,search:"",page:1,page_size:10})),i==null||i.setTitle("Stages"),i==null||i.setSubtitle("Masters"),u("")},[]);const F=e=>{a(j({})),a(h(e))},R=e=>{const o=e.target.value;u(o),a(p({...r,search:o||"",page:1,page_size:10}))},N=()=>{a(h(!1))};return t.jsxs(t.Fragment,{children:[t.jsx(W,{modal:b,closeModal:N}),t.jsx(Q,{prefix:"Masters",postfix:"stage",pageTitle:"Stages",goBack:!0,addModelTile:(s==null?void 0:s.indexOf("Masters.add_stage"))!==-1?"Add Stages":void 0,modalVisible:!0,setIsModalVisible:F,pageText:"",searchComponent:t.jsx(tt,{type:"text",sx:{width:"300px"},value:M,size:"small",InputProps:{startAdornment:t.jsx(et,{position:"start",children:t.jsx(G,{size:16})})},variant:"outlined",placeholder:"Search",onChange:R}),children:t.jsx(X,{count:P,columns:_,rows:O,loading:I,page:r.page,pageSize:r.page_size,handleChangePage:E,handleChangeRowsPerPage:A,showPagination:!0})})]})};export{Ht as default};
