import{b as L,eb as N,r as p,wb as A,E as V,j as t,B as Y,b2 as $,t as G,T as J,J as f,wc as n,P as x,Y as W,wd as q}from"./index-d2b25495.js";import{T as w}from"./index-75fca24c.js";import{M as H}from"./MasterPageTitle-86504016.js";import{u as K}from"./index.esm-ce3c2c20.js";import{o as Q}from"./yup-267e586f.js";import{c as U,b as X}from"./index.esm-3043d6d4.js";import{P as Z}from"./Menu-337a466b.js";import{T as ee}from"./TextField-e155d2be.js";import{I as te}from"./InputAdornment-d0c3ebef.js";import"./TableContainer-dd7cf0ce.js";import"./TableRow-74f9cf3b.js";import"./Skeleton-1012c2e6.js";import"./index-1249dfe4.js";import"./useMediaQuery-b1fbc166.js";import"./TableHead-fac214d3.js";import"./createSvgIcon-e39ae511.js";import"./TablePagination-2c2a1682.js";import"./Select-ef36a2b2.js";import"./OutlinedInput-86f3ec98.js";import"./useFormControl-2b068664.js";import"./useControlled-8d737f13.js";import"./MenuItem-2bdddad4.js";import"./List-863f013e.js";import"./dividerClasses-02a44d89.js";import"./listItemTextClasses-cadd4b00.js";import"./KeyboardArrowRight-7e978a8a.js";import"./index.esm-0ec21729.js";import"./FilterFilled-4dfce120.js";import"./AntdIcon-8449be55.js";import"./objectSpread2-b41ee31b.js";import"./index-709861af.js";import"./Grow-8719411b.js";import"./FormControl-73683015.js";import"./InputLabel-bb6ab40e.js";const Ye=()=>{const r=L(),o=N();p.useState(!1);const[h,g]=p.useState(null),T=!!h,[l,j]=p.useState(null),{pdfTemplates:{pdfTemplatesList:v,pageParams:a,loading:P,pdfTemplatesCount:b},mini:{miniLocationList:ae,miniLocationLoading:ie,miniLocationParams:se},system:{userAccessList:s}}=A(),u=V(),y=[{title:"S.No",width:10},{title:"Code",width:10},{title:"Name",width:10},{title:"Actions",width:10}];function C(e,i,c,d){return{index:e,code:i,name:c,actions:d}}let S=U({search:X()});const{control:re,handleSubmit:z,register:_,reset:oe}=K({resolver:Q(S),values:{search:a.search}}),I=(e,i)=>{j(i),g(e.currentTarget)},m=()=>{g(null)},O=e=>{r(q({id:e,clearDataFn:()=>{m()},navigate:()=>{},pageParams:{...a,search:"",page:1,page_size:10}}))},R=v.map((e,i)=>{const c=(a.page-1)*a.page_size+(i+1),d=t.jsxs(Y,{justifyContent:"start",alignItems:"center",sx:{display:"flex",gap:2},children:[(s==null?void 0:s.indexOf("Reports.change_pdftemplate"))!==-1&&t.jsx($,{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:D=>I(D,e==null?void 0:e.id)}),t.jsx(Z,{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(J,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),t.jsx(f,{variant:"contained",type:"submit",color:"primary",onClick:()=>{O(l)},autoFocus:!0,children:"Yes"}),t.jsx(f,{variant:"outlined",size:"small",onClick:m,style:{marginLeft:"20px"},children:"No"})]})})]})]});return C(c,e.code,e.name,d)}),k=({search:e})=>{r(n({...a,search:e||"",page:1,page_size:10}))},B=(e,i)=>{r(n({...a,search:"",page:i+1}))},E=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 F=e=>{u("/pages/masters/pdf_templates/0")},M=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:F,pageText:"",children:[t.jsx("form",{action:"",onSubmit:z(k),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(W,{size:16})})},fullWidth:!0,variant:"outlined",placeholder:"Search",onChange:M})})})}),t.jsx(w,{count:b,columns:y,rows:R,loading:P,page:a.page,pageSize:a.page_size,handleChangePage:B,handleChangeRowsPerPage:E})]})})};export{Ye as default};
