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-c3f592b2.js";import{M as q}from"./MasterPageTitle-eaa6f939.js";import{c as G,b as H,u as J}from"./index.esm-70dd1c06.js";import{o as K}from"./yup-abb4a026.js";import{d as Q}from"./Delete-5ebded29.js";import{e as W}from"./Edit-abad5e84.js";import{C as X}from"./index-14d7673e.js";import{P as Z}from"./Select-9d10c4ab.js";import{T as w}from"./TextField-7d0d5009.js";import{I as ee}from"./InputAdornment-fd596377.js";import"./index.esm-1314deac.js";import"./Divider-057a9865.js";import"./dividerClasses-03c42ea7.js";import"./FilterFilled-90800ccd.js";import"./AntdIcon-b07622f5.js";import"./objectSpread2-890c3efa.js";import"./index-78da10f4.js";import"./LastPage-4fb40c42.js";import"./TableRow-974e102e.js";import"./Grow-f61cc5ca.js";import"./KeyboardArrowRight-ee7691b4.js";import"./componentStyles-b8fcedb5.js";import"./TableContainer-a7e6bb64.js";import"./TableHead-98885dba.js";import"./TablePagination-fd957a04.js";import"./KeyboardArrowRight-8b3fa289.js";import"./LastPage-a52503ff.js";import"./Toolbar-ac8f3726.js";import"./MenuItem-e7a45c4b.js";import"./listItemTextClasses-3ff99335.js";import"./listItemIconClasses-b60c7a41.js";import"./isMuiElement-43203123.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};
