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-d895656a.js";import{T as se}from"./index-ea344eac.js";import{M as oe}from"./MasterPageTitle-a3ec39dd.js";import{A as re}from"./add.document-ff0bdea0.js";import{c as ie,b as ne,u as ce}from"./index.esm-1087b2f3.js";import{o as le}from"./yup-9573aa79.js";import{P as pe}from"./Menu-1728e1dd.js";import{T as me}from"./TextField-6f73e19a.js";import{I as de}from"./InputAdornment-36977269.js";import"./TableRow-5557ab84.js";import"./useMediaQuery-dbbc87b0.js";import"./TableContainer-a89da0a1.js";import"./TableHead-1b575958.js";import"./Grow-d4be81a5.js";import"./TablePagination-582dd1d9.js";import"./KeyboardArrowRight-5067dfe9.js";import"./Toolbar-adca1e0f.js";import"./Select-6d425a72.js";import"./index-e5978b8b.js";import"./MenuItem-f1f55b7e.js";import"./dividerClasses-f4dcf412.js";import"./listItemTextClasses-1ed38b44.js";import"./index.esm-44fedea2.js";import"./Divider-cb9ba1b0.js";import"./FilterFilled-9d5acdc3.js";import"./AntdIcon-19e16777.js";import"./objectSpread2-c21546fe.js";import"./index-45bf15b6.js";import"./GenericThumbnailView-532ea2d7.js";import"./popper-f3391c26.js";import"./ScrollableList-e2b22048.js";import"./CircularProgress-1f3ca34c.js";import"./FormInput-9b5da280.js";import"./FormControlLabel-2fb7bcfb.js";import"./componentStyles-866300fe.js";import"./TextArea-fb0d0821.js";import"./DialogContent-4ce43512.js";import"./DialogTitle-738ca272.js";import"./DialogContentText-8b9b0e0c.js";import"./DialogActions-7b82f6f6.js";import"./isMuiElement-424c145f.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};
