import{b as G,r as p,eb as J,a as W,nc as q,g as H,j as t,B as K,b2 as Q,yf as U,yg as M,t as X,T as Z,J as j,yh as n,nf as L,yi as w,P as ee,Y as te,yj as ae}from"./index-d2b25495.js";import{T as re}from"./index-75fca24c.js";import{M as se}from"./MasterPageTitle-86504016.js";import{A as ie}from"./add.make-156aaa8b.js";import{u as oe}from"./index.esm-ce3c2c20.js";import{o as ne}from"./yup-267e586f.js";import{c as pe,b as le}from"./index.esm-3043d6d4.js";import{P as me}from"./Menu-337a466b.js";import{T as ce}from"./TextField-e155d2be.js";import{I as de}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"./componentStyles-0e851d91.js";import"./popper-f3391c26.js";import"./index-38f860bc.js";import"./InputLabel-bb6ab40e.js";import"./FormInput-d202e905.js";import"./FormControlLabel-78be0abe.js";import"./Checkbox-d1c5682c.js";import"./SwitchBase-8b4bccce.js";/* empty css                   */import"./ScrollableList-fc1de312.js";import"./Loader-1b927baf.js";import"./DialogContent-cded694d.js";import"./DialogTitle-a145b392.js";import"./DialogContentText-43575e44.js";import"./DialogActions-7c802cc8.js";import"./Grow-8719411b.js";import"./FormControl-73683015.js";const mt=()=>{const a=G(),[k,u]=p.useState(!1),o=J(),[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}}=W(e=>({make:q(e),system:H(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 P=pe({search:le()});const{control:ue,handleSubmit:_,register:O,reset:B}=oe({resolver:ne(P),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(K,{justifyContent:"start",alignItems:"center",sx:{display:"flex",gap:2},children:[(i==null?void 0:i.indexOf("Masters.change_make"))!==-1&&t.jsx(Q,{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:$=>E($,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(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 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)},Y=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:Y})})}),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:k,closeModal:R,mastersName:"Make",editId:z,mastersValue:b})]})};export{mt as default};
