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-e0c07a84.js";import{M as W}from"./MasterPageTitle-10ea7f2b.js";import{A as X}from"./add.stage-900e871e.js";import{C as $}from"./index-2eb663b6.js";import{T}from"./Tooltip-69dd5e58.js";import{Z as v}from"./Zoom-6e8c52bc.js";import{P as L}from"./Select-a8f8fd6a.js";import{T as tt}from"./TextField-23174150.js";import{I as et}from"./InputAdornment-bf957c61.js";import"./index.esm-68061338.js";import"./index.esm-79617ba5.js";import"./yup-74a95d85.js";import"./Divider-ee8faca1.js";import"./dividerClasses-6c6c8dc7.js";import"./FilterFilled-80640201.js";import"./AntdIcon-bc64d1d9.js";import"./objectSpread2-f946b5f0.js";import"./index-c7a54fed.js";import"./GenericThumbnailView-d192caf7.js";import"./createClass-1acb73b4.js";import"./popper-f3391c26.js";import"./Grow-5c4c469c.js";import"./ScrollableList-874c742d.js";import"./CircularProgress-cff840b0.js";import"./FormInput-7bb37f2a.js";import"./FormControlLabel-5799166a.js";import"./Checkbox-80534fe3.js";import"./SwitchBase-ed82e33a.js";import"./componentStyles-5432a72d.js";import"./TableRow-248ce459.js";import"./TextArea-e9886f56.js";import"./DialogContent-bfc00e3a.js";import"./DialogTitle-d1ec1f1a.js";import"./DialogContentText-c88b94b0.js";import"./DialogActions-7f92619e.js";import"./LoadingButton-f9561377.js";import"./composeClasses-b42b2e69.js";import"./TableContainer-84b94d99.js";import"./TableHead-3bf23892.js";import"./TablePagination-da0d0adf.js";import"./KeyboardArrowRight-aeb4c8ed.js";import"./LastPage-d8600c66.js";import"./Toolbar-c85ba7f8.js";import"./MenuItem-9dcf8782.js";import"./listItemTextClasses-e9c46ccd.js";import"./listItemIconClasses-129e65e5.js";import"./index-e5978b8b.js";import"./isMuiElement-953ce284.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};
