import{d as V,r as n,b6 as Z,a as Q,pi as Y,j as t,B as q,I as S,pl as j,tv as h,ew as G,Q as H,T as J,R as C,tw as p,_ as K,tx as U}from"./index-e6164346.js";import{M as W}from"./MasterPageTitle-fcafb323.js";import{A as X}from"./add.stage-92cb8f23.js";import{C as $}from"./index-cde536dd.js";import{T}from"./Tooltip-c38fd0c1.js";import{Z as v}from"./Zoom-393881cf.js";import{P as L}from"./Select-9c2d8cd2.js";import{T as tt}from"./TextField-db9cff08.js";import{I as et}from"./InputAdornment-59975edf.js";import"./index.esm-42924bf1.js";import"./index.esm-0a041314.js";import"./yup-5fd5d57b.js";import"./Divider-6099014b.js";import"./dividerClasses-932c3e8b.js";import"./FilterFilled-c0851aaa.js";import"./AntdIcon-4f5aa87b.js";import"./objectSpread2-7d7378cc.js";import"./index-ce90e1a7.js";import"./GenericThumbnailView-80c6fd98.js";import"./createClass-ad55a3ca.js";import"./popper-f3391c26.js";import"./Grow-306e2fd0.js";import"./ScrollableList-5a17e8f4.js";import"./CircularProgress-7d99d864.js";import"./FormInput-859198ec.js";import"./FormControlLabel-ee192a98.js";import"./Checkbox-70f568c2.js";import"./SwitchBase-e1f0b96b.js";import"./componentStyles-00385170.js";import"./TableRow-bf4e60a0.js";import"./TextArea-f5c200de.js";import"./Dialog-2e8a8e2e.js";import"./DialogTitle-8757f50f.js";import"./DialogContent-f10d6731.js";import"./DialogContentText-027be15d.js";import"./DialogActions-31bec80e.js";import"./LoadingButton-bce4d1bf.js";import"./composeClasses-b42b2e69.js";import"./TableContainer-7ecd96ea.js";import"./TableHead-0c525f54.js";import"./TablePagination-b02830fa.js";import"./KeyboardArrowRight-73af71dd.js";import"./LastPage-b9dcf78c.js";import"./Toolbar-82d22fac.js";import"./MenuItem-8dd174fb.js";import"./listItemTextClasses-6b253cb4.js";import"./listItemIconClasses-a58b491d.js";import"./index-e5978b8b.js";import"./isMuiElement-5779af4f.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(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: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(j({})),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};
