import{b as $,r as p,e8 as G,a as K,ng as W,h as q,j as t,B as H,b2 as J,xP as U,xQ as M,v as X,T as Z,K as j,xR as n,nj as L,xS as w,Q as ee,Y as te,xT as ae}from"./index-43bf7a1c.js";import{T as re}from"./index-2d303f1d.js";import{M as se}from"./MasterPageTitle-e54f2b5e.js";import{A as ie}from"./add.make-a0e8a9b1.js";import{u as oe}from"./index.esm-0548c843.js";import{o as ne}from"./yup-3b80ed10.js";import{c as pe,b as le}from"./index.esm-f9e0a906.js";import{P as me}from"./Menu-362130d3.js";import{T as ce}from"./TextField-4da97115.js";import{I as de}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"./componentStyles-4624000e.js";import"./floating-ui.dom-e7d69f3b.js";import"./index-913b2dc6.js";import"./InputLabel-6c7474f0.js";import"./FormInput-33b720a4.js";import"./FormControlLabel-15b42e5e.js";import"./Checkbox-b7a88fca.js";import"./SwitchBase-75578ec7.js";/* empty css                   */import"./ScrollableList-e19132c3.js";import"./Loader-aabe9ed3.js";import"./DialogContent-d5902709.js";import"./DialogTitle-20dc6f66.js";import"./DialogContentText-abf03c9f.js";import"./DialogActions-d63c6496.js";import"./Grow-ca573f65.js";import"./FormControl-8d011aab.js";const mt=()=>{const a=$(),[k,u]=p.useState(!1),o=G(),[g,x]=p.useState(null),S=!!g,[l,y]=p.useState(null),{make:{makeList:m,pageParams:r,loading:v,makeCount:C,searchValue:he,masterValue:T,masterEditId:b},system:{userAccessList:i}}=K(e=>({make:W(e),system:q(e)})),z=[{title:"S.No",width:100},{title:"Code",width:100},{title:"Name",width:100},{title:"Actions",width:100}];function I(e,s,d,h){return{index:e,code:s,name:d,actions:h}}let P=pe({search:le()});const{control:ue,handleSubmit:_,register:O,reset:B}=oe({resolver:ne(P),values:{search:r.search}}),E=(e,s)=>{y(s),x(e.currentTarget)},c=()=>{x(null)},D=e=>{a(ae({id:e,clearDataFn:()=>{},navigate:s=>{},pageParams:r})),a(n({...r,search:"",page:1,page_size:10})),c()},F=m==null?void 0:m.map((e,s)=>{const d=(r.page-1)*r.page_size+(s+1),h=t.jsxs(H,{justifyContent:"start",alignItems:"center",sx:{display:"flex",gap:2},children:[(i==null?void 0:i.indexOf("Masters.change_make"))!==-1&&t.jsx(J,{style:{cursor:"pointer",color:"#fc6f03"},onClick:()=>{a(U({id:e==null?void 0:e.id})),f(!0),a(M(e==null?void 0:e.id))}}),(i==null?void 0:i.indexOf("Masters.delete_make"))!==-1&&t.jsxs(t.Fragment,{children:[t.jsx(X,{style:{cursor:"pointer",color:"#fc6f03"},onClick:Y=>E(Y,e==null?void 0:e.id)}),t.jsx(me,{id:l?String(l):void 0,open:S,anchorEl:g,onClose:c,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:t.jsxs("div",{style:{padding:"15px"},children:[t.jsx(Z,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),t.jsx(j,{variant:"contained",type:"submit",color:"primary",onClick:()=>{D(l)},autoFocus:!0,children:"Yes"}),t.jsx(j,{variant:"outlined",size:"small",onClick:c,style:{marginLeft:"20px"},children:"No"})]})})]})]});return I(d,e.code,e.name,h)}),V=({search:e})=>{a(n({...r,search:e||"",page:1,page_size:10}))},A=(e,s)=>{a(n({...r,search:"",page:s+1}))},N=e=>{a(n({...r,search:"",page:1,page_size:parseInt(e.target.value)}))};p.useEffect(()=>{a(n({...r,search:"",page:1,page_size:10})),o==null||o.setTitle("Make"),o==null||o.setSubtitle("Masters"),B({search:""})},[]);const f=e=>{a(M(0)),a(L({})),u(e),a(w(e))},R=()=>{u(!1)},Q=e=>{const s=e.target.value;a(n({...r,search:s||"",page:1,page_size:10}))};return t.jsxs(t.Fragment,{children:[t.jsxs(se,{prefix:"Masters",postfix:"Make",pageTitle:"Make",goBack:!0,addModelTile:(i==null?void 0:i.indexOf("Masters.add_make"))!==-1?"Add Make":void 0,modalVisible:!0,setIsModalVisible:f,pageText:"",children:[t.jsx("form",{action:"",onSubmit:_(V),children:t.jsx(ee,{container:!0,my:2,children:t.jsx(ce,{type:"text",sx:{width:"500px"},...O("search"),id:"input-with-icon-textfield",size:"small",InputProps:{startAdornment:t.jsx(de,{position:"start",children:t.jsx(te,{size:20})})},fullWidth:!0,variant:"outlined",placeholder:"Search",onChange:Q})})}),t.jsx(re,{count:C,columns:z,rows:F,loading:v,page:r.page,pageSize:r.page_size,handleChangePage:A,handleChangeRowsPerPage:N})]}),t.jsx(ie,{modal:k,closeModal:R,mastersName:"Make",editId:b,mastersValue:T})]})};export{mt as default};
