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-def636a4.js";import{T as re}from"./index-fc769754.js";import{M as se}from"./MasterPageTitle-bbea54a4.js";import{A as ie}from"./add.make-5ef97537.js";import{u as oe}from"./index.esm-7d9d1491.js";import{o as ne}from"./yup-c8535458.js";import{c as pe,b as le}from"./index.esm-eec4f448.js";import{P as me}from"./Menu-af49d134.js";import{T as ce}from"./TextField-2ba95a45.js";import{I as de}from"./InputAdornment-196a5386.js";import"./TableContainer-5944247b.js";import"./TableRow-2c544f58.js";import"./Skeleton-5cf57ed1.js";import"./index-b5a6fbe3.js";import"./useMediaQuery-4304fb25.js";import"./TableHead-f0476938.js";import"./createSvgIcon-ff487f53.js";import"./TablePagination-7d3b42e9.js";import"./Select-2cfb5afd.js";import"./OutlinedInput-ddb8bb3f.js";import"./useFormControl-880b2f7b.js";import"./List-17cd485b.js";import"./useControlled-bd643819.js";import"./MenuItem-8fdd2340.js";import"./dividerClasses-2b953c2a.js";import"./listItemTextClasses-063fcacf.js";import"./KeyboardArrowRight-bfb3d848.js";import"./index.esm-c912dbcd.js";import"./FilterFilled-08c5b5a7.js";import"./AntdIcon-34324527.js";import"./objectSpread2-a4d0f5f6.js";import"./presets-dbb0f3bf.js";import"./componentStyles-41382c67.js";import"./floating-ui.dom-e7d69f3b.js";import"./index-f48c8aa0.js";import"./InputLabel-e2e73b27.js";import"./FormInput-8d872744.js";import"./FormControlLabel-f5b899d5.js";import"./Checkbox-76a12c6d.js";import"./SwitchBase-b0dec868.js";/* empty css                   */import"./ScrollableList-a550bc32.js";import"./Loader-16c57fae.js";import"./DialogContent-0cb684b3.js";import"./DialogTitle-e2e75924.js";import"./DialogContentText-b2259947.js";import"./DialogActions-c4045764.js";import"./Grow-85576dd3.js";import"./FormControl-1f811046.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};
