import{d as E,b4 as N,r as p,kU as L,z as A,j as t,B as V,T as $,R as f,ph as n,_ as U,pi as Y}from"./index-83d9c1e2.js";import{M as q}from"./MasterPageTitle-9ab56f94.js";import{c as G,b as H,u as J}from"./index.esm-82874186.js";import{o as K}from"./yup-dfe9f223.js";import{d as Q}from"./Delete-5ebded29.js";import{e as W}from"./Edit-abad5e84.js";import{C as X}from"./index-ffc92880.js";import{P as Z}from"./Select-1505055e.js";import{T as w}from"./TextField-39c52322.js";import{I as ee}from"./InputAdornment-4b0a9854.js";import"./index.esm-316fec71.js";import"./Divider-71865361.js";import"./dividerClasses-f18f0f93.js";import"./FilterFilled-eb3492a9.js";import"./AntdIcon-f9724de9.js";import"./objectSpread2-e5f2d908.js";import"./index-1ceef347.js";import"./Grow-6cc6748b.js";import"./componentStyles-7858e543.js";import"./TableRow-1c35ea2a.js";import"./TableContainer-98997305.js";import"./TableHead-95baa189.js";import"./TablePagination-81b30c1b.js";import"./KeyboardArrowRight-b7bab219.js";import"./Toolbar-25a41873.js";import"./MenuItem-26e66f0f.js";import"./listItemTextClasses-fcd068d2.js";import"./index-e5978b8b.js";import"./isMuiElement-5c2699ea.js";const De=()=>{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=A(),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=G({search:H()});const{control:ie,handleSubmit:y,register:_,reset:oe}=J({resolver:K(S),values:{search:a.search}}),b=(e,s)=>{T(s),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,s)=>{const d=(a.page-1)*a.page_size+(s+1),c=t.jsxs(V,{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:Q,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($,{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,s)=>{o(n({...a,search:"",page:s+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 s=e.target.value;o(n({...a,search:s||"",page:1,page_size:10}))};return t.jsx(t.Fragment,{children:t.jsx(q,{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:F,pageText:"",searchComponent:t.jsx("form",{onSubmit:y(k),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:M})}),children:t.jsx(X,{count:P,columns:C,rows:R,loading:v,page:a.page,pageSize:a.page_size,handleChangePage:O,handleChangeRowsPerPage:B,showPagination:!0})})})};export{De as default};
