import{d as V,r as n,b6 as Z,a as Q,pj as Y,j as t,B as q,I as j,pm as S,tw as h,ew as G,Q as H,T as J,R as C,tx as p,_ as K,ty as U}from"./index-6f149d0c.js";import{M as W}from"./MasterPageTitle-30469691.js";import{A as X}from"./add.stage-aa7ff438.js";import{C as $}from"./index-123bf5f6.js";import{T}from"./Tooltip-0754c119.js";import{Z as v}from"./Zoom-0a60304c.js";import{P as L}from"./Select-70a66099.js";import{T as tt}from"./TextField-a5af71e6.js";import{I as et}from"./InputAdornment-ca5e29e7.js";import"./index.esm-3605974c.js";import"./index.esm-88773116.js";import"./yup-7ebcc99d.js";import"./Divider-79e55221.js";import"./dividerClasses-aa25d579.js";import"./FilterFilled-843cffe9.js";import"./AntdIcon-d56b3db9.js";import"./objectSpread2-bd69b5ce.js";import"./index-a88b83d7.js";import"./GenericThumbnailView-01fef5a2.js";import"./createClass-925b8ab0.js";import"./popper-f3391c26.js";import"./Grow-aea427ae.js";import"./ScrollableList-e382be10.js";import"./CircularProgress-49299c74.js";import"./FormInput-d3efc191.js";import"./FormControlLabel-5b331de0.js";import"./Checkbox-541bacdb.js";import"./SwitchBase-2c6e76be.js";import"./componentStyles-d6393a0a.js";import"./TableRow-1e254c97.js";import"./TextArea-eb0beb3a.js";import"./Dialog-4a8f5dd6.js";import"./DialogTitle-0edc620d.js";import"./DialogContent-398aea0b.js";import"./DialogContentText-12f15d60.js";import"./DialogActions-d3c730f9.js";import"./LoadingButton-91f0786c.js";import"./composeClasses-b42b2e69.js";import"./TableContainer-98fd6e5d.js";import"./TableHead-483470b3.js";import"./TablePagination-40662a32.js";import"./KeyboardArrowRight-1f33e1ff.js";import"./LastPage-de948385.js";import"./Toolbar-7b4b233b.js";import"./MenuItem-8bc5d37f.js";import"./listItemTextClasses-6dace016.js";import"./listItemIconClasses-4d219f9a.js";import"./index-e5978b8b.js";import"./isMuiElement-36ccba67.js";const Xt=()=>{const a=V(),[y,u]=n.useState(""),i=Z(),[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:N=>B(N,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}))},w=()=>{a(h(!1))};return t.jsxs(t.Fragment,{children:[t.jsx(X,{modal:b,closeModal:w}),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{Xt as default};
