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,eR 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-c5c88b67.js";import{T as se}from"./index-f0b37835.js";import{M as oe}from"./MasterPageTitle-405781d7.js";import{A as re}from"./add.document-191b1f24.js";import{c as ie,b as ne,u as ce}from"./index.esm-81620445.js";import{o as le}from"./yup-41605283.js";import{P as pe}from"./Menu-e7d2b2ee.js";import{T as me}from"./TextField-78388962.js";import{I as de}from"./InputAdornment-d66117f3.js";import"./TableRow-2b359fa8.js";import"./useMediaQuery-fe3ce37c.js";import"./TableContainer-c31f204a.js";import"./TableHead-c2c21491.js";import"./Grow-7345f8ea.js";import"./TablePagination-0147f84a.js";import"./KeyboardArrowRight-261f4f43.js";import"./Toolbar-f8d4b0c4.js";import"./Select-4ed8db5d.js";import"./index-e5978b8b.js";import"./MenuItem-81e44793.js";import"./dividerClasses-6bc0ca72.js";import"./listItemTextClasses-88792089.js";import"./index.esm-0ad88c35.js";import"./Divider-0dc41916.js";import"./FilterFilled-9066fadd.js";import"./AntdIcon-1a0d7a6b.js";import"./objectSpread2-65a0d991.js";import"./index-c98d1d89.js";import"./GenericThumbnailView-43782201.js";import"./createClass-fb49042e.js";import"./popper-f3391c26.js";import"./ScrollableList-21ab2b9c.js";import"./CircularProgress-13afa056.js";import"./FormInput-86f14880.js";import"./FormControlLabel-d6955dc8.js";import"./componentStyles-a5e5a830.js";import"./TextArea-aad9dffe.js";import"./DialogContent-1350b249.js";import"./DialogTitle-da236dcc.js";import"./DialogContentText-659ecbc3.js";import"./DialogActions-1232a7fa.js";import"./isMuiElement-b3c21f38.js";const st=()=>{const a=Q(),[y,u]=c.useState(!1);c.useState("");const i=W(),[h,g]=c.useState(null),S=!!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:S,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}))},R=(e,o)=>{a(n({...s,search:"",page:o+1}))},A=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))},N=()=>{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:R,handleChangeRowsPerPage:A})]}),t.jsx(re,{modal:y,closeModal:N,mastersName:"Document",edit_Id:I,mastersValue:z})]})};export{st as default};
