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-d895656a.js";import{T as te}from"./index-ea344eac.js";import{M as ae}from"./MasterPageTitle-a3ec39dd.js";import{A as oe}from"./add.stage-d689ab29.js";import{c as re,b as se,u as ie}from"./index.esm-1087b2f3.js";import{o as ne}from"./yup-9573aa79.js";import{T as j}from"./Tooltip-b199707c.js";import{Z as C}from"./Zoom-19a9db59.js";import{P as le}from"./Menu-1728e1dd.js";import{C as pe}from"./CardContent-26fc99d8.js";import{T as ce}from"./TextField-6f73e19a.js";import{I as me}from"./InputAdornment-36977269.js";import"./TableRow-5557ab84.js";import"./useMediaQuery-dbbc87b0.js";import"./TableContainer-a89da0a1.js";import"./TableHead-1b575958.js";import"./Grow-d4be81a5.js";import"./TablePagination-582dd1d9.js";import"./KeyboardArrowRight-5067dfe9.js";import"./Toolbar-adca1e0f.js";import"./Select-6d425a72.js";import"./index-e5978b8b.js";import"./MenuItem-f1f55b7e.js";import"./dividerClasses-f4dcf412.js";import"./listItemTextClasses-1ed38b44.js";import"./index.esm-44fedea2.js";import"./Divider-cb9ba1b0.js";import"./FilterFilled-9d5acdc3.js";import"./AntdIcon-19e16777.js";import"./objectSpread2-c21546fe.js";import"./index-45bf15b6.js";import"./GenericThumbnailView-532ea2d7.js";import"./popper-f3391c26.js";import"./ScrollableList-e2b22048.js";import"./CircularProgress-1f3ca34c.js";import"./FormInput-9b5da280.js";import"./FormControlLabel-2fb7bcfb.js";import"./componentStyles-866300fe.js";import"./TextArea-fb0d0821.js";import"./DialogContent-4ce43512.js";import"./DialogTitle-738ca272.js";import"./DialogContentText-8b9b0e0c.js";import"./DialogActions-7b82f6f6.js";import"./LoadingButton-c8915ab4.js";import"./composeClasses-b42b2e69.js";import"./isMuiElement-424c145f.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};
