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-6c48ebe4.js";import{T as oe}from"./index-f4e64c6d.js";import{M as se}from"./MasterPageTitle-d5826191.js";import{A as re}from"./add.document-babe7d4a.js";import{c as ie,b as ne,u as ce}from"./index.esm-fd3369ba.js";import{o as le}from"./yup-75ac0470.js";import{P as me}from"./Select-c5c274bb.js";import{T as pe}from"./TextField-3876249c.js";import{I as de}from"./InputAdornment-42748b9a.js";import"./TableRow-31f0a4a1.js";import"./useMediaQuery-00a4851f.js";import"./TableContainer-45046f6e.js";import"./TableHead-37e5318b.js";import"./Grow-3d640bff.js";import"./TablePagination-cd240560.js";import"./KeyboardArrowRight-345292ac.js";import"./LastPage-6dc33080.js";import"./Toolbar-6122c8d7.js";import"./MenuItem-12bffc2f.js";import"./dividerClasses-28ddda01.js";import"./listItemTextClasses-6920789d.js";import"./listItemIconClasses-a3efc5a3.js";import"./index.esm-83aa69eb.js";import"./Divider-96d02e86.js";import"./FilterFilled-a2396aeb.js";import"./AntdIcon-3eb8cd38.js";import"./objectSpread2-31ff416c.js";import"./index-84485105.js";import"./GenericThumbnailView-e18774c4.js";import"./createClass-8ad09c76.js";import"./popper-f3391c26.js";import"./ScrollableList-e9cb113e.js";import"./CircularProgress-7b4c6820.js";import"./FormInput-345d040e.js";import"./FormControlLabel-122a731f.js";import"./Checkbox-f9887e1d.js";import"./SwitchBase-8951f097.js";import"./componentStyles-1dd5fe29.js";import"./TextArea-4432195b.js";import"./DialogContent-2975c76a.js";import"./DialogTitle-6235c46a.js";import"./DialogContentText-928ca488.js";import"./DialogActions-aa83bc6c.js";import"./index-e5978b8b.js";import"./isMuiElement-447b74a0.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};
