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-ba11e6ab.js";import{T as te}from"./index-cbb0ce26.js";import{M as ae}from"./MasterPageTitle-6247bce5.js";import{A as oe}from"./add.stage-f687ef44.js";import{c as re,b as se,u as ie}from"./index.esm-39ef576a.js";import{o as ne}from"./yup-902af9ab.js";import{T as S}from"./Tooltip-0b246907.js";import{Z as C}from"./Zoom-60edb791.js";import{P as le}from"./Select-f9434f8a.js";import{C as pe}from"./CardContent-9c57d232.js";import{T as me}from"./TextField-16337ecc.js";import{I as ce}from"./InputAdornment-0f07311f.js";import"./TableRow-e1616615.js";import"./useMediaQuery-c8eb26e5.js";import"./TableContainer-9178cc85.js";import"./TableHead-5a0d8cfc.js";import"./Grow-1038181b.js";import"./TablePagination-3b5112dd.js";import"./KeyboardArrowRight-36117cc9.js";import"./Toolbar-c7a1b81e.js";import"./MenuItem-e4578955.js";import"./dividerClasses-ab944802.js";import"./listItemTextClasses-a4497781.js";import"./index.esm-c4573c1c.js";import"./Divider-7b675f59.js";import"./FilterFilled-94a9d775.js";import"./AntdIcon-d49f53d6.js";import"./objectSpread2-d72b34ab.js";import"./index-33824b7d.js";import"./GenericThumbnailView-511a7e33.js";import"./popper-f3391c26.js";import"./ScrollableList-b4fc4d99.js";import"./CircularProgress-509803a6.js";import"./FormInput-3e62ad24.js";import"./FormControlLabel-8048035a.js";import"./Checkbox-3e187368.js";import"./SwitchBase-7d4e0bc8.js";import"./componentStyles-cc6f218d.js";import"./TextArea-1c46e0e4.js";import"./DialogContent-af77e042.js";import"./DialogTitle-dc43931f.js";import"./DialogContentText-990aa19e.js";import"./DialogActions-3fe54b4c.js";import"./LoadingButton-a3eae003.js";import"./composeClasses-b42b2e69.js";import"./index-e5978b8b.js";import"./isMuiElement-f8265807.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};
