import{d as U,r as c,b6 as $,a as G,oS as L,b as W,j as t,B as Y,eL as H,qQ as J,qR as f,Q as K,T as X,R as j,qS as n,oU as Z,qT as w,l9 as ee,_ as te,qU as ae}from"./index-c121b02d.js";import{T as oe}from"./index-4981d6f8.js";import{M as se}from"./MasterPageTitle-877dfad0.js";import{A as re}from"./add.document-06446751.js";import{c as ie,b as ne,u as ce}from"./index.esm-0c6778ff.js";import{o as le}from"./yup-1361ecb6.js";import{P as me}from"./Select-dd7adaf8.js";import{T as pe}from"./TextField-f9d2a024.js";import{I as de}from"./InputAdornment-ae4c2625.js";import"./TableRow-0b65a5b3.js";import"./useMediaQuery-4319583b.js";import"./TableContainer-be48ac32.js";import"./TableHead-9a25be14.js";import"./Grow-9a484472.js";import"./TablePagination-6fddb4ff.js";import"./KeyboardArrowRight-87bf88d8.js";import"./LastPage-df7292bf.js";import"./Toolbar-600c82f3.js";import"./MenuItem-0f1fc7f8.js";import"./dividerClasses-81752629.js";import"./listItemTextClasses-27b4ea1b.js";import"./listItemIconClasses-b2c374f0.js";import"./index.esm-0bede3d3.js";import"./Divider-6da4bf5c.js";import"./FilterFilled-a045b23e.js";import"./AntdIcon-28682171.js";import"./objectSpread2-d754d5ed.js";import"./index-2d756126.js";import"./GenericThumbnailView-77114fcb.js";import"./createClass-66eb0661.js";import"./popper-f3391c26.js";import"./ScrollableList-dc408f1e.js";import"./CircularProgress-fa872e62.js";import"./FormInput-c000e22e.js";import"./FormControlLabel-560df3d1.js";import"./Checkbox-a6136302.js";import"./SwitchBase-9f520d13.js";import"./componentStyles-2d610038.js";import"./TextArea-dfbfc4f6.js";import"./DialogContent-caa035c8.js";import"./DialogTitle-9f04a88b.js";import"./DialogContentText-e68ec1be.js";import"./DialogActions-1901dd11.js";import"./index-e5978b8b.js";import"./isMuiElement-d52f64c2.js";const it=()=>{const a=U(),[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:L(e),system:W(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:B}=ce({resolver:le(_),values:{search:o.search}}),E=(e,s)=>{D(s),g(e.currentTarget)},m=()=>{g(null)},k=e=>{a(ae({id:e,clearDataFn:()=>{},navigate:s=>{},pageParams:o})),a(n({...o,search:"",page:1,page_size:10})),m()},F=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:Q=>E(Q,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(X,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),t.jsx(j,{variant:"contained",type:"submit",color:"primary",onClick:()=>{k(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)}),V=({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"),B({search:""})},[]);const x=e=>{a(f(0)),a(Z({})),u(e),a(w(e))},R=()=>{u(!1)},N=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(V),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:N})})}),t.jsx(oe,{count:M,columns:z,rows:F,loading:C,page:o.page,pageSize:o.page_size,handleChangePage:q,handleChangeRowsPerPage:A})]}),t.jsx(re,{modal:S,closeModal:R,mastersName:"Document",edit_Id:b,mastersValue:T})]})};export{it as default};
