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-60a3c753.js";import{T as q}from"./index-7e55cf46.js";import{M as H}from"./MasterPageTitle-8a6edc29.js";import{u as J}from"./index.esm-c494934a.js";import{o as U}from"./yup-92678dde.js";import{c as X,b as Z}from"./index.esm-62d6b2f7.js";import{P as w}from"./Menu-d1b7e1c3.js";import{T as ee}from"./TextField-32b29087.js";import{I as te}from"./InputAdornment-96c40dce.js";import"./TableContainer-414c12e0.js";import"./TableRow-0b33776c.js";import"./Skeleton-98c353d9.js";import"./index-a99c9f65.js";import"./useMediaQuery-dba48e3b.js";import"./TableHead-f864c753.js";import"./createSvgIcon-de433e5f.js";import"./TablePagination-218dde38.js";import"./Select-99fc0d84.js";import"./OutlinedInput-3a884178.js";import"./useFormControl-e13b5747.js";import"./List-f567f8e4.js";import"./useControlled-194ef007.js";import"./MenuItem-2f410bd2.js";import"./dividerClasses-3fa67596.js";import"./listItemTextClasses-36afdb92.js";import"./KeyboardArrowRight-b2645aed.js";import"./index.esm-8ea8e217.js";import"./FilterFilled-cdde02db.js";import"./AntdIcon-bed41c21.js";import"./objectSpread2-85813881.js";import"./presets-06d13753.js";import"./Grow-68442588.js";import"./FormControl-d13d2693.js";import"./InputLabel-71dfc9d4.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};
