import{d as G,r as c,b8 as K,a as U,qh as W,b as Y,j as t,B as H,eK as J,sh as L,si as f,R as Q,T as X,U as j,sj as n,qj as Z,sk as w,my as ee,$ as te,sl as ae}from"./index-c3f592b2.js";import{T as se}from"./index-6f96a8b8.js";import{M as oe}from"./MasterPageTitle-eaa6f939.js";import{A as re}from"./add.document-d50e636c.js";import{c as ie,b as ne,u as ce}from"./index.esm-70dd1c06.js";import{o as le}from"./yup-abb4a026.js";import{P as me}from"./Select-9d10c4ab.js";import{T as pe}from"./TextField-7d0d5009.js";import{I as de}from"./InputAdornment-fd596377.js";import"./TableRow-974e102e.js";import"./index-88943ce1.js";import"./TableContainer-a7e6bb64.js";import"./TableHead-98885dba.js";import"./Grow-f61cc5ca.js";import"./TablePagination-fd957a04.js";import"./KeyboardArrowRight-8b3fa289.js";import"./LastPage-a52503ff.js";import"./Toolbar-ac8f3726.js";import"./MenuItem-e7a45c4b.js";import"./dividerClasses-03c42ea7.js";import"./listItemTextClasses-3ff99335.js";import"./listItemIconClasses-b60c7a41.js";import"./index.esm-1314deac.js";import"./Divider-057a9865.js";import"./FilterFilled-90800ccd.js";import"./AntdIcon-b07622f5.js";import"./objectSpread2-890c3efa.js";import"./index-78da10f4.js";import"./GenericThumbnailView-9f1d2f81.js";import"./createClass-c7973e27.js";import"./popper-f3391c26.js";import"./ScrollableList-ecbfc0f3.js";import"./FormInput-adbf55b1.js";import"./FormControlLabel-3f9f7a84.js";import"./Checkbox-38171bff.js";import"./SwitchBase-38103115.js";import"./componentStyles-b8fcedb5.js";import"./TextArea-674a9ec6.js";import"./DialogContent-b7fc1c43.js";import"./DialogTitle-5d3e2030.js";import"./DialogContentText-c3e782dc.js";import"./DialogActions-6e00f4f1.js";import"./isMuiElement-43203123.js";const ot=()=>{const a=G(),[y,u]=c.useState(!1);c.useState("");const i=K(),[h,g]=c.useState(null),S=!!h,[l,D]=c.useState(null),{document:{documentList:v,pageParams:s,loading:C,documentCount:M,searchValue:ue,masterValue:b,masterEditId:z},system:{userAccessList:r}}=U(e=>({document:W(e),system:Y(e)})),I=[{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:k}=ce({resolver:le(_),values:{search:s.search}}),B=(e,o)=>{D(o),g(e.currentTarget)},m=()=>{g(null)},E=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(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(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(Q,{style:{cursor:"pointer",color:"#fc6f03"},onClick:q=>B(q,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)}),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(Z({})),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(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:$})})}),t.jsx(se,{count:M,columns:I,rows:F,loading:C,page:s.page,pageSize:s.page_size,handleChangePage:A,handleChangeRowsPerPage:N})]}),t.jsx(re,{modal:y,closeModal:R,mastersName:"Document",edit_Id:z,mastersValue:b})]})};export{ot as default};
