import{d as E,b4 as N,r as p,kZ as L,z as A,j as t,B as V,T as $,R as f,py as n,_ as Y,pz as Z}from"./index-858224db.js";import{M as q}from"./MasterPageTitle-cb9528e3.js";import{c as G,b as H,u as J}from"./index.esm-241dec99.js";import{o as K}from"./yup-9213c3af.js";import{d as Q}from"./Delete-5ebded29.js";import{e as U}from"./Edit-abad5e84.js";import{C as W}from"./index-d0523d92.js";import{P as X}from"./Select-8b602eed.js";import{T as w}from"./TextField-bbb2480f.js";import{I as ee}from"./InputAdornment-583927e5.js";import"./index.esm-20949d74.js";import"./Divider-262150be.js";import"./dividerClasses-3bf2d765.js";import"./FilterFilled-4ddeca5a.js";import"./AntdIcon-8f3bee6f.js";import"./objectSpread2-cfd43bb2.js";import"./index-9223140c.js";import"./Grow-b7b43b3f.js";import"./componentStyles-107bd37e.js";import"./TableRow-ef998644.js";import"./TableContainer-0664e137.js";import"./TableHead-cf76ecee.js";import"./TablePagination-4cf72ac4.js";import"./KeyboardArrowRight-b25c72ab.js";import"./LastPage-c7260b25.js";import"./Toolbar-9be5abc1.js";import"./MenuItem-bf5218a0.js";import"./listItemTextClasses-ac0d77df.js";import"./listItemIconClasses-5ed9cb9d.js";import"./index-e5978b8b.js";import"./isMuiElement-ec705bc2.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}}=L(),u=A(),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 y=G({search:H()});const{control:se,handleSubmit:S,register:_,reset:oe}=J({resolver:K(y),values:{search:a.search}}),b=(e,i)=>{T(i),g(e.currentTarget)},m=()=>{g(null)},I=e=>{o(Z({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(V,{justifyContent:"center",alignItems:"center",sx:{display:"flex",gap:2},children:[(s==null?void 0:s.indexOf("Reports.change_pdftemplate"))!==-1&&t.jsx("img",{src:U,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:D=>b(D,e==null?void 0:e.id)}),t.jsx(X,{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($,{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)}),k=({search:e})=>{o(n({...a,search:e||"",page:1,page_size:10}))},O=(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(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:F,pageText:"",searchComponent:t.jsx("form",{onSubmit:S(k),children:t.jsx(w,{type:"text",sx:{width:"300px"},..._("search"),size:"small",InputProps:{startAdornment:t.jsx(ee,{position:"start",children:t.jsx(Y,{size:16})})},variant:"outlined",placeholder:"Search",onChange:M})}),children:t.jsx(W,{count:P,columns:C,rows:R,loading:v,page:a.page,pageSize:a.page_size,handleChangePage:O,handleChangeRowsPerPage:B,showPagination:!0})})})};export{Ne as default};
