import{d as E,aV as N,r as p,kB as L,k as V,j as t,B as A,T as $,z as f,p6 as n,M as Y,p7 as q}from"./index-c5c88b67.js";import{M as G}from"./MasterPageTitle-405781d7.js";import{c as H,b as J,u as K}from"./index.esm-81620445.js";import{o as Q}from"./yup-41605283.js";import{d as U}from"./Delete-5ebded29.js";import{e as W}from"./Edit-abad5e84.js";import{C as X}from"./index-e101df4a.js";import{P as Z}from"./Menu-e7d2b2ee.js";import{T as w}from"./TextField-78388962.js";import{I as ee}from"./InputAdornment-d66117f3.js";import"./index.esm-0ad88c35.js";import"./Divider-0dc41916.js";import"./dividerClasses-6bc0ca72.js";import"./FilterFilled-9066fadd.js";import"./AntdIcon-1a0d7a6b.js";import"./objectSpread2-65a0d991.js";import"./index-c98d1d89.js";import"./Grow-7345f8ea.js";import"./componentStyles-a5e5a830.js";import"./TableRow-2b359fa8.js";import"./TableContainer-c31f204a.js";import"./TableHead-c2c21491.js";import"./TablePagination-0147f84a.js";import"./KeyboardArrowRight-261f4f43.js";import"./Toolbar-f8d4b0c4.js";import"./Select-4ed8db5d.js";import"./index-e5978b8b.js";import"./MenuItem-81e44793.js";import"./listItemTextClasses-88792089.js";import"./isMuiElement-b3c21f38.js";const Ee=()=>{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:se},system:{userAccessList:i}}=L(),u=V(),C=[{title:"S.No",width:10},{title:"Code",width:10},{title:"Name",width:10},{title:"Actions",width:10}];function z(e,s,d,c){return{index:e,code:s,name:d,actions:c}}let S=H({search:J()});const{control:ie,handleSubmit:y,register:_,reset:oe}=K({resolver:Q(S),values:{search:a.search}}),I=(e,s)=>{T(s),g(e.currentTarget)},m=()=>{g(null)},b=e=>{o(q({id:e,clearDataFn:()=>{m()},navigate:()=>{},pageParams:{...a,search:"",page:1,page_size:10}}))},k=j.map((e,s)=>{const d=(a.page-1)*a.page_size+(s+1),c=t.jsxs(A,{justifyContent:"center",alignItems:"center",sx:{display:"flex",gap:2},children:[(i==null?void 0:i.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))}}),(i==null?void 0:i.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=>I(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($,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),t.jsx(f,{variant:"contained",type:"submit",color:"primary",onClick:()=>{b(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)}),B=({search:e})=>{o(n({...a,search:e||"",page:1,page_size:10}))},M=(e,s)=>{o(n({...a,search:"",page:s+1}))},O=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 R=e=>{u("/pages/masters/pdf_template/0")},F=e=>{const s=e.target.value;o(n({...a,search:s||"",page:1,page_size:10}))};return t.jsx(t.Fragment,{children:t.jsx(G,{prefix:"Reports",postfix:"pdftemplate",pageTitle:"Pdf Template",goBack:!0,addModelTile:(i==null?void 0:i.indexOf("Reports.add_pdftemplate"))!==-1?"Add Template":void 0,modalVisible:!0,setIsModalVisible:R,pageText:"",searchComponent:t.jsx("form",{onSubmit:y(B),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:F})}),children:t.jsx(X,{count:P,columns:C,rows:k,loading:v,page:a.page,pageSize:a.page_size,handleChangePage:M,handleChangeRowsPerPage:O,showPagination:!0})})})};export{Ee as default};
