import{d as G,r as c,b7 as Q,a as W,q6 as Y,b as H,j as t,B as J,eI as K,s6 as L,s7 as f,Q as U,T as X,R as j,s8 as n,q8 as Z,s9 as w,mn as ee,_ as te,sa as ae}from"./index-e79f7aad.js";import{T as se}from"./index-a65810f4.js";import{M as oe}from"./MasterPageTitle-a4f02d02.js";import{A as re}from"./add.document-aa0d69e1.js";import{c as ie,b as ne,u as ce}from"./index.esm-1ca67d65.js";import{o as le}from"./yup-96f14780.js";import{P as me}from"./Select-8a61e5a6.js";import{T as pe}from"./TextField-21e22d39.js";import{I as de}from"./InputAdornment-d42c17cd.js";import"./TableRow-0ea91e40.js";import"./useMediaQuery-9155ba05.js";import"./TableContainer-00013c19.js";import"./TableHead-1f8b658d.js";import"./TablePagination-6f9f31d4.js";import"./KeyboardArrowRight-4ee9435c.js";import"./LastPage-1ca2417e.js";import"./Toolbar-d2cd5725.js";import"./MenuItem-c14df0e9.js";import"./dividerClasses-691b251c.js";import"./listItemTextClasses-d3a968ad.js";import"./listItemIconClasses-03011ebf.js";import"./index.esm-05058101.js";import"./Divider-d5c2dff6.js";import"./FilterFilled-8d538f67.js";import"./AntdIcon-1cfbd840.js";import"./objectSpread2-d56e1476.js";import"./index-310d07a1.js";import"./GenericThumbnailView-8a83a30c.js";import"./createClass-b86a4c8d.js";import"./popper-f3391c26.js";import"./ScrollableList-5929779e.js";import"./CircularProgress-8c35778c.js";import"./FormInput-07daa19d.js";import"./FormControlLabel-bfeefc5c.js";import"./Checkbox-b895334d.js";import"./SwitchBase-e7cea42d.js";import"./componentStyles-7718fc5e.js";import"./TextArea-ec29d1d5.js";import"./DialogContent-6a297cef.js";import"./DialogTitle-62595023.js";import"./DialogContentText-0c5306f9.js";import"./DialogActions-edd1d02f.js";import"./index-e5978b8b.js";import"./isMuiElement-db2b7d4c.js";const rt=()=>{const a=G(),[S,u]=c.useState(!1);c.useState("");const i=Q(),[h,g]=c.useState(null),y=!!h,[l,D]=c.useState(null),{document:{documentList:v,pageParams:s,loading:C,documentCount:I,searchValue:ue,masterValue:M,masterEditId:b},system:{userAccessList:r}}=W(e=>({document:Y(e),system:H(e)})),z=[{title:"S.No",width:100},{title:"Code",width:100},{title:"Name",width:100},{title:"Actions",width:100}];function T(e,o,p,d){return{index:e,code:o,name:p,actions:d}}let _=ie({search:ne()});const{control:he,handleSubmit:P,register:O,reset:B}=ce({resolver:le(_),values:{search:s.search}}),E=(e,o)=>{D(o),g(e.currentTarget)},m=()=>{g(null)},k=e=>{a(ae({id:e,clearDataFn:()=>{},navigate:o=>{},pageParams:s})),a(n({...s,search:"",page:1,page_size:10})),m()},F=v.map((e,o)=>{const p=(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:$=>E($,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({...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"),B({search:""})},[]);const x=e=>{a(f(0)),a(Z({})),u(e),a(w(e))},R=()=>{u(!1)},q=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: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:q})})}),t.jsx(se,{count:I,columns:z,rows:F,loading:C,page:s.page,pageSize:s.page_size,handleChangePage:A,handleChangeRowsPerPage:N})]}),t.jsx(re,{modal:S,closeModal:R,mastersName:"Document",edit_Id:b,mastersValue:M})]})};export{rt as default};
