import{b as L,e8 as N,r as p,vV as V,F as A,j as t,B as W,b2 as Y,v as $,T as G,K as f,vW as n,Q as x,Y as K,vX as Q}from"./index-76d4793e.js";import{T as X}from"./index-1fae9bc3.js";import{M as q}from"./MasterPageTitle-e8b467fa.js";import{u as H}from"./index.esm-3adfd9f7.js";import{o as J}from"./yup-688ec4f6.js";import{c as U,b as Z}from"./index.esm-ad8a7c9f.js";import{P as w}from"./Menu-ed7c6894.js";import{T as ee}from"./TextField-9c64a4a2.js";import{I as te}from"./InputAdornment-b99403ce.js";import"./TableContainer-4147c2f3.js";import"./TableRow-736f36bd.js";import"./Skeleton-5d9101fd.js";import"./index-85763c32.js";import"./useMediaQuery-8cb39c65.js";import"./TableHead-c6031541.js";import"./createSvgIcon-01ec10fc.js";import"./TablePagination-5e47b2d0.js";import"./Select-338083eb.js";import"./OutlinedInput-ac933786.js";import"./useFormControl-c8d490e1.js";import"./List-4c24b3e8.js";import"./useControlled-e03384de.js";import"./MenuItem-cff1abce.js";import"./dividerClasses-45958eb8.js";import"./listItemTextClasses-89e7894e.js";import"./KeyboardArrowRight-8920e265.js";import"./index.esm-d9f89842.js";import"./FilterFilled-aa7d40e4.js";import"./AntdIcon-55dc1b5f.js";import"./objectSpread2-51b6810f.js";import"./Grow-84b30c0e.js";import"./FormControl-c671c595.js";import"./InputLabel-5ed57f0e.js";const Ae=()=>{const r=L(),o=N();p.useState(!1);const[h,g]=p.useState(null),v=!!h,[l,T]=p.useState(null),{pdfTemplates:{pdfTemplatesList:j,pageParams:a,loading:P,pdfTemplatesCount:y},mini:{miniLocationList:ae,miniLocationLoading:se,miniLocationParams:ie},system:{userAccessList:i}}=V(),u=A(),C=[{title:"S.No",width:10},{title:"Code",width:10},{title:"Name",width:10},{title:"Actions",width:10}];function S(e,s,c,d){return{index:e,code:s,name:c,actions:d}}let z=U({search:Z()});const{control:re,handleSubmit:b,register:_,reset:oe}=H({resolver:J(z),values:{search:a.search}}),I=(e,s)=>{T(s),g(e.currentTarget)},m=()=>{g(null)},F=e=>{r(Q({id:e,clearDataFn:()=>{m()},navigate:()=>{},pageParams:{...a,search:"",page:1,page_size:10}}))},O=j.map((e,s)=>{const c=(a.page-1)*a.page_size+(s+1),d=t.jsxs(W,{justifyContent:"start",alignItems:"center",sx:{display:"flex",gap:2},children:[(i==null?void 0:i.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))}}),(i==null?void 0:i.indexOf("Reports.delete_pdftemplate"))!==-1&&t.jsxs(t.Fragment,{children:[t.jsx($,{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:v,anchorEl:h,onClose:m,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:t.jsxs("div",{style:{padding:"15px"},children:[t.jsx(G,{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,s)=>{r(n({...a,search:"",page:s+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 s=e.target.value;r(n({...a,search:s||"",page:1,page_size:10}))};return t.jsx(t.Fragment,{children:t.jsxs(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:M,pageText:"",children:[t.jsx("form",{action:"",onSubmit:b(R),children:t.jsx(x,{container:!0,my:2,spacing:2,children:t.jsx(x,{children:t.jsx(ee,{type:"text",sx:{width:"500px"},..._("search"),id:"input-with-icon-textfield",size:"small",InputProps:{startAdornment:t.jsx(te,{position:"start",children:t.jsx(K,{size:16})})},fullWidth:!0,variant:"outlined",placeholder:"Search",onChange:D})})})}),t.jsx(X,{count:y,columns:C,rows:O,loading:P,page:a.page,pageSize:a.page_size,handleChangePage:k,handleChangeRowsPerPage:B})]})})};export{Ae as default};
