import{d as w,r as l,b4 as G,a as Q,on as W,j as e,B as Y,I as x,oq as f,sA as h,eZ as H,Q as J,T as K,R as j,sB as n,a2 as U,kr as X,_ as L,sC as ee}from"./index-dc933734.js";import{T as te}from"./index-ad373baf.js";import{M as ae}from"./MasterPageTitle-7544e586.js";import{A as oe}from"./add.stage-92ed5e45.js";import{c as re,b as se,u as ie}from"./index.esm-288e984c.js";import{o as ne}from"./yup-5b2e0cf9.js";import{T as S}from"./Tooltip-8eede184.js";import{Z as C}from"./Zoom-f460b424.js";import{P as le}from"./Select-e75c6695.js";import{C as pe}from"./CardContent-06dac9b3.js";import{T as ce}from"./TextField-a8016ff3.js";import{I as me}from"./InputAdornment-a4d846b9.js";import"./TableRow-f425a931.js";import"./useMediaQuery-c00165e7.js";import"./TableContainer-dd105b51.js";import"./TableHead-2909bf19.js";import"./Grow-3459ea54.js";import"./TablePagination-4ad2d9ff.js";import"./KeyboardArrowRight-e096ea37.js";import"./Toolbar-e48cc4d1.js";import"./MenuItem-03911a3a.js";import"./dividerClasses-75377d2f.js";import"./listItemTextClasses-436d31bc.js";import"./index.esm-cd80da5b.js";import"./Divider-b8be3c1c.js";import"./FilterFilled-5453348f.js";import"./AntdIcon-bb02d05f.js";import"./objectSpread2-d52818a5.js";import"./index-9b86adbc.js";import"./GenericThumbnailView-69a8725b.js";import"./popper-f3391c26.js";import"./ScrollableList-c8354e44.js";import"./CircularProgress-b8ef250f.js";import"./FormInput-58d4b01b.js";import"./FormControlLabel-476fd96c.js";import"./componentStyles-4df963a1.js";import"./TextArea-80ac5c9b.js";import"./DialogContent-d9f48895.js";import"./DialogTitle-4ec33ac0.js";import"./DialogContentText-e0ace713.js";import"./DialogActions-9dacec58.js";import"./LoadingButton-2e968ec8.js";import"./composeClasses-b42b2e69.js";import"./index-e5978b8b.js";import"./isMuiElement-f75ebb7c.js";const rt=()=>{const a=w();l.useState("");const i=G(),[g,u]=l.useState(null),T=!!g,[p,v]=l.useState(null),{stages:{stagesList:c,pageParams:o,loading:b,stagesCount:y,model:z},system:{userAccessList:s}}=Q(t=>W(t)),M=[{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 _=re({search:se()});const{control:de,handleSubmit:B,register:P,reset:k}=ie({resolver:ne(_),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}))},A=c==null?void 0:c.map((t,r)=>{const d=(o.page-1)*o.page_size+(r+1),$=e.jsxs(Y,{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(h(!0))},children:e.jsx(H,{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:q=>D(q,t==null?void 0:t.id),children:e.jsx(J,{style:{cursor:"pointer",color:"#fc6f03",fontSize:16}})})}),e.jsx(le,{id:p?String(p):void 0,open:T,anchorEl:g,onClose:m,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsxs("div",{style:{padding:"15px"},children:[e.jsx(K,{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:m,style:{marginLeft:"20px"},children:"No"})]})})]})]});return I(d,t.name,$)}),E=({search:t})=>{a(n({...o,search:t||"",page:1,page_size:10}))},F=(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 N=t=>{a(f({})),a(h(t))},V=t=>{const r=t.target.value;a(n({...o,search:r||"",page:1,page_size:10}))},Z=()=>{a(h(!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:N,pageText:""}),e.jsx(U,{sx:{marginBottom:"20px",marginTop:"15px"},children:e.jsxs(pe,{style:{padding:"10px",borderRadius:"10px"},children:[e.jsx("form",{action:"",onSubmit:B(E),children:e.jsx(X,{container:!0,mb:2,children:e.jsx(ce,{type:"text",sx:{width:"500px"},...P("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:V})})}),e.jsx(te,{count:y,columns:M,rows:A,loading:b,page:o.page,pageSize:o.page_size,handleChangePage:F,handleChangeRowsPerPage:R})]})}),e.jsx(oe,{modal:z,closeModal:Z})]})};export{rt as default};
