import{d as G,r as l,aV as W,a as Y,od as q,j as e,B as H,I as x,og as f,s7 as g,eS as J,y as K,T as Q,z as S,s8 as n,R as U,k9 as X,M as L,s9 as ee}from"./index-4dfc510b.js";import{T as te}from"./index-2560e6e6.js";import{M as ae}from"./MasterPageTitle-68cbcd9e.js";import{A as oe}from"./add.stage-68e8f5b4.js";import{c as re,b as se,u as ie}from"./index.esm-0a454763.js";import{o as ne}from"./yup-80def618.js";import{T as j}from"./Tooltip-cc3e7d19.js";import{Z as C}from"./Zoom-a3338917.js";import{P as le}from"./Menu-0f556e12.js";import{C as pe}from"./CardContent-afcdca5e.js";import{T as ce}from"./TextField-c0d4022e.js";import{I as me}from"./InputAdornment-ccd6e8ff.js";import"./TableRow-bee40746.js";import"./useMediaQuery-75ea24f6.js";import"./TableContainer-3d0f0f18.js";import"./TableHead-c19aff48.js";import"./Grow-a7315f12.js";import"./TablePagination-faf46d98.js";import"./KeyboardArrowRight-605c8352.js";import"./Toolbar-1cf142b4.js";import"./Select-c8503f85.js";import"./index-e5978b8b.js";import"./MenuItem-9737e3d9.js";import"./dividerClasses-26c2a6d6.js";import"./listItemTextClasses-e85f7ff0.js";import"./index.esm-337179d9.js";import"./Divider-1794f57d.js";import"./FilterFilled-dc66781c.js";import"./AntdIcon-90a37458.js";import"./objectSpread2-66550f90.js";import"./index-9a385720.js";import"./GenericThumbnailView-6256cad7.js";import"./popper-f3391c26.js";import"./ScrollableList-bef4a518.js";import"./CircularProgress-d36b5e75.js";import"./FormInput-f887e69c.js";import"./FormControlLabel-e49dd1e5.js";import"./componentStyles-df94248d.js";import"./TextArea-a0cc14f3.js";import"./DialogContent-3bf4ff27.js";import"./DialogTitle-248b1818.js";import"./DialogContentText-a6ab23a2.js";import"./DialogActions-49286e71.js";import"./LoadingButton-09ba23cd.js";import"./composeClasses-b42b2e69.js";import"./isMuiElement-7be61a21.js";const st=()=>{const a=G();l.useState("");const i=W(),[h,u]=l.useState(null),T=!!h,[p,v]=l.useState(null),{stages:{stagesList:c,pageParams:o,loading:y,stagesCount:z,model:M},system:{userAccessList:s}}=Y(t=>q(t)),b=[{title:"S.No",width:100},{title:"Name",width:100},{title:"Actions",width:100}];function I(t,r,d){return{index:t,name:r,actions:d}}let P=re({search:se()});const{control:de,handleSubmit:_,register:B,reset:k}=ie({resolver:ne(P),values:{search:o.search}}),D=(t,r)=>{v(r),u(t.currentTarget)},m=()=>{u(null)},O=t=>{a(ee({id:t,clearDataFn:()=>{m()},pageParams:o}))},E=c==null?void 0:c.map((t,r)=>{const d=(o.page-1)*o.page_size+(r+1),$=e.jsxs(H,{sx:{display:"flex",gap:2,justifyContent:"start"},children:[(s==null?void 0:s.indexOf("Masters.change_stage"))!==-1&&e.jsx(j,{TransitionComponent:C,title:"Edit Stage",children:e.jsx(x,{onClick:()=>{a(f(t)),a(g(!0))},children:e.jsx(J,{style:{cursor:"pointer",color:"#fc6f03",fontSize:16}})})}),(s==null?void 0:s.indexOf("Masters.delete_stage"))!==-1&&e.jsxs(e.Fragment,{children:[e.jsx(j,{TransitionComponent:C,title:"Delete Stage",children:e.jsx(x,{onClick:w=>D(w,t==null?void 0:t.id),children:e.jsx(K,{style:{cursor:"pointer",color:"#fc6f03",fontSize:16}})})}),e.jsx(le,{id:p?String(p):void 0,open:T,anchorEl:h,onClose:m,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsxs("div",{style:{padding:"15px"},children:[e.jsx(Q,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),e.jsx(S,{variant:"contained",type:"submit",color:"primary",onClick:()=>{O(p)},autoFocus:!0,children:"Yes"}),e.jsx(S,{variant:"outlined",size:"small",onClick:m,style:{marginLeft:"20px"},children:"No"})]})})]})]});return I(d,t.name,$)}),F=({search:t})=>{a(n({...o,search:t||"",page:1,page_size:10}))},A=(t,r)=>{a(n({...o,search:"",page:r+1}))},R=t=>{a(n({...o,search:"",page:1,page_size:parseInt(t.target.value)}))};l.useEffect(()=>{a(n({...o,search:"",page:1,page_size:10})),i==null||i.setTitle("Stages"),i==null||i.setSubtitle("Masters"),k({search:""})},[]);const V=t=>{a(f({})),a(g(t))},N=t=>{const r=t.target.value;a(n({...o,search:r||"",page:1,page_size:10}))},Z=()=>{a(g(!1))};return e.jsxs(e.Fragment,{children:[e.jsx(ae,{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:V,pageText:""}),e.jsx(U,{sx:{marginBottom:"20px",marginTop:"15px"},children:e.jsxs(pe,{style:{padding:"10px",borderRadius:"10px"},children:[e.jsx("form",{action:"",onSubmit:_(F),children:e.jsx(X,{container:!0,mb:2,children:e.jsx(ce,{type:"text",sx:{width:"500px"},...B("search"),id:"input-with-icon-textfield",size:"small",InputProps:{startAdornment:e.jsx(me,{position:"start",children:e.jsx(L,{size:20})})},fullWidth:!0,variant:"outlined",placeholder:"Search",onChange:N})})}),e.jsx(te,{count:z,columns:b,rows:E,loading:y,page:o.page,pageSize:o.page_size,handleChangePage:A,handleChangeRowsPerPage:R})]})}),e.jsx(oe,{modal:M,closeModal:Z})]})};export{st as default};
