import{d as Y,r as c,b4 as G,a as Q,nZ as W,b as X,j as t,B as q,eZ as H,pX as J,pY as f,Q as K,T as L,R as j,pZ as n,n$ as U,p_ as w,kr as ee,_ as te,p$ as ae}from"./index-dc933734.js";import{T as se}from"./index-ad373baf.js";import{M as oe}from"./MasterPageTitle-7544e586.js";import{A as re}from"./add.document-5b2fb6c7.js";import{c as ie,b as ne,u as ce}from"./index.esm-288e984c.js";import{o as le}from"./yup-5b2e0cf9.js";import{P as pe}from"./Select-e75c6695.js";import{T as me}from"./TextField-a8016ff3.js";import{I as de}from"./InputAdornment-a4d846b9.js";import"./TableRow-f425a931.js";import"./useMediaQuery-c00165e7.js";import"./TableContainer-dd105b51.js";import"./TableHead-2909bf19.js";import"./Grow-3459ea54.js";import"./TablePagination-4ad2d9ff.js";import"./KeyboardArrowRight-e096ea37.js";import"./Toolbar-e48cc4d1.js";import"./MenuItem-03911a3a.js";import"./dividerClasses-75377d2f.js";import"./listItemTextClasses-436d31bc.js";import"./index.esm-cd80da5b.js";import"./Divider-b8be3c1c.js";import"./FilterFilled-5453348f.js";import"./AntdIcon-bb02d05f.js";import"./objectSpread2-d52818a5.js";import"./index-9b86adbc.js";import"./GenericThumbnailView-69a8725b.js";import"./popper-f3391c26.js";import"./ScrollableList-c8354e44.js";import"./CircularProgress-b8ef250f.js";import"./FormInput-58d4b01b.js";import"./FormControlLabel-476fd96c.js";import"./componentStyles-4df963a1.js";import"./TextArea-80ac5c9b.js";import"./DialogContent-d9f48895.js";import"./DialogTitle-4ec33ac0.js";import"./DialogContentText-e0ace713.js";import"./DialogActions-9dacec58.js";import"./index-e5978b8b.js";import"./isMuiElement-f75ebb7c.js";const tt=()=>{const a=Y(),[S,u]=c.useState(!1);c.useState("");const i=G(),[h,g]=c.useState(null),y=!!h,[l,D]=c.useState(null),{document:{documentList:v,pageParams:s,loading:C,documentCount:M,searchValue:ue,masterValue:b,masterEditId:z},system:{userAccessList:r}}=Q(e=>({document:W(e),system:X(e)})),I=[{title:"S.No",width:100},{title:"Code",width:100},{title:"Name",width:100},{title:"Actions",width:100}];function T(e,o,m,d){return{index:e,code:o,name:m,actions:d}}let _=ie({search:ne()});const{control:he,handleSubmit:P,register:O,reset:k}=ce({resolver:le(_),values:{search:s.search}}),B=(e,o)=>{D(o),g(e.currentTarget)},p=()=>{g(null)},E=e=>{a(ae({id:e,clearDataFn:()=>{},navigate:o=>{},pageParams:s})),a(n({...s,search:"",page:1,page_size:10})),p()},F=v.map((e,o)=>{const m=(s.page-1)*s.page_size+(o+1),d=t.jsxs(q,{justifyContent:"start",alignItems:"center",sx:{display:"flex",gap:2},children:[(r==null?void 0:r.indexOf("Masters.change_document"))!==-1&&t.jsx(H,{style:{cursor:"pointer",color:"#fc6f03"},onClick:()=>{a(J({id:e==null?void 0:e.id})),x(!0),a(f(e==null?void 0:e.id))}}),(r==null?void 0:r.indexOf("Masters.delete_document"))!==-1&&t.jsxs(t.Fragment,{children:[t.jsx(K,{style:{cursor:"pointer",color:"#fc6f03"},onClick:Z=>B(Z,e==null?void 0:e.id)}),t.jsx(pe,{id:l?String(l):void 0,open:y,anchorEl:h,onClose:p,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:t.jsxs("div",{style:{padding:"15px"},children:[t.jsx(L,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),t.jsx(j,{variant:"contained",type:"submit",color:"primary",onClick:()=>{E(l)},autoFocus:!0,children:"Yes"}),t.jsx(j,{variant:"outlined",size:"small",onClick:p,style:{marginLeft:"20px"},children:"No"})]})})]})]});return T(m,e.code,e.name,d)}),V=({search:e})=>{a(n({...s,search:e||"",page:1,page_size:10}))},A=(e,o)=>{a(n({...s,search:"",page:o+1}))},N=e=>{a(n({...s,search:"",page:1,page_size:parseInt(e.target.value)}))};c.useEffect(()=>{a(n({...s,search:"",page:1,page_size:10})),i==null||i.setTitle("Document"),i==null||i.setSubtitle("Masters"),k({search:""})},[]);const x=e=>{a(f(0)),a(U({})),u(e),a(w(e))},R=()=>{u(!1)},$=e=>{const o=e.target.value;a(n({...s,search:o||"",page:1,page_size:10}))};return t.jsxs(t.Fragment,{children:[t.jsxs(oe,{prefix:"Masters",postfix:"Document",pageTitle:"Document",goBack:!0,addModelTile:(r==null?void 0:r.indexOf("Masters.add_document"))!==-1?"Add Document":void 0,modalVisible:!0,setIsModalVisible:x,pageText:"",children:[t.jsx("form",{action:"",onSubmit:P(V),children:t.jsx(ee,{container:!0,my:2,children:t.jsx(me,{type:"text",sx:{width:"500px"},...O("search"),id:"input-with-icon-textfield",size:"small",InputProps:{startAdornment:t.jsx(de,{position:"start",children:t.jsx(te,{size:20})})},fullWidth:!0,variant:"outlined",placeholder:"Search",onChange:$})})}),t.jsx(se,{count:M,columns:I,rows:F,loading:C,page:s.page,pageSize:s.page_size,handleChangePage:A,handleChangeRowsPerPage:N})]}),t.jsx(re,{modal:S,closeModal:R,mastersName:"Document",edit_Id:z,mastersValue:b})]})};export{tt as default};
