import{b as L,e8 as N,r as p,v_ as $,F as A,j as t,B as V,b2 as Y,v as G,T as K,K as f,v$ as n,Q as x,Y as Q,w0 as W}from"./index-43bf7a1c.js";import{T as q}from"./index-2d303f1d.js";import{M as H}from"./MasterPageTitle-e54f2b5e.js";import{u as J}from"./index.esm-0548c843.js";import{o as U}from"./yup-3b80ed10.js";import{c as X,b as Z}from"./index.esm-f9e0a906.js";import{P as w}from"./Menu-362130d3.js";import{T as ee}from"./TextField-4da97115.js";import{I as te}from"./InputAdornment-b1a1aa58.js";import"./TableContainer-b977c6cc.js";import"./TableRow-86264944.js";import"./Skeleton-ed4df299.js";import"./index-5757b954.js";import"./useMediaQuery-d6627623.js";import"./TableHead-fb4972c5.js";import"./createSvgIcon-f118be02.js";import"./TablePagination-9147f93d.js";import"./Select-44fd3147.js";import"./OutlinedInput-6bcf3cf8.js";import"./useFormControl-2c5d60c2.js";import"./List-6fcc4821.js";import"./useControlled-ab567149.js";import"./MenuItem-58b8887e.js";import"./dividerClasses-497df10c.js";import"./listItemTextClasses-0ea25cee.js";import"./KeyboardArrowRight-8bd7c13f.js";import"./index.esm-d1bd9bb6.js";import"./FilterFilled-ccc86e02.js";import"./AntdIcon-634507e8.js";import"./objectSpread2-c31b885b.js";import"./presets-bb9bdfd8.js";import"./Grow-ca573f65.js";import"./FormControl-8d011aab.js";import"./InputLabel-6c7474f0.js";const Ve=()=>{const r=L(),o=N();p.useState(!1);const[h,g]=p.useState(null),T=!!h,[l,v]=p.useState(null),{pdfTemplates:{pdfTemplatesList:j,pageParams:a,loading:P,pdfTemplatesCount:y},mini:{miniLocationList:ae,miniLocationLoading:ie,miniLocationParams:se},system:{userAccessList:s}}=$(),u=A(),C=[{title:"S.No",width:10},{title:"Code",width:10},{title:"Name",width:10},{title:"Actions",width:10}];function S(e,i,c,d){return{index:e,code:i,name:c,actions:d}}let z=X({search:Z()});const{control:re,handleSubmit:_,register:b,reset:oe}=J({resolver:U(z),values:{search:a.search}}),I=(e,i)=>{v(i),g(e.currentTarget)},m=()=>{g(null)},F=e=>{r(W({id:e,clearDataFn:()=>{m()},navigate:()=>{},pageParams:{...a,search:"",page:1,page_size:10}}))},O=j.map((e,i)=>{const c=(a.page-1)*a.page_size+(i+1),d=t.jsxs(V,{justifyContent:"start",alignItems:"center",sx:{display:"flex",gap:2},children:[(s==null?void 0:s.indexOf("Reports.change_pdftemplate"))!==-1&&t.jsx(Y,{style:{cursor:"pointer",color:"#fc6f03"},onClick:()=>{u("/pages/masters/pdf_templates/"+(e==null?void 0:e.id))}}),(s==null?void 0:s.indexOf("Reports.delete_pdftemplate"))!==-1&&t.jsxs(t.Fragment,{children:[t.jsx(G,{style:{cursor:"pointer",color:"#fc6f03"},onClick:E=>I(E,e==null?void 0:e.id)}),t.jsx(w,{id:l?String(l):void 0,open:T,anchorEl:h,onClose:m,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:t.jsxs("div",{style:{padding:"15px"},children:[t.jsx(K,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),t.jsx(f,{variant:"contained",type:"submit",color:"primary",onClick:()=>{F(l)},autoFocus:!0,children:"Yes"}),t.jsx(f,{variant:"outlined",size:"small",onClick:m,style:{marginLeft:"20px"},children:"No"})]})})]})]});return S(c,e.code,e.name,d)}),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 M=e=>{u("/pages/masters/pdf_templates/0")},D=e=>{const i=e.target.value;r(n({...a,search:i||"",page:1,page_size:10}))};return t.jsx(t.Fragment,{children:t.jsxs(H,{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:M,pageText:"",children:[t.jsx("form",{action:"",onSubmit:_(R),children:t.jsx(x,{container:!0,my:2,spacing:2,children:t.jsx(x,{children:t.jsx(ee,{type:"text",sx:{width:"500px"},...b("search"),id:"input-with-icon-textfield",size:"small",InputProps:{startAdornment:t.jsx(te,{position:"start",children:t.jsx(Q,{size:16})})},fullWidth:!0,variant:"outlined",placeholder:"Search",onChange:D})})})}),t.jsx(q,{count:y,columns:C,rows:O,loading:P,page:a.page,pageSize:a.page_size,handleChangePage:k,handleChangeRowsPerPage:B})]})})};export{Ve as default};
