import{d as U,r as p,b8 as Y,a as G,ql as H,b as J,j as t,B as K,rx as Q,ry as y,T as W,U as f,rz as n,qo as X,rA as Z,$ as L,rB as w}from"./index-60657852.js";import{M as ee}from"./MasterPageTitle-4d4d4430.js";import{A as te}from"./add.category-c1f11eae.js";import{c as ae,b as re,u as oe}from"./index.esm-509a598d.js";import{o as se}from"./yup-75ad371b.js";import{C as ie}from"./index-61d7dc47.js";import{e as ne}from"./Edit-abad5e84.js";import{d as pe}from"./Delete-5ebded29.js";import{P as le}from"./Select-7d2a5359.js";import{T as ce}from"./TextField-6b778b78.js";import{I as me}from"./InputAdornment-12fc79ce.js";import"./index.esm-5fae0aa9.js";import"./Divider-6555f8d4.js";import"./dividerClasses-590294d7.js";import"./FilterFilled-e5a9bf0e.js";import"./AntdIcon-53906b68.js";import"./objectSpread2-b46e5e65.js";import"./index-980acb6c.js";import"./GenericThumbnailView-f8b17afa.js";import"./createClass-2b895736.js";import"./popper-f3391c26.js";import"./Grow-a21bdd26.js";import"./ScrollableList-ef4c85dc.js";import"./FormInput-6b018fe9.js";import"./FormControlLabel-95d4d7bb.js";import"./Checkbox-026acf65.js";import"./SwitchBase-3b306fc6.js";import"./componentStyles-19763afb.js";import"./TableRow-0ab1e69a.js";import"./TextArea-d897dbf9.js";import"./DialogContent-d5183bd6.js";import"./DialogTitle-66c21479.js";import"./DialogContentText-e3f3f7dd.js";import"./DialogActions-1dfa5a01.js";import"./LastPage-71f2133b.js";import"./KeyboardArrowRight-450d5bb8.js";import"./TableContainer-c3087864.js";import"./TableHead-1ba4d27d.js";import"./TablePagination-dd506b19.js";import"./KeyboardArrowRight-5039311c.js";import"./LastPage-c4cc7e5b.js";import"./Toolbar-e6f520d9.js";import"./MenuItem-64348b57.js";import"./listItemTextClasses-81f8effc.js";import"./listItemIconClasses-39f47a05.js";import"./isMuiElement-82a67859.js";const it=()=>{const a=U(),[C,g]=p.useState(!1);p.useState("");const i=Y(),{category:{categoryList:j,pageParams:r,loading:S,categoryCount:v,searchValue:de,masterValue:I,masterEditId:z},system:{userAccessList:s}}=G(e=>({category:H(e),system:J(e)})),[h,u]=p.useState(null),M=!!h,[l,b]=p.useState(null),T=[{title:"S.No",width:100},{title:"Code",width:100},{title:"Name",width:100},{title:"Actions",width:100}];function _(e,o,m,d){return{index:e,code:o,name:m,actions:d}}let P=ae({search:re()});const{control:ge,handleSubmit:B,register:O,reset:E}=oe({resolver:se(P),values:{search:r.search}}),k=(e,o)=>{b(o),u(e.currentTarget)},c=()=>{u(null)},A=e=>{a(w({id:e,clearDataFn:()=>{},navigate:o=>{},pageParams:r})),a(n({...r,search:"",page:1,page_size:10})),c()},D=j.map((e,o)=>{const m=(r.page-1)*r.page_size+(o+1),d=t.jsxs(K,{justifyContent:"center",alignItems:"center",sx:{display:"flex",gap:2},children:[(s==null?void 0:s.indexOf("Masters.change_category"))!==-1&&t.jsx("img",{src:ne,alt:"edit",style:{cursor:"pointer",width:"15px",height:"15px"},onClick:()=>{a(Q({id:e==null?void 0:e.id})),x(!0),a(y(e==null?void 0:e.id))}}),(s==null?void 0:s.indexOf("Masters.delete_category"))!==-1&&t.jsxs(t.Fragment,{children:[t.jsx("img",{src:pe,alt:"edit",style:{cursor:"pointer",width:"15px",height:"15px"},onClick:q=>k(q,e==null?void 0:e.id)}),t.jsx(le,{id:l?String(l):void 0,open:M,anchorEl:h,onClose:c,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:t.jsxs("div",{style:{padding:"15px"},children:[t.jsx(W,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),t.jsx(f,{variant:"contained",type:"submit",color:"primary",onClick:()=>A(l),autoFocus:!0,children:"Yes"}),t.jsx(f,{variant:"outlined",size:"small",onClick:c,style:{marginLeft:"20px"},children:"No"})]})})]})]});return _(m,e.code,e.name,d)}),F=({search:e})=>{a(n({...r,search:e||"",page:1,page_size:10}))},V=(e,o)=>{a(n({...r,search:"",page:o+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})),i==null||i.setTitle("Category"),i==null||i.setSubtitle("Masters"),E({search:""})},[]);const x=e=>{a(X({})),a(y(0)),g(e),a(Z(e))},R=()=>{g(!1)},$=e=>{const o=e.target.value;a(n({...r,search:o||"",page:1,page_size:10}))};return t.jsxs(t.Fragment,{children:[t.jsx(ee,{prefix:"Masters",postfix:"Category",pageTitle:"Category",goBack:!0,addModelTile:(s==null?void 0:s.indexOf("Masters.add_category"))!==-1?"Add Category":void 0,modalVisible:!0,setIsModalVisible:x,pageText:"",searchComponent:t.jsx("form",{onSubmit:B(F),children:t.jsx(ce,{type:"text",sx:{width:"300px"},...O("search"),size:"small",InputProps:{startAdornment:t.jsx(me,{position:"start",children:t.jsx(L,{size:16})})},variant:"outlined",placeholder:"Search",onChange:$})}),children:t.jsx(ie,{count:v,columns:T,rows:D,loading:S,page:r.page,pageSize:r.page_size,handleChangePage:V,handleChangeRowsPerPage:N,showPagination:!0})}),t.jsx(te,{modal:C,closeModal:R,mastersName:"Category",edit_Id:z,mastersValue:I})]})};export{it as default};
