import{d as Z,r as n,b6 as w,a as Q,pk as Y,j as t,B as q,I as S,pn as j,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-5ae5cc5e.js";import{M as W}from"./MasterPageTitle-426707bb.js";import{A as X}from"./add.stage-1b675719.js";import{C as $}from"./index-b50996fd.js";import{T}from"./Tooltip-650e2bc8.js";import{Z as v}from"./Zoom-9aa3be87.js";import{P as L}from"./Select-6f375e89.js";import{T as tt}from"./TextField-013fef4f.js";import{I as et}from"./InputAdornment-c8af61f0.js";import"./index.esm-91b69e04.js";import"./index.esm-bd37e938.js";import"./yup-86a48159.js";import"./Divider-e1d32c28.js";import"./dividerClasses-ea2ed133.js";import"./FilterFilled-40058e95.js";import"./AntdIcon-b932f733.js";import"./objectSpread2-13a56fdb.js";import"./index-125b1c7e.js";import"./GenericThumbnailView-fac7773c.js";import"./createClass-227e27b6.js";import"./popper-f3391c26.js";import"./Grow-d70e9b6d.js";import"./ScrollableList-2ee889f8.js";import"./CircularProgress-672898c5.js";import"./FormInput-77541d96.js";import"./FormControlLabel-b2fabe81.js";import"./Checkbox-84b6779a.js";import"./SwitchBase-4fa73d90.js";import"./componentStyles-7d84c389.js";import"./TableRow-fbdd6d52.js";import"./TextArea-20f097f8.js";import"./DialogContent-e2578cbd.js";import"./DialogTitle-4a5aec12.js";import"./DialogContentText-bc10bf8d.js";import"./DialogActions-ad26e3d6.js";import"./LoadingButton-d465030d.js";import"./composeClasses-b42b2e69.js";import"./TableContainer-ed67fdcd.js";import"./TableHead-15aac70d.js";import"./TablePagination-63129eb6.js";import"./KeyboardArrowRight-8e772e39.js";import"./LastPage-aa82a010.js";import"./Toolbar-0ec32807.js";import"./MenuItem-dc2bf765.js";import"./listItemTextClasses-2547faff.js";import"./listItemIconClasses-20c36342.js";import"./index-e5978b8b.js";import"./isMuiElement-c29cfc23.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)),k=[{title:"S.No",width:100},{title:"Name",width:100},{title:"Remarks",width:100},{title:"Actions",width:100}];function _(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(S,{onClick:()=>{a(j(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(S,{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 _(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(j({})),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:k,rows:O,loading:I,page:r.page,pageSize:r.page_size,handleChangePage:E,handleChangeRowsPerPage:A,showPagination:!0})})]})};export{Wt as default};
