import{d as Y,r as p,b6 as G,a as H,oY as J,b as K,j as t,B as Q,q6 as U,q7 as y,T as W,R as f,q8 as n,o$ as X,q9 as Z,_ as L,qa as w}from"./index-e6164346.js";import{M as ee}from"./MasterPageTitle-fcafb323.js";import{A as te}from"./add.category-24b27a85.js";import{c as ae,b as re,u as oe}from"./index.esm-0a041314.js";import{o as se}from"./yup-5fd5d57b.js";import{C as ie}from"./index-cde536dd.js";import{e as ne}from"./Edit-abad5e84.js";import{d as pe}from"./Delete-5ebded29.js";import{P as le}from"./Select-9c2d8cd2.js";import{T as ce}from"./TextField-db9cff08.js";import{I as me}from"./InputAdornment-59975edf.js";import"./index.esm-42924bf1.js";import"./Divider-6099014b.js";import"./dividerClasses-932c3e8b.js";import"./FilterFilled-c0851aaa.js";import"./AntdIcon-4f5aa87b.js";import"./objectSpread2-7d7378cc.js";import"./index-ce90e1a7.js";import"./GenericThumbnailView-80c6fd98.js";import"./createClass-ad55a3ca.js";import"./popper-f3391c26.js";import"./Grow-306e2fd0.js";import"./ScrollableList-5a17e8f4.js";import"./CircularProgress-7d99d864.js";import"./FormInput-859198ec.js";import"./FormControlLabel-ee192a98.js";import"./Checkbox-70f568c2.js";import"./SwitchBase-e1f0b96b.js";import"./componentStyles-00385170.js";import"./TableRow-bf4e60a0.js";import"./TextArea-f5c200de.js";import"./Dialog-2e8a8e2e.js";import"./DialogTitle-8757f50f.js";import"./DialogContent-f10d6731.js";import"./DialogContentText-027be15d.js";import"./DialogActions-31bec80e.js";import"./TableContainer-7ecd96ea.js";import"./TableHead-0c525f54.js";import"./TablePagination-b02830fa.js";import"./KeyboardArrowRight-73af71dd.js";import"./LastPage-b9dcf78c.js";import"./Toolbar-82d22fac.js";import"./MenuItem-8dd174fb.js";import"./listItemTextClasses-6b253cb4.js";import"./listItemIconClasses-a58b491d.js";import"./index-e5978b8b.js";import"./isMuiElement-5779af4f.js";const nt=()=>{const a=Y(),[C,g]=p.useState(!1);p.useState("");const i=G(),{category:{categoryList:j,pageParams:r,loading:S,categoryCount:v,searchValue:de,masterValue:I,masterEditId:M},system:{userAccessList:s}}=H(e=>({category:J(e),system:K(e)})),[h,u]=p.useState(null),b=!!h,[l,z]=p.useState(null),_=[{title:"S.No",width:100},{title:"Code",width:100},{title:"Name",width:100},{title:"Actions",width:100}];function T(e,o,m,d){return{index:e,code:o,name:m,actions:d}}let P=ae({search:re()});const{control:ge,handleSubmit:O,register:B,reset:E}=oe({resolver:se(P),values:{search:r.search}}),k=(e,o)=>{z(o),u(e.currentTarget)},c=()=>{u(null)},D=e=>{a(w({id:e,clearDataFn:()=>{},navigate:o=>{},pageParams:r})),a(n({...r,search:"",page:1,page_size:10})),c()},F=j.map((e,o)=>{const m=(r.page-1)*r.page_size+(o+1),d=t.jsxs(Q,{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(U({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:$=>k($,e==null?void 0:e.id)}),t.jsx(le,{id:l?String(l):void 0,open:b,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:()=>D(l),autoFocus:!0,children:"Yes"}),t.jsx(f,{variant:"outlined",size:"small",onClick:c,style:{marginLeft:"20px"},children:"No"})]})})]})]});return T(m,e.code,e.name,d)}),V=({search:e})=>{a(n({...r,search:e||"",page:1,page_size:10}))},q=(e,o)=>{a(n({...r,search:"",page:o+1}))},A=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))},N=()=>{g(!1)},R=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:O(V),children:t.jsx(ce,{type:"text",sx:{width:"300px"},...B("search"),size:"small",InputProps:{startAdornment:t.jsx(me,{position:"start",children:t.jsx(L,{size:16})})},variant:"outlined",placeholder:"Search",onChange:R})}),children:t.jsx(ie,{count:v,columns:_,rows:F,loading:S,page:r.page,pageSize:r.page_size,handleChangePage:q,handleChangeRowsPerPage:A,showPagination:!0})}),t.jsx(te,{modal:C,closeModal:N,mastersName:"Category",edit_Id:M,mastersValue:I})]})};export{nt as default};
