import{d as E,b8 as N,r as p,n0 as A,A as L,j as t,B as $,T as V,U as f,rC as n,$ as U,rD as Y}from"./index-60657852.js";import{M as q}from"./MasterPageTitle-4d4d4430.js";import{c as G,b as H,u as J}from"./index.esm-509a598d.js";import{o as K}from"./yup-75ad371b.js";import{d as Q}from"./Delete-5ebded29.js";import{e as W}from"./Edit-abad5e84.js";import{C as X}from"./index-61d7dc47.js";import{P as Z}from"./Select-7d2a5359.js";import{T as w}from"./TextField-6b778b78.js";import{I as ee}from"./InputAdornment-12fc79ce.js";import"./index.esm-5fae0aa9.js";import"./Divider-6555f8d4.js";import"./dividerClasses-590294d7.js";import"./FilterFilled-e5a9bf0e.js";import"./AntdIcon-53906b68.js";import"./objectSpread2-b46e5e65.js";import"./index-980acb6c.js";import"./LastPage-71f2133b.js";import"./TableRow-0ab1e69a.js";import"./Grow-a21bdd26.js";import"./KeyboardArrowRight-450d5bb8.js";import"./componentStyles-19763afb.js";import"./TableContainer-c3087864.js";import"./TableHead-1ba4d27d.js";import"./TablePagination-dd506b19.js";import"./KeyboardArrowRight-5039311c.js";import"./LastPage-c4cc7e5b.js";import"./Toolbar-e6f520d9.js";import"./MenuItem-64348b57.js";import"./listItemTextClasses-81f8effc.js";import"./listItemIconClasses-39f47a05.js";import"./isMuiElement-82a67859.js";const Ae=()=>{const r=E(),o=N();p.useState(!1);const[h,g]=p.useState(null),x=!!h,[l,T]=p.useState(null),{pdfTemplates:{pdfTemplatesList:j,pageParams:a,loading:v,pdfTemplatesCount:C},mini:{miniLocationList:te,miniLocationLoading:ae,miniLocationParams:ie},system:{userAccessList:s}}=A(),u=L(),P=[{title:"S.No",width:10},{title:"Code",width:10},{title:"Name",width:10},{title:"Actions",width:10}];function S(e,i,d,c){return{index:e,code:i,name:d,actions:c}}let y=G({search:H()});const{control:se,handleSubmit:z,register:_,reset:re}=J({resolver:K(y),values:{search:a.search}}),b=(e,i)=>{T(i),g(e.currentTarget)},m=()=>{g(null)},I=e=>{r(Y({id:e,clearDataFn:()=>{m()},navigate:()=>{},pageParams:{...a,search:"",page:1,page_size:10}}))},O=j.map((e,i)=>{const d=(a.page-1)*a.page_size+(i+1),c=t.jsxs($,{justifyContent:"center",alignItems:"center",sx:{display:"flex",gap:2},children:[(s==null?void 0:s.indexOf("Reports.change_pdftemplate"))!==-1&&t.jsx("img",{src:W,alt:"edit",style:{cursor:"pointer",width:"15px",height:"15px"},onClick:()=>{u("/pages/masters/pdf_template/"+(e==null?void 0:e.id))}}),(s==null?void 0:s.indexOf("Reports.delete_pdftemplate"))!==-1&&t.jsxs(t.Fragment,{children:[t.jsx("img",{src:Q,alt:"edit",style:{cursor:"pointer",width:"15px",height:"15px"},onClick:M=>b(M,e==null?void 0:e.id)}),t.jsx(Z,{id:l?String(l):void 0,open:x,anchorEl:h,onClose:m,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:t.jsxs("div",{style:{padding:"15px"},children:[t.jsx(V,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),t.jsx(f,{variant:"contained",type:"submit",color:"primary",onClick:()=>{I(l)},autoFocus:!0,children:"Yes"}),t.jsx(f,{variant:"outlined",size:"small",onClick:m,style:{marginLeft:"20px"},children:"No"})]})})]})]});return S(d,e.code,e.name,c)}),R=({search:e})=>{r(n({...a,search:e||"",page:1,page_size:10}))},k=(e,i)=>{r(n({...a,search:"",page:i+1}))},B=e=>{r(n({...a,search:"",page:1,page_size:parseInt(e.target.value)}))};p.useEffect(()=>{r(n({...a,search:"",page:1,page_size:10})),o==null||o.setTitle("PdfTemplates"),o==null||o.setSubtitle("Masters")},[]);const D=e=>{u("/pages/masters/pdf_template/0")},F=e=>{const i=e.target.value;r(n({...a,search:i||"",page:1,page_size:10}))};return t.jsx(t.Fragment,{children:t.jsx(q,{prefix:"Reports",postfix:"pdftemplate",pageTitle:"Pdf Template",goBack:!0,addModelTile:(s==null?void 0:s.indexOf("Reports.add_pdftemplate"))!==-1?"Add Template":void 0,modalVisible:!0,setIsModalVisible:D,pageText:"",searchComponent:t.jsx("form",{onSubmit:z(R),children:t.jsx(w,{type:"text",sx:{width:"300px"},..._("search"),size:"small",InputProps:{startAdornment:t.jsx(ee,{position:"start",children:t.jsx(U,{size:16})})},variant:"outlined",placeholder:"Search",onChange:F})}),children:t.jsx(X,{count:C,columns:P,rows:O,loading:v,page:a.page,pageSize:a.page_size,handleChangePage:k,handleChangeRowsPerPage:B,showPagination:!0})})})};export{Ae as default};
