import{d as Z,r as n,b6 as w,a as Q,pg as Y,j as t,B as q,I as j,pj as S,tt as h,eL as G,Q as H,T as J,R as C,tu as p,_ as K,tv as U}from"./index-c121b02d.js";import{M as W}from"./MasterPageTitle-877dfad0.js";import{A as X}from"./add.stage-24a16d50.js";import{C as $}from"./index-ae3694f0.js";import{T}from"./Tooltip-4b00e924.js";import{Z as v}from"./Zoom-7d897850.js";import{P as L}from"./Select-dd7adaf8.js";import{T as tt}from"./TextField-f9d2a024.js";import{I as et}from"./InputAdornment-ae4c2625.js";import"./index.esm-0bede3d3.js";import"./index.esm-0c6778ff.js";import"./yup-1361ecb6.js";import"./Divider-6da4bf5c.js";import"./dividerClasses-81752629.js";import"./FilterFilled-a045b23e.js";import"./AntdIcon-28682171.js";import"./objectSpread2-d754d5ed.js";import"./index-2d756126.js";import"./GenericThumbnailView-77114fcb.js";import"./createClass-66eb0661.js";import"./popper-f3391c26.js";import"./Grow-9a484472.js";import"./ScrollableList-dc408f1e.js";import"./CircularProgress-fa872e62.js";import"./FormInput-c000e22e.js";import"./FormControlLabel-560df3d1.js";import"./Checkbox-a6136302.js";import"./SwitchBase-9f520d13.js";import"./componentStyles-2d610038.js";import"./TableRow-0b65a5b3.js";import"./TextArea-dfbfc4f6.js";import"./DialogContent-caa035c8.js";import"./DialogTitle-9f04a88b.js";import"./DialogContentText-e68ec1be.js";import"./DialogActions-1901dd11.js";import"./LoadingButton-66be9360.js";import"./composeClasses-b42b2e69.js";import"./TableContainer-be48ac32.js";import"./TableHead-9a25be14.js";import"./TablePagination-6fddb4ff.js";import"./KeyboardArrowRight-87bf88d8.js";import"./LastPage-df7292bf.js";import"./Toolbar-600c82f3.js";import"./MenuItem-0f1fc7f8.js";import"./listItemTextClasses-27b4ea1b.js";import"./listItemIconClasses-b2c374f0.js";import"./index-e5978b8b.js";import"./isMuiElement-d52f64c2.js";const Wt=()=>{const a=Z(),[y,u]=n.useState(""),i=w(),[x,f]=n.useState(null),z=!!x,[l,M]=n.useState(null),{stages:{stagesList:m,pageParams:r,loading:I,stagesCount:P,model:b},system:{userAccessList:s}}=Q(e=>Y(e)),_=[{title:"S.No",width:100},{title:"Name",width:100},{title:"Remarks",width:100},{title:"Actions",width:100}];function k(e,o,d,g){return{index:e,name:o,remarks:d,actions:g}}const B=(e,o)=>{M(o),f(e.currentTarget)},c=()=>{f(null)},D=e=>{a(U({id:e,clearDataFn:()=>{c()},pageParams:r}))},O=m==null?void 0:m.map((e,o)=>{const d=(r.page-1)*r.page_size+(o+1),g=t.jsxs(q,{sx:{display:"flex",gap:2,justifyContent:"start"},children:[(s==null?void 0:s.indexOf("Masters.change_stage"))!==-1&&t.jsx(T,{TransitionComponent:v,title:"Edit Stage",children:t.jsx(j,{onClick:()=>{a(S(e)),a(h(!0))},children:t.jsx(G,{style:{cursor:"pointer",color:"#fc6f03",fontSize:16}})})}),(s==null?void 0:s.indexOf("Masters.delete_stage"))!==-1&&t.jsxs(t.Fragment,{children:[t.jsx(T,{TransitionComponent:v,title:"Delete Stage",children:t.jsx(j,{onClick:V=>B(V,e==null?void 0:e.id),children:t.jsx(H,{style:{cursor:"pointer",color:"#fc6f03",fontSize:16}})})}),t.jsx(L,{id:l?String(l):void 0,open:z,anchorEl:x,onClose:c,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:t.jsxs("div",{style:{padding:"15px"},children:[t.jsx(J,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),t.jsx(C,{variant:"contained",type:"submit",color:"primary",onClick:()=>{D(l)},autoFocus:!0,children:"Yes"}),t.jsx(C,{variant:"outlined",size:"small",onClick:c,style:{marginLeft:"20px"},children:"No"})]})})]})]});return k(d,e.name,e.remarks,g)}),E=(e,o)=>{a(p({...r,search:"",page:o+1}))},A=e=>{a(p({...r,search:"",page:1,page_size:parseInt(e.target.value)}))};n.useEffect(()=>{a(p({...r,search:"",page:1,page_size:10})),i==null||i.setTitle("Stages"),i==null||i.setSubtitle("Masters"),u("")},[]);const F=e=>{a(S({})),a(h(e))},R=e=>{const o=e.target.value;u(o),a(p({...r,search:o||"",page:1,page_size:10}))},N=()=>{a(h(!1))};return t.jsxs(t.Fragment,{children:[t.jsx(X,{modal:b,closeModal:N}),t.jsx(W,{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:F,pageText:"",searchComponent:t.jsx(tt,{type:"text",sx:{width:"300px"},value:y,size:"small",InputProps:{startAdornment:t.jsx(et,{position:"start",children:t.jsx(K,{size:16})})},variant:"outlined",placeholder:"Search",onChange:R}),children:t.jsx($,{count:P,columns:_,rows:O,loading:I,page:r.page,pageSize:r.page_size,handleChangePage:E,handleChangeRowsPerPage:A,showPagination:!0})})]})};export{Wt as default};
