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,eR as J,y as K,T as Q,z as j,s8 as n,R as U,k9 as X,M as L,s9 as ee}from"./index-c5c88b67.js";import{T as te}from"./index-f0b37835.js";import{M as ae}from"./MasterPageTitle-405781d7.js";import{A as oe}from"./add.stage-b9c8423d.js";import{c as re,b as se,u as ie}from"./index.esm-81620445.js";import{o as ne}from"./yup-41605283.js";import{T as S}from"./Tooltip-7a33c6d6.js";import{Z as C}from"./Zoom-7991491b.js";import{P as le}from"./Menu-e7d2b2ee.js";import{C as pe}from"./CardContent-5f043396.js";import{T as me}from"./TextField-78388962.js";import{I as ce}from"./InputAdornment-d66117f3.js";import"./TableRow-2b359fa8.js";import"./useMediaQuery-fe3ce37c.js";import"./TableContainer-c31f204a.js";import"./TableHead-c2c21491.js";import"./Grow-7345f8ea.js";import"./TablePagination-0147f84a.js";import"./KeyboardArrowRight-261f4f43.js";import"./Toolbar-f8d4b0c4.js";import"./Select-4ed8db5d.js";import"./index-e5978b8b.js";import"./MenuItem-81e44793.js";import"./dividerClasses-6bc0ca72.js";import"./listItemTextClasses-88792089.js";import"./index.esm-0ad88c35.js";import"./Divider-0dc41916.js";import"./FilterFilled-9066fadd.js";import"./AntdIcon-1a0d7a6b.js";import"./objectSpread2-65a0d991.js";import"./index-c98d1d89.js";import"./GenericThumbnailView-43782201.js";import"./createClass-fb49042e.js";import"./popper-f3391c26.js";import"./ScrollableList-21ab2b9c.js";import"./CircularProgress-13afa056.js";import"./FormInput-86f14880.js";import"./FormControlLabel-d6955dc8.js";import"./componentStyles-a5e5a830.js";import"./TextArea-aad9dffe.js";import"./DialogContent-1350b249.js";import"./DialogTitle-da236dcc.js";import"./DialogContentText-659ecbc3.js";import"./DialogActions-1232a7fa.js";import"./LoadingButton-3a5d0643.js";import"./composeClasses-b42b2e69.js";import"./isMuiElement-b3c21f38.js";const it=()=>{const a=G();l.useState("");const i=W(),[h,u]=l.useState(null),T=!!h,[p,v]=l.useState(null),{stages:{stagesList:m,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)},c=()=>{u(null)},O=t=>{a(ee({id:t,clearDataFn:()=>{c()},pageParams:o}))},E=m==null?void 0:m.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(S,{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(S,{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:c,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(j,{variant:"contained",type:"submit",color:"primary",onClick:()=>{O(p)},autoFocus:!0,children:"Yes"}),e.jsx(j,{variant:"outlined",size:"small",onClick:c,style:{marginLeft:"20px"},children:"No"})]})})]})]});return I(d,t.name,$)}),F=({search:t})=>{a(n({...o,search:t||"",page:1,page_size:10}))},R=(t,r)=>{a(n({...o,search:"",page:r+1}))},A=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(me,{type:"text",sx:{width:"500px"},...B("search"),id:"input-with-icon-textfield",size:"small",InputProps:{startAdornment:e.jsx(ce,{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:R,handleChangeRowsPerPage:A})]})}),e.jsx(oe,{modal:M,closeModal:Z})]})};export{it as default};
