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-60a3c753.js";import{T as re}from"./index-7e55cf46.js";import{M as se}from"./MasterPageTitle-8a6edc29.js";import{A as ie}from"./add.make-4cf5b1ce.js";import{u as oe}from"./index.esm-c494934a.js";import{o as ne}from"./yup-92678dde.js";import{c as pe,b as le}from"./index.esm-62d6b2f7.js";import{P as me}from"./Menu-d1b7e1c3.js";import{T as ce}from"./TextField-32b29087.js";import{I as de}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"./componentStyles-7753bbb9.js";import"./floating-ui.dom-e7d69f3b.js";import"./index-900fa817.js";import"./InputLabel-71dfc9d4.js";import"./FormInput-74e2c4d2.js";import"./FormControlLabel-950ba0c7.js";import"./Checkbox-fe59fe9f.js";import"./SwitchBase-eb3a47ff.js";/* empty css                   */import"./ScrollableList-1962b023.js";import"./Loader-466ccb5e.js";import"./DialogContent-89e21f2e.js";import"./DialogTitle-fe69da5c.js";import"./DialogContentText-6688bd59.js";import"./DialogActions-e754942c.js";import"./Grow-68442588.js";import"./FormControl-d13d2693.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};
