import{d as E,b6 as N,r as p,lA as A,z as L,j as t,B as q,T as V,R as f,q9 as n,_ as $,qa as Y}from"./index-e0c07a84.js";import{M as G}from"./MasterPageTitle-10ea7f2b.js";import{c as H,b as J,u as K}from"./index.esm-79617ba5.js";import{o as Q}from"./yup-74a95d85.js";import{d as U}from"./Delete-5ebded29.js";import{e as W}from"./Edit-abad5e84.js";import{C as X}from"./index-2eb663b6.js";import{P as Z}from"./Select-a8f8fd6a.js";import{T as w}from"./TextField-23174150.js";import{I as ee}from"./InputAdornment-bf957c61.js";import"./index.esm-68061338.js";import"./Divider-ee8faca1.js";import"./dividerClasses-6c6c8dc7.js";import"./FilterFilled-80640201.js";import"./AntdIcon-bc64d1d9.js";import"./objectSpread2-f946b5f0.js";import"./index-c7a54fed.js";import"./Grow-5c4c469c.js";import"./componentStyles-5432a72d.js";import"./TableRow-248ce459.js";import"./TableContainer-84b94d99.js";import"./TableHead-3bf23892.js";import"./TablePagination-da0d0adf.js";import"./KeyboardArrowRight-aeb4c8ed.js";import"./LastPage-d8600c66.js";import"./Toolbar-c85ba7f8.js";import"./MenuItem-9dcf8782.js";import"./listItemTextClasses-e9c46ccd.js";import"./listItemIconClasses-129e65e5.js";import"./index-e5978b8b.js";import"./isMuiElement-953ce284.js";const Ne=()=>{const o=E(),r=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:P},mini:{miniLocationList:te,miniLocationLoading:ae,miniLocationParams:ie},system:{userAccessList:s}}=A(),u=L(),C=[{title:"S.No",width:10},{title:"Code",width:10},{title:"Name",width:10},{title:"Actions",width:10}];function z(e,i,d,c){return{index:e,code:i,name:d,actions:c}}let S=H({search:J()});const{control:se,handleSubmit:y,register:_,reset:oe}=K({resolver:Q(S),values:{search:a.search}}),b=(e,i)=>{T(i),g(e.currentTarget)},m=()=>{g(null)},I=e=>{o(Y({id:e,clearDataFn:()=>{m()},navigate:()=>{},pageParams:{...a,search:"",page:1,page_size:10}}))},R=j.map((e,i)=>{const d=(a.page-1)*a.page_size+(i+1),c=t.jsxs(q,{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:U,alt:"edit",style:{cursor:"pointer",width:"15px",height:"15px"},onClick:D=>b(D,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 z(d,e.code,e.name,c)}),O=({search:e})=>{o(n({...a,search:e||"",page:1,page_size:10}))},k=(e,i)=>{o(n({...a,search:"",page:i+1}))},B=e=>{o(n({...a,search:"",page:1,page_size:parseInt(e.target.value)}))};p.useEffect(()=>{o(n({...a,search:"",page:1,page_size:10})),r==null||r.setTitle("PdfTemplates"),r==null||r.setSubtitle("Masters")},[]);const F=e=>{u("/pages/masters/pdf_template/0")},M=e=>{const i=e.target.value;o(n({...a,search:i||"",page:1,page_size:10}))};return t.jsx(t.Fragment,{children:t.jsx(G,{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:F,pageText:"",searchComponent:t.jsx("form",{onSubmit:y(O),children:t.jsx(w,{type:"text",sx:{width:"300px"},..._("search"),size:"small",InputProps:{startAdornment:t.jsx(ee,{position:"start",children:t.jsx($,{size:16})})},variant:"outlined",placeholder:"Search",onChange:M})}),children:t.jsx(X,{count:P,columns:C,rows:R,loading:v,page:a.page,pageSize:a.page_size,handleChangePage:k,handleChangeRowsPerPage:B,showPagination:!0})})})};export{Ne as default};
