import{d as Q,r as c,aV as W,a as Y,nP as q,b as H,j as t,B as J,eS as K,pN as L,pO as f,y as U,T as X,z as j,pP as n,nR as Z,pQ as w,k9 as ee,M as te,pR as ae}from"./index-4dfc510b.js";import{T as se}from"./index-2560e6e6.js";import{M as oe}from"./MasterPageTitle-68cbcd9e.js";import{A as re}from"./add.document-020b7bef.js";import{c as ie,b as ne,u as ce}from"./index.esm-0a454763.js";import{o as le}from"./yup-80def618.js";import{P as pe}from"./Menu-0f556e12.js";import{T as me}from"./TextField-c0d4022e.js";import{I as de}from"./InputAdornment-ccd6e8ff.js";import"./TableRow-bee40746.js";import"./useMediaQuery-75ea24f6.js";import"./TableContainer-3d0f0f18.js";import"./TableHead-c19aff48.js";import"./Grow-a7315f12.js";import"./TablePagination-faf46d98.js";import"./KeyboardArrowRight-605c8352.js";import"./Toolbar-1cf142b4.js";import"./Select-c8503f85.js";import"./index-e5978b8b.js";import"./MenuItem-9737e3d9.js";import"./dividerClasses-26c2a6d6.js";import"./listItemTextClasses-e85f7ff0.js";import"./index.esm-337179d9.js";import"./Divider-1794f57d.js";import"./FilterFilled-dc66781c.js";import"./AntdIcon-90a37458.js";import"./objectSpread2-66550f90.js";import"./index-9a385720.js";import"./GenericThumbnailView-6256cad7.js";import"./popper-f3391c26.js";import"./ScrollableList-bef4a518.js";import"./CircularProgress-d36b5e75.js";import"./FormInput-f887e69c.js";import"./FormControlLabel-e49dd1e5.js";import"./componentStyles-df94248d.js";import"./TextArea-a0cc14f3.js";import"./DialogContent-3bf4ff27.js";import"./DialogTitle-248b1818.js";import"./DialogContentText-a6ab23a2.js";import"./DialogActions-49286e71.js";import"./isMuiElement-7be61a21.js";const at=()=>{const a=Q(),[S,u]=c.useState(!1);c.useState("");const i=W(),[h,g]=c.useState(null),y=!!h,[l,D]=c.useState(null),{document:{documentList:v,pageParams:s,loading:C,documentCount:M,searchValue:ue,masterValue:z,masterEditId:I},system:{userAccessList:r}}=Y(e=>({document:q(e),system:H(e)})),T=[{title:"S.No",width:100},{title:"Code",width:100},{title:"Name",width:100},{title:"Actions",width:100}];function b(e,o,m,d){return{index:e,code:o,name:m,actions:d}}let P=ie({search:ne()});const{control:he,handleSubmit:_,register:O,reset:k}=ce({resolver:le(P),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()},V=v.map((e,o)=>{const m=(s.page-1)*s.page_size+(o+1),d=t.jsxs(J,{justifyContent:"start",alignItems:"center",sx:{display:"flex",gap:2},children:[(r==null?void 0:r.indexOf("Masters.change_document"))!==-1&&t.jsx(K,{style:{cursor:"pointer",color:"#fc6f03"},onClick:()=>{a(L({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(U,{style:{cursor:"pointer",color:"#fc6f03"},onClick:G=>B(G,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(X,{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 b(m,e.code,e.name,d)}),F=({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(Z({})),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:_(F),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:T,rows:V,loading:C,page:s.page,pageSize:s.page_size,handleChangePage:A,handleChangeRowsPerPage:N})]}),t.jsx(re,{modal:S,closeModal:R,mastersName:"Document",edit_Id:I,mastersValue:z})]})};export{at as default};
