import{b as $,r as p,e8 as G,a as Q,n6 as W,h as q,j as t,B as H,b2 as J,xK as U,xL as M,v as X,T as Z,K as k,xM as n,n9 as L,xN as w,Q as ee,Y as te,xO as ae}from"./index-76d4793e.js";import{T as re}from"./index-1fae9bc3.js";import{M as se}from"./MasterPageTitle-e8b467fa.js";import{A as ie}from"./add.make-cc416f78.js";import{u as oe}from"./index.esm-3adfd9f7.js";import{o as ne}from"./yup-688ec4f6.js";import{c as pe,b as le}from"./index.esm-ad8a7c9f.js";import{P as me}from"./Menu-ed7c6894.js";import{T as ce}from"./TextField-9c64a4a2.js";import{I as de}from"./InputAdornment-b99403ce.js";import"./TableContainer-4147c2f3.js";import"./TableRow-736f36bd.js";import"./Skeleton-5d9101fd.js";import"./index-85763c32.js";import"./useMediaQuery-8cb39c65.js";import"./TableHead-c6031541.js";import"./createSvgIcon-01ec10fc.js";import"./TablePagination-5e47b2d0.js";import"./Select-338083eb.js";import"./OutlinedInput-ac933786.js";import"./useFormControl-c8d490e1.js";import"./List-4c24b3e8.js";import"./useControlled-e03384de.js";import"./MenuItem-cff1abce.js";import"./dividerClasses-45958eb8.js";import"./listItemTextClasses-89e7894e.js";import"./KeyboardArrowRight-8920e265.js";import"./index.esm-d9f89842.js";import"./FilterFilled-aa7d40e4.js";import"./AntdIcon-55dc1b5f.js";import"./objectSpread2-51b6810f.js";import"./componentStyles-0803b39e.js";import"./floating-ui.dom-e7d69f3b.js";import"./index-ecea5cfc.js";import"./InputLabel-5ed57f0e.js";import"./FormInput-8f40ded1.js";import"./FormControlLabel-77c65f77.js";import"./Checkbox-ce15672a.js";import"./SwitchBase-25e1ee17.js";/* empty css                   */import"./ScrollableList-4dae3697.js";import"./Loader-9f443a4c.js";import"./DialogContent-7bd8dd8f.js";import"./DialogTitle-71dd5b3a.js";import"./DialogContentText-7642f81f.js";import"./DialogActions-5a5e1db9.js";import"./Grow-84b30c0e.js";import"./FormControl-c671c595.js";const lt=()=>{const a=$(),[j,u]=p.useState(!1),o=G(),[g,x]=p.useState(null),y=!!g,[l,S]=p.useState(null),{make:{makeList:m,pageParams:r,loading:v,makeCount:C,searchValue:he,masterValue:b,masterEditId:z},system:{userAccessList:i}}=Q(e=>({make:W(e),system:q(e)})),I=[{title:"S.No",width:100},{title:"Code",width:100},{title:"Name",width:100},{title:"Actions",width:100}];function T(e,s,d,h){return{index:e,code:s,name:d,actions:h}}let _=pe({search:le()});const{control:ue,handleSubmit:O,register:P,reset:B}=oe({resolver:ne(_),values:{search:r.search}}),E=(e,s)=>{S(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:y,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(k,{variant:"contained",type:"submit",color:"primary",onClick:()=>{D(l)},autoFocus:!0,children:"Yes"}),t.jsx(k,{variant:"outlined",size:"small",onClick:c,style:{marginLeft:"20px"},children:"No"})]})})]})]});return T(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)},K=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:O(V),children:t.jsx(ee,{container:!0,my:2,children:t.jsx(ce,{type:"text",sx:{width:"500px"},...P("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:K})})}),t.jsx(re,{count:C,columns:I,rows:F,loading:v,page:r.page,pageSize:r.page_size,handleChangePage:A,handleChangeRowsPerPage:N})]}),t.jsx(ie,{modal:j,closeModal:R,mastersName:"Make",editId:z,mastersValue:b})]})};export{lt as default};
