import{d as W,r as p,b7 as X,a as Y,p0 as q,b as G,j as t,B as H,tS as J,tT as j,T as K,R as S,tU as n,tV as Q,tW as Z,_ as L,tX as w}from"./index-952e178b.js";import{M as ee}from"./MasterPageTitle-7665a485.js";import{A as te}from"./add.baseunit-e2401a26.js";import{o as ae}from"./yup-d92565dd.js";import{c as se,b as re,u as ie}from"./index.esm-6feddb16.js";import{d as oe}from"./Delete-5ebded29.js";import{e as ne}from"./Edit-abad5e84.js";import{C as pe}from"./index-8c2f17c1.js";import{P as le}from"./Select-41d78585.js";import{T as me}from"./TextField-d1a887ff.js";import{I as ce}from"./InputAdornment-020147de.js";import"./index.esm-70af4911.js";import"./Divider-342f1cfc.js";import"./dividerClasses-8e897c94.js";import"./FilterFilled-1ab4da14.js";import"./AntdIcon-54006664.js";import"./objectSpread2-a71852a2.js";import"./index-22eb3e7f.js";import"./GenericThumbnailView-4e535459.js";import"./createClass-5a32667f.js";import"./popper-f3391c26.js";import"./ScrollableList-cd5816a8.js";import"./CircularProgress-3b605689.js";import"./FormInput-8320115a.js";import"./FormControlLabel-973be654.js";import"./Checkbox-6c7c4dc0.js";import"./SwitchBase-bd5cc4c6.js";import"./componentStyles-00160cc0.js";import"./TableRow-6a27d7f4.js";import"./TextArea-ce7716c9.js";import"./DialogContent-4facb916.js";import"./DialogTitle-3aa960f8.js";import"./DialogContentText-54d95680.js";import"./DialogActions-bd200b72.js";import"./LastPage-9979d461.js";import"./KeyboardArrowRight-91d2ccce.js";import"./TableContainer-e3ecf13b.js";import"./TableHead-e31d41f4.js";import"./TablePagination-b93979a3.js";import"./KeyboardArrowRight-c3d685e2.js";import"./LastPage-54692111.js";import"./Toolbar-201b514b.js";import"./MenuItem-f41722f4.js";import"./listItemTextClasses-ca40551b.js";import"./listItemIconClasses-3e4286ad.js";import"./index-e5978b8b.js";import"./isMuiElement-f03a71e4.js";const nt=()=>{const a=W(),[C,u]=p.useState(!1),o=X(),[g,x]=p.useState(null),M=!!g,[l,b]=p.useState(null),{baseunit:{baseunitList:m,pageParams:s,loading:y,baseunitCount:v,searchValue:de,masterValue:I,masterEditId:z},system:{userAccessList:i}}=Y(e=>({baseunit:q(e),system:G(e)})),B=[{title:"S.No",width:100},{title:"Code",width:100},{title:"Name",width:100},{title:"Actions",width:100}];function T(e,r,d,h){return{index:e,code:r,name:d,actions:h}}const O=(e,r)=>{b(r),x(e.currentTarget)},c=()=>{x(null)},_=e=>{a(w({params:s,id:e,clearDataFn:()=>{},navigate:r=>{}})),a(n({...s,search:"",page:1,page_size:10})),c()},P=m==null?void 0:m.map((e,r)=>{const d=(s.page-1)*s.page_size+(r+1),h=t.jsxs(H,{justifyContent:"center",alignItems:"center",sx:{display:"flex",gap:2},children:[(i==null?void 0:i.indexOf("Masters.change_uom"))!==-1&&t.jsx("img",{src:ne,alt:"edit",style:{cursor:"pointer",width:"15px",height:"15px"},onClick:()=>{a(J({id:e==null?void 0:e.id})),f(!0),a(j(e==null?void 0:e.id))}}),(i==null?void 0:i.indexOf("Masters.delete_uom"))!==-1&&t.jsxs(t.Fragment,{children:[t.jsx("img",{src:oe,alt:"edit",style:{cursor:"pointer",width:"15px",height:"15px"},onClick:$=>O($,e==null?void 0:e.id)}),t.jsx(le,{id:l?String(l):void 0,open:M,anchorEl:g,onClose:c,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:t.jsxs("div",{style:{padding:"15px"},children:[t.jsx(K,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),t.jsx(S,{variant:"contained",type:"submit",color:"primary",onClick:()=>_(String(l)),autoFocus:!0,children:"Yes"}),t.jsx(S,{variant:"outlined",size:"small",onClick:c,style:{marginLeft:"20px"},children:"No"})]})})]})]});return T(d,e.code,e.name,h)}),E=({search:e})=>{a(n({...s,search:e||"",page:1,page_size:10}))},V=(e,r)=>{a(n({...s,search:"",page:r+1}))},k=e=>{a(n({...s,search:"",page:1,page_size:parseInt(e.target.value)}))};p.useEffect(()=>{a(n({...s,search:"",page:1,page_size:10})),o==null||o.setTitle("Baseunit"),o==null||o.setSubtitle("Masters"),N({search:""})},[]);const f=e=>{a(Q({})),a(j(0)),u(e),a(Z(e))},D=()=>{u(!1)};let F=se({search:re()});const{control:he,handleSubmit:U,register:A,reset:N}=ie({resolver:ae(F),values:{search:s.search}}),R=e=>{const r=e.target.value;a(n({...s,search:r||"",page:1,page_size:10}))};return t.jsxs(t.Fragment,{children:[t.jsx(ee,{prefix:"Masters",postfix:"uom",pageTitle:"UOM",goBack:!0,addModelTile:(i==null?void 0:i.indexOf("Masters.add_uom"))!==-1?"Add UOM":void 0,modalVisible:!0,setIsModalVisible:f,pageText:"",searchComponent:t.jsx("form",{onSubmit:U(E),children:t.jsx(me,{type:"text",sx:{width:"300px"},...A("search"),size:"small",InputProps:{startAdornment:t.jsx(ce,{position:"start",children:t.jsx(L,{size:16})})},variant:"outlined",placeholder:"Search",onChange:R})})}),t.jsx(pe,{count:v,columns:B,rows:P,loading:y,page:s.page,pageSize:s.page_size,handleChangePage:V,handleChangeRowsPerPage:k,showPagination:!0}),t.jsx(te,{modal:C,closeModal:D,mastersName:"UOM",editId:z,mastersValue:I})]})};export{nt as default};
