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-3141de2d.js";import{T as te}from"./index-a22dce01.js";import{M as ae}from"./MasterPageTitle-e75bb457.js";import{A as oe}from"./add.stage-18ad5480.js";import{c as re,b as se,u as ie}from"./index.esm-8b0c9a99.js";import{o as ne}from"./yup-c2fea6fa.js";import{T as S}from"./Tooltip-ca912c56.js";import{Z as C}from"./Zoom-ef11d3b2.js";import{P as le}from"./Select-369b8a03.js";import{C as pe}from"./CardContent-97006932.js";import{T as me}from"./TextField-ec161c03.js";import{I as ce}from"./InputAdornment-1680248d.js";import"./TableRow-e26106d8.js";import"./useMediaQuery-aa4be5c2.js";import"./TableContainer-e4a79220.js";import"./TableHead-6dad4842.js";import"./Grow-e0aea29d.js";import"./TablePagination-377a84d4.js";import"./KeyboardArrowRight-d5826f7e.js";import"./Toolbar-c1e97401.js";import"./MenuItem-d41bf2e5.js";import"./dividerClasses-752b2dd5.js";import"./listItemTextClasses-5f5f8755.js";import"./index.esm-8b587a7a.js";import"./Divider-e779ddd3.js";import"./FilterFilled-94ea2c05.js";import"./AntdIcon-eb0da2c9.js";import"./objectSpread2-41b8b8d3.js";import"./index-a3f870f6.js";import"./GenericThumbnailView-c2621934.js";import"./popper-f3391c26.js";import"./ScrollableList-fa62971d.js";import"./CircularProgress-a64e9e1b.js";import"./FormInput-abff9e70.js";import"./FormControlLabel-c4983ca8.js";import"./Checkbox-8808455f.js";import"./SwitchBase-416973c8.js";import"./componentStyles-24f97919.js";import"./TextArea-ceaff311.js";import"./DialogContent-17781b67.js";import"./DialogTitle-16416764.js";import"./DialogContentText-c64ca110.js";import"./DialogActions-37bf04e2.js";import"./LoadingButton-8bbad6d1.js";import"./composeClasses-b42b2e69.js";import"./index-e5978b8b.js";import"./isMuiElement-2bebf9f1.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};
