import{d as $,r as c,b6 as G,a as J,oK as L,b as Q,j as t,B as W,fi as Y,qI as H,qJ as f,Q as U,T as X,R as j,qK as n,oM as Z,qL as w,l0 as ee,_ as te,qM as ae}from"./index-458d5762.js";import{T as oe}from"./index-7483f8f7.js";import{M as se}from"./MasterPageTitle-9f45ffbd.js";import{A as re}from"./add.document-55d67b0b.js";import{c as ie,b as ne,u as ce}from"./index.esm-b1b14098.js";import{o as le}from"./yup-536c503d.js";import{P as me}from"./Select-1c8a1710.js";import{T as pe}from"./TextField-e297d925.js";import{I as de}from"./InputAdornment-84b43ef6.js";import"./TableRow-804f1ca0.js";import"./useMediaQuery-49fd660f.js";import"./TableContainer-e19f0ed8.js";import"./TableHead-f91d726f.js";import"./Grow-1b19ccc0.js";import"./TablePagination-a615fa80.js";import"./KeyboardArrowRight-d389d7f9.js";import"./LastPage-ff5a6182.js";import"./Toolbar-866a7faf.js";import"./MenuItem-5cd95798.js";import"./dividerClasses-eff9af63.js";import"./listItemTextClasses-04d37f34.js";import"./listItemIconClasses-8da63284.js";import"./index.esm-5ead9a4b.js";import"./Divider-41f4fe7b.js";import"./FilterFilled-c223055e.js";import"./AntdIcon-99e065a0.js";import"./objectSpread2-cbe250a0.js";import"./index-3b6e321a.js";import"./GenericThumbnailView-3cd8dbb5.js";import"./createClass-9305c513.js";import"./popper-f3391c26.js";import"./ScrollableList-ba92364a.js";import"./CircularProgress-cad31cee.js";import"./FormInput-3d74947b.js";import"./FormControlLabel-c2b32a8e.js";import"./Checkbox-2fec2521.js";import"./SwitchBase-1c31939b.js";import"./componentStyles-56425874.js";import"./TextArea-233680fc.js";import"./DialogContent-2b2d5db0.js";import"./DialogTitle-bda4183d.js";import"./DialogContentText-f6501c39.js";import"./DialogActions-38a5ba62.js";import"./index-e5978b8b.js";import"./isMuiElement-6ed6867f.js";const it=()=>{const a=$(),[S,u]=c.useState(!1);c.useState("");const i=G(),[h,g]=c.useState(null),y=!!h,[l,D]=c.useState(null),{document:{documentList:M,pageParams:o,loading:v,documentCount:C,searchValue:ue,masterValue:I,masterEditId:b},system:{userAccessList:r}}=J(e=>({document:L(e),system:Q(e)})),z=[{title:"S.No",width:100},{title:"Code",width:100},{title:"Name",width:100},{title:"Actions",width:100}];function T(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=M.map((e,s)=>{const p=(o.page-1)*o.page_size+(s+1),d=t.jsxs(W,{justifyContent:"start",alignItems:"center",sx:{display:"flex",gap:2},children:[(r==null?void 0:r.indexOf("Masters.change_document"))!==-1&&t.jsx(Y,{style:{cursor:"pointer",color:"#fc6f03"},onClick:()=>{a(H({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:K=>E(K,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 T(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))},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(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:R})})}),t.jsx(oe,{count:C,columns:z,rows:F,loading:v,page:o.page,pageSize:o.page_size,handleChangePage:q,handleChangeRowsPerPage:A})]}),t.jsx(re,{modal:S,closeModal:N,mastersName:"Document",edit_Id:b,mastersValue:I})]})};export{it as default};
