import{d as G,r as l,b4 as Q,a as W,oo as Y,j as e,B as q,I as x,or as f,sB as h,e_ as H,Q as J,T as K,R as j,sC as n,a2 as U,ks as X,_ as L,sD as ee}from"./index-83d9c1e2.js";import{T as te}from"./index-cc00c6a4.js";import{M as ae}from"./MasterPageTitle-9ab56f94.js";import{A as oe}from"./add.stage-2f256707.js";import{c as re,b as se,u as ie}from"./index.esm-82874186.js";import{o as ne}from"./yup-dfe9f223.js";import{T as S}from"./Tooltip-872413c1.js";import{Z as C}from"./Zoom-630f9c40.js";import{P as le}from"./Select-1505055e.js";import{C as pe}from"./CardContent-fb0d7247.js";import{T as me}from"./TextField-39c52322.js";import{I as ce}from"./InputAdornment-4b0a9854.js";import"./TableRow-1c35ea2a.js";import"./useMediaQuery-c67ad591.js";import"./TableContainer-98997305.js";import"./TableHead-95baa189.js";import"./Grow-6cc6748b.js";import"./TablePagination-81b30c1b.js";import"./KeyboardArrowRight-b7bab219.js";import"./Toolbar-25a41873.js";import"./MenuItem-26e66f0f.js";import"./dividerClasses-f18f0f93.js";import"./listItemTextClasses-fcd068d2.js";import"./index.esm-316fec71.js";import"./Divider-71865361.js";import"./FilterFilled-eb3492a9.js";import"./AntdIcon-f9724de9.js";import"./objectSpread2-e5f2d908.js";import"./index-1ceef347.js";import"./GenericThumbnailView-ceecb14e.js";import"./popper-f3391c26.js";import"./ScrollableList-2bb71a63.js";import"./CircularProgress-3ce9da74.js";import"./FormInput-03b7722e.js";import"./FormControlLabel-af5c9791.js";import"./Checkbox-fe0b2cdb.js";import"./SwitchBase-ad42caec.js";import"./componentStyles-7858e543.js";import"./TextArea-7d949f4d.js";import"./DialogContent-a75c4d06.js";import"./DialogTitle-3c642f58.js";import"./DialogContentText-ab545101.js";import"./DialogActions-3c3ab24c.js";import"./LoadingButton-f61ccca8.js";import"./composeClasses-b42b2e69.js";import"./index-e5978b8b.js";import"./isMuiElement-5c2699ea.js";const it=()=>{const a=G();l.useState("");const i=Q(),[g,u]=l.useState(null),T=!!g,[p,v]=l.useState(null),{stages:{stagesList:m,pageParams:o,loading:b,stagesCount:y,model:z},system:{userAccessList:s}}=W(t=>Y(t)),M=[{title:"S.No",width:100},{title:"Name",width:100},{title:"Actions",width:100}];function _(t,r,d){return{index:t,name:r,actions:d}}let I=re({search:se()});const{control:de,handleSubmit:B,register:P,reset:D}=ie({resolver:ne(I),values:{search:o.search}}),k=(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(q,{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:w=>k(w,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:c,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:c,style:{marginLeft:"20px"},children:"No"})]})})]})]});return _(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"),D({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(F),children:e.jsx(X,{container:!0,mb:2,children:e.jsx(me,{type:"text",sx:{width:"500px"},...P("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:V})})}),e.jsx(te,{count:y,columns:M,rows:E,loading:b,page:o.page,pageSize:o.page_size,handleChangePage:A,handleChangeRowsPerPage:R})]})}),e.jsx(oe,{modal:z,closeModal:Z})]})};export{it as default};
