import{d as U,r as c,b6 as $,a as G,oU as Q,b as Y,j as t,B as H,ew as J,qS as K,qT as f,Q as L,T as X,R as j,qU as n,oW as Z,qV as w,lb as ee,_ as te,qW as ae}from"./index-e6164346.js";import{T as oe}from"./index-8e856c3a.js";import{M as se}from"./MasterPageTitle-fcafb323.js";import{A as re}from"./add.document-5315359e.js";import{c as ie,b as ne,u as ce}from"./index.esm-0a041314.js";import{o as le}from"./yup-5fd5d57b.js";import{P as me}from"./Select-9c2d8cd2.js";import{T as pe}from"./TextField-db9cff08.js";import{I as de}from"./InputAdornment-59975edf.js";import"./TableRow-bf4e60a0.js";import"./useMediaQuery-43140cef.js";import"./TableContainer-7ecd96ea.js";import"./TableHead-0c525f54.js";import"./Grow-306e2fd0.js";import"./TablePagination-b02830fa.js";import"./KeyboardArrowRight-73af71dd.js";import"./LastPage-b9dcf78c.js";import"./Toolbar-82d22fac.js";import"./MenuItem-8dd174fb.js";import"./dividerClasses-932c3e8b.js";import"./listItemTextClasses-6b253cb4.js";import"./listItemIconClasses-a58b491d.js";import"./index.esm-42924bf1.js";import"./Divider-6099014b.js";import"./FilterFilled-c0851aaa.js";import"./AntdIcon-4f5aa87b.js";import"./objectSpread2-7d7378cc.js";import"./index-ce90e1a7.js";import"./GenericThumbnailView-80c6fd98.js";import"./createClass-ad55a3ca.js";import"./popper-f3391c26.js";import"./ScrollableList-5a17e8f4.js";import"./CircularProgress-7d99d864.js";import"./FormInput-859198ec.js";import"./FormControlLabel-ee192a98.js";import"./Checkbox-70f568c2.js";import"./SwitchBase-e1f0b96b.js";import"./componentStyles-00385170.js";import"./TextArea-f5c200de.js";import"./Dialog-2e8a8e2e.js";import"./DialogTitle-8757f50f.js";import"./DialogContent-f10d6731.js";import"./DialogContentText-027be15d.js";import"./DialogActions-31bec80e.js";import"./index-e5978b8b.js";import"./isMuiElement-5779af4f.js";const nt=()=>{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:b,searchValue:ue,masterValue:M,masterEditId:T},system:{userAccessList:r}}=G(e=>({document:Q(e),system:Y(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)},V=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(H,{justifyContent:"start",alignItems:"center",sx:{display:"flex",gap:2},children:[(r==null?void 0:r.indexOf("Masters.change_document"))!==-1&&t.jsx(J,{style:{cursor:"pointer",color:"#fc6f03"},onClick:()=>{a(K({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(L,{style:{cursor:"pointer",color:"#fc6f03"},onClick:W=>E(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(X,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),t.jsx(j,{variant:"contained",type:"submit",color:"primary",onClick:()=>{V(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"),B({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:b,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:T,mastersValue:M})]})};export{nt as default};
