import{d as q,r as c,b4 as G,a as Q,n_ as W,b as Z,j as t,B as H,e_ as J,pY as K,pZ as f,Q as L,T as U,R as j,p_ as n,o0 as X,p$ as w,ks as ee,_ as te,q0 as ae}from"./index-83d9c1e2.js";import{T as se}from"./index-cc00c6a4.js";import{M as oe}from"./MasterPageTitle-9ab56f94.js";import{A as re}from"./add.document-d177fdbe.js";import{c as ie,b as ne,u as ce}from"./index.esm-82874186.js";import{o as le}from"./yup-dfe9f223.js";import{P as pe}from"./Select-1505055e.js";import{T as me}from"./TextField-39c52322.js";import{I as de}from"./InputAdornment-4b0a9854.js";import"./TableRow-1c35ea2a.js";import"./useMediaQuery-c67ad591.js";import"./TableContainer-98997305.js";import"./TableHead-95baa189.js";import"./Grow-6cc6748b.js";import"./TablePagination-81b30c1b.js";import"./KeyboardArrowRight-b7bab219.js";import"./Toolbar-25a41873.js";import"./MenuItem-26e66f0f.js";import"./dividerClasses-f18f0f93.js";import"./listItemTextClasses-fcd068d2.js";import"./index.esm-316fec71.js";import"./Divider-71865361.js";import"./FilterFilled-eb3492a9.js";import"./AntdIcon-f9724de9.js";import"./objectSpread2-e5f2d908.js";import"./index-1ceef347.js";import"./GenericThumbnailView-ceecb14e.js";import"./popper-f3391c26.js";import"./ScrollableList-2bb71a63.js";import"./CircularProgress-3ce9da74.js";import"./FormInput-03b7722e.js";import"./FormControlLabel-af5c9791.js";import"./Checkbox-fe0b2cdb.js";import"./SwitchBase-ad42caec.js";import"./componentStyles-7858e543.js";import"./TextArea-7d949f4d.js";import"./DialogContent-a75c4d06.js";import"./DialogTitle-3c642f58.js";import"./DialogContentText-ab545101.js";import"./DialogActions-3c3ab24c.js";import"./index-e5978b8b.js";import"./isMuiElement-5c2699ea.js";const st=()=>{const a=q(),[S,u]=c.useState(!1);c.useState("");const i=G(),[h,g]=c.useState(null),y=!!h,[l,D]=c.useState(null),{document:{documentList:v,pageParams:s,loading:C,documentCount:_,searchValue:ue,masterValue:M,masterEditId:b},system:{userAccessList:r}}=Q(e=>({document:W(e),system:Z(e)})),z=[{title:"S.No",width:100},{title:"Code",width:100},{title:"Name",width:100},{title:"Actions",width:100}];function I(e,o,m,d){return{index:e,code:o,name:m,actions:d}}let T=ie({search:ne()});const{control:he,handleSubmit:P,register:O,reset:k}=ce({resolver:le(T),values:{search:s.search}}),B=(e,o)=>{D(o),g(e.currentTarget)},p=()=>{g(null)},E=e=>{a(ae({id:e,clearDataFn:()=>{},navigate:o=>{},pageParams:s})),a(n({...s,search:"",page:1,page_size:10})),p()},F=v.map((e,o)=>{const m=(s.page-1)*s.page_size+(o+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:Y=>B(Y,e==null?void 0:e.id)}),t.jsx(pe,{id:l?String(l):void 0,open:y,anchorEl:h,onClose:p,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:t.jsxs("div",{style:{padding:"15px"},children:[t.jsx(U,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),t.jsx(j,{variant:"contained",type:"submit",color:"primary",onClick:()=>{E(l)},autoFocus:!0,children:"Yes"}),t.jsx(j,{variant:"outlined",size:"small",onClick:p,style:{marginLeft:"20px"},children:"No"})]})})]})]});return I(m,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"),k({search:""})},[]);const x=e=>{a(f(0)),a(X({})),u(e),a(w(e))},R=()=>{u(!1)},$=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(me,{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:$})})}),t.jsx(se,{count:_,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{st as default};
