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-def636a4.js";import{T as q}from"./index-fc769754.js";import{M as H}from"./MasterPageTitle-bbea54a4.js";import{u as J}from"./index.esm-7d9d1491.js";import{o as U}from"./yup-c8535458.js";import{c as X,b as Z}from"./index.esm-eec4f448.js";import{P as w}from"./Menu-af49d134.js";import{T as ee}from"./TextField-2ba95a45.js";import{I as te}from"./InputAdornment-196a5386.js";import"./TableContainer-5944247b.js";import"./TableRow-2c544f58.js";import"./Skeleton-5cf57ed1.js";import"./index-b5a6fbe3.js";import"./useMediaQuery-4304fb25.js";import"./TableHead-f0476938.js";import"./createSvgIcon-ff487f53.js";import"./TablePagination-7d3b42e9.js";import"./Select-2cfb5afd.js";import"./OutlinedInput-ddb8bb3f.js";import"./useFormControl-880b2f7b.js";import"./List-17cd485b.js";import"./useControlled-bd643819.js";import"./MenuItem-8fdd2340.js";import"./dividerClasses-2b953c2a.js";import"./listItemTextClasses-063fcacf.js";import"./KeyboardArrowRight-bfb3d848.js";import"./index.esm-c912dbcd.js";import"./FilterFilled-08c5b5a7.js";import"./AntdIcon-34324527.js";import"./objectSpread2-a4d0f5f6.js";import"./presets-dbb0f3bf.js";import"./Grow-85576dd3.js";import"./FormControl-1f811046.js";import"./InputLabel-e2e73b27.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};
