import{d as Q,r as c,b7 as W,a as Y,pA as q,b as H,j as t,B as J,eI as K,ry as L,rz as f,Q as U,T as X,R as j,rA as n,pC as Z,rB as w,lR as ee,_ as te,rC as ae}from"./index-952e178b.js";import{T as re}from"./index-baa25e61.js";import{M as se}from"./MasterPageTitle-7665a485.js";import{A as oe}from"./add.document-2ba11e01.js";import{c as ie,b as ne,u as ce}from"./index.esm-6feddb16.js";import{o as le}from"./yup-d92565dd.js";import{P as me}from"./Select-41d78585.js";import{T as pe}from"./TextField-d1a887ff.js";import{I as de}from"./InputAdornment-020147de.js";import"./TableRow-6a27d7f4.js";import"./useMediaQuery-86e0ce33.js";import"./TableContainer-e3ecf13b.js";import"./TableHead-e31d41f4.js";import"./TablePagination-b93979a3.js";import"./KeyboardArrowRight-c3d685e2.js";import"./LastPage-54692111.js";import"./Toolbar-201b514b.js";import"./MenuItem-f41722f4.js";import"./dividerClasses-8e897c94.js";import"./listItemTextClasses-ca40551b.js";import"./listItemIconClasses-3e4286ad.js";import"./index.esm-70af4911.js";import"./Divider-342f1cfc.js";import"./FilterFilled-1ab4da14.js";import"./AntdIcon-54006664.js";import"./objectSpread2-a71852a2.js";import"./index-22eb3e7f.js";import"./GenericThumbnailView-4e535459.js";import"./createClass-5a32667f.js";import"./popper-f3391c26.js";import"./ScrollableList-cd5816a8.js";import"./CircularProgress-3b605689.js";import"./FormInput-8320115a.js";import"./FormControlLabel-973be654.js";import"./Checkbox-6c7c4dc0.js";import"./SwitchBase-bd5cc4c6.js";import"./componentStyles-00160cc0.js";import"./TextArea-ce7716c9.js";import"./DialogContent-4facb916.js";import"./DialogTitle-3aa960f8.js";import"./DialogContentText-54d95680.js";import"./DialogActions-bd200b72.js";import"./index-e5978b8b.js";import"./isMuiElement-f03a71e4.js";const ot=()=>{const a=Q(),[y,u]=c.useState(!1);c.useState("");const i=W(),[h,g]=c.useState(null),S=!!h,[l,C]=c.useState(null),{document:{documentList:D,pageParams:r,loading:v,documentCount:z,searchValue:ue,masterValue:I,masterEditId:M},system:{userAccessList:o}}=Y(e=>({document:q(e),system:H(e)})),b=[{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:B,reset:O}=ce({resolver:le(_),values:{search:r.search}}),A=(e,s)=>{C(s),g(e.currentTarget)},m=()=>{g(null)},E=e=>{a(ae({id:e,clearDataFn:()=>{},navigate:s=>{},pageParams:r})),a(n({...r,search:"",page:1,page_size:10})),m()},k=D.map((e,s)=>{const p=(r.page-1)*r.page_size+(s+1),d=t.jsxs(J,{justifyContent:"start",alignItems:"center",sx:{display:"flex",gap:2},children:[(o==null?void 0:o.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))}}),(o==null?void 0:o.indexOf("Masters.delete_document"))!==-1&&t.jsxs(t.Fragment,{children:[t.jsx(U,{style:{cursor:"pointer",color:"#fc6f03"},onClick:G=>A(G,e==null?void 0:e.id)}),t.jsx(me,{id:l?String(l):void 0,open:S,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:()=>{E(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({...r,search:e||"",page:1,page_size:10}))},V=(e,s)=>{a(n({...r,search:"",page:s+1}))},R=e=>{a(n({...r,search:"",page:1,page_size:parseInt(e.target.value)}))};c.useEffect(()=>{a(n({...r,search:"",page:1,page_size:10})),i==null||i.setTitle("Document"),i==null||i.setSubtitle("Masters"),O({search:""})},[]);const x=e=>{a(f(0)),a(Z({})),u(e),a(w(e))},N=()=>{u(!1)},$=e=>{const s=e.target.value;a(n({...r,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:(o==null?void 0:o.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"},...B("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(re,{count:z,columns:b,rows:k,loading:v,page:r.page,pageSize:r.page_size,handleChangePage:V,handleChangeRowsPerPage:R})]}),t.jsx(oe,{modal:y,closeModal:N,mastersName:"Document",edit_Id:M,mastersValue:I})]})};export{ot as default};
