import{d as Y,r as c,b6 as $,a as G,oW as L,b as Q,j as t,B as U,eL as X,qU as H,qV as f,Q as J,T as K,R as j,qW as n,oY as Z,qX as w,ld as ee,_ as te,qY as ae}from"./index-5ae5cc5e.js";import{T as oe}from"./index-7d0c783f.js";import{M as se}from"./MasterPageTitle-426707bb.js";import{A as re}from"./add.document-1f03b36a.js";import{c as ie,b as ne,u as ce}from"./index.esm-bd37e938.js";import{o as le}from"./yup-86a48159.js";import{P as me}from"./Select-6f375e89.js";import{T as pe}from"./TextField-013fef4f.js";import{I as de}from"./InputAdornment-c8af61f0.js";import"./TableRow-fbdd6d52.js";import"./useMediaQuery-8780c1c1.js";import"./TableContainer-ed67fdcd.js";import"./TableHead-15aac70d.js";import"./Grow-d70e9b6d.js";import"./TablePagination-63129eb6.js";import"./KeyboardArrowRight-8e772e39.js";import"./LastPage-aa82a010.js";import"./Toolbar-0ec32807.js";import"./MenuItem-dc2bf765.js";import"./dividerClasses-ea2ed133.js";import"./listItemTextClasses-2547faff.js";import"./listItemIconClasses-20c36342.js";import"./index.esm-91b69e04.js";import"./Divider-e1d32c28.js";import"./FilterFilled-40058e95.js";import"./AntdIcon-b932f733.js";import"./objectSpread2-13a56fdb.js";import"./index-125b1c7e.js";import"./GenericThumbnailView-fac7773c.js";import"./createClass-227e27b6.js";import"./popper-f3391c26.js";import"./ScrollableList-2ee889f8.js";import"./CircularProgress-672898c5.js";import"./FormInput-77541d96.js";import"./FormControlLabel-b2fabe81.js";import"./Checkbox-84b6779a.js";import"./SwitchBase-4fa73d90.js";import"./componentStyles-7d84c389.js";import"./TextArea-20f097f8.js";import"./DialogContent-e2578cbd.js";import"./DialogTitle-4a5aec12.js";import"./DialogContentText-bc10bf8d.js";import"./DialogActions-ad26e3d6.js";import"./index-e5978b8b.js";import"./isMuiElement-c29cfc23.js";const it=()=>{const a=Y(),[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:M,searchValue:ue,masterValue:b,masterEditId:z},system:{userAccessList:r}}=G(e=>({document:L(e),system:Q(e)})),I=[{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)},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(U,{justifyContent:"start",alignItems:"center",sx:{display:"flex",gap:2},children:[(r==null?void 0:r.indexOf("Masters.change_document"))!==-1&&t.jsx(X,{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(J,{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(K,{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 T(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:M,columns:I,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:z,mastersValue:b})]})};export{it as default};
