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,fr as G,Q as H,T as J,R as C,tu as p,_ as K,tv as U}from"./index-e972fa8e.js";import{M as W}from"./MasterPageTitle-fc1ef7a8.js";import{A as X}from"./add.stage-cc8c9a05.js";import{C as $}from"./index-db9d46ea.js";import{T}from"./Tooltip-9b8e644f.js";import{Z as v}from"./Zoom-caee0cdd.js";import{P as L}from"./Select-a2938be0.js";import{T as tt}from"./TextField-77f9d647.js";import{I as et}from"./InputAdornment-acd34c72.js";import"./index.esm-44b3cc2a.js";import"./index.esm-b3c20f6d.js";import"./yup-b3178c01.js";import"./Divider-1d368ab1.js";import"./dividerClasses-b771f620.js";import"./FilterFilled-61dd8e74.js";import"./AntdIcon-c86cb7c3.js";import"./objectSpread2-5ffd54f7.js";import"./index-44db81fe.js";import"./GenericThumbnailView-38007944.js";import"./createClass-8ffbea6f.js";import"./popper-f3391c26.js";import"./Grow-0b3a9797.js";import"./ScrollableList-4768c2b7.js";import"./CircularProgress-58819244.js";import"./FormInput-dbaa88c2.js";import"./FormControlLabel-77a47114.js";import"./Checkbox-05d562e2.js";import"./SwitchBase-a3d90b7d.js";import"./componentStyles-7142291f.js";import"./TableRow-c60adf0a.js";import"./TextArea-6c7f39e1.js";import"./DialogContent-51a7b314.js";import"./DialogTitle-6bcbc606.js";import"./DialogContentText-1562904b.js";import"./DialogActions-122de1b4.js";import"./LoadingButton-1312b0f8.js";import"./composeClasses-b42b2e69.js";import"./TableContainer-ad9de4b5.js";import"./TableHead-11d85aea.js";import"./TablePagination-63dde5fc.js";import"./KeyboardArrowRight-4b11e6b9.js";import"./LastPage-69d51b6f.js";import"./Toolbar-fca75f8a.js";import"./MenuItem-fab52ff5.js";import"./listItemTextClasses-f7cdafa8.js";import"./listItemIconClasses-bcb38dc7.js";import"./index-e5978b8b.js";import"./isMuiElement-fab695f8.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};
