import{d as X,r as c,b6 as $,a as G,oV as Q,b as U,j as t,B as Y,ew as H,qT as J,qU as f,Q as K,T as L,R as j,qV as n,oX as Z,qW as w,lc as ee,_ as te,qX as ae}from"./index-6f149d0c.js";import{T as oe}from"./index-2cd683b8.js";import{M as se}from"./MasterPageTitle-30469691.js";import{A as re}from"./add.document-421d6231.js";import{c as ie,b as ne,u as ce}from"./index.esm-88773116.js";import{o as le}from"./yup-7ebcc99d.js";import{P as me}from"./Select-70a66099.js";import{T as pe}from"./TextField-a5af71e6.js";import{I as de}from"./InputAdornment-ca5e29e7.js";import"./TableRow-1e254c97.js";import"./useMediaQuery-4f481de0.js";import"./TableContainer-98fd6e5d.js";import"./TableHead-483470b3.js";import"./Grow-aea427ae.js";import"./TablePagination-40662a32.js";import"./KeyboardArrowRight-1f33e1ff.js";import"./LastPage-de948385.js";import"./Toolbar-7b4b233b.js";import"./MenuItem-8bc5d37f.js";import"./dividerClasses-aa25d579.js";import"./listItemTextClasses-6dace016.js";import"./listItemIconClasses-4d219f9a.js";import"./index.esm-3605974c.js";import"./Divider-79e55221.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"./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"./TextArea-eb0beb3a.js";import"./Dialog-4a8f5dd6.js";import"./DialogTitle-0edc620d.js";import"./DialogContent-398aea0b.js";import"./DialogContentText-12f15d60.js";import"./DialogActions-d3c730f9.js";import"./index-e5978b8b.js";import"./isMuiElement-36ccba67.js";const nt=()=>{const a=X(),[S,u]=c.useState(!1);c.useState("");const i=$(),[h,g]=c.useState(null),y=!!h,[l,D]=c.useState(null),{document:{documentList:v,pageParams:o,loading:C,documentCount:M,searchValue:ue,masterValue:T,masterEditId:b},system:{userAccessList:r}}=G(e=>({document:Q(e),system:U(e)})),z=[{title:"S.No",width:100},{title:"Code",width:100},{title:"Name",width:100},{title:"Actions",width:100}];function I(e,s,p,d){return{index:e,code:s,name:p,actions:d}}let _=ie({search:ne()});const{control:he,handleSubmit:P,register:O,reset:V}=ce({resolver:le(_),values:{search:o.search}}),B=(e,s)=>{D(s),g(e.currentTarget)},m=()=>{g(null)},E=e=>{a(ae({id:e,clearDataFn:()=>{},navigate:s=>{},pageParams:o})),a(n({...o,search:"",page:1,page_size:10})),m()},k=v.map((e,s)=>{const p=(o.page-1)*o.page_size+(s+1),d=t.jsxs(Y,{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:W=>B(W,e==null?void 0:e.id)}),t.jsx(me,{id:l?String(l):void 0,open:y,anchorEl:h,onClose:m,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:m,style:{marginLeft:"20px"},children:"No"})]})})]})]});return I(p,e.code,e.name,d)}),F=({search:e})=>{a(n({...o,search:e||"",page:1,page_size:10}))},q=(e,s)=>{a(n({...o,search:"",page:s+1}))},A=e=>{a(n({...o,search:"",page:1,page_size:parseInt(e.target.value)}))};c.useEffect(()=>{a(n({...o,search:"",page:1,page_size:10})),i==null||i.setTitle("Document"),i==null||i.setSubtitle("Masters"),V({search:""})},[]);const x=e=>{a(f(0)),a(Z({})),u(e),a(w(e))},N=()=>{u(!1)},R=e=>{const s=e.target.value;a(n({...o,search:s||"",page:1,page_size:10}))};return t.jsxs(t.Fragment,{children:[t.jsxs(se,{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(F),children:t.jsx(ee,{container:!0,my:2,children:t.jsx(pe,{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:R})})}),t.jsx(oe,{count:M,columns:z,rows:k,loading:C,page:o.page,pageSize:o.page_size,handleChangePage:q,handleChangeRowsPerPage:A})]}),t.jsx(re,{modal:S,closeModal:N,mastersName:"Document",edit_Id:b,mastersValue:T})]})};export{nt as default};
