import{d as G,r as p,aV as H,a as J,nI as K,b as Q,j as e,B as U,rA as W,rB as f,T as X,z as C,rC as n,rD as Z,rE as L,M as w,rF as tt}from"./index-4dfc510b.js";import{M as et}from"./MasterPageTitle-68cbcd9e.js";import{A as at}from"./add.city-0fac3134.js";import{c as it,b as rt,u as st}from"./index.esm-0a454763.js";import{o as ot}from"./yup-80def618.js";import{d as nt}from"./Delete-5ebded29.js";import{e as pt}from"./Edit-abad5e84.js";import{C as lt}from"./index-71406b65.js";import{P as ct}from"./Menu-0f556e12.js";import{T as mt}from"./TextField-c0d4022e.js";import{I as dt}from"./InputAdornment-ccd6e8ff.js";import"./index.esm-337179d9.js";import"./Divider-1794f57d.js";import"./dividerClasses-26c2a6d6.js";import"./FilterFilled-dc66781c.js";import"./AntdIcon-90a37458.js";import"./objectSpread2-66550f90.js";import"./index-9a385720.js";import"./GenericThumbnailView-6256cad7.js";import"./popper-f3391c26.js";import"./Select-c8503f85.js";import"./index-e5978b8b.js";import"./Grow-a7315f12.js";import"./ScrollableList-bef4a518.js";import"./CircularProgress-d36b5e75.js";import"./FormInput-f887e69c.js";import"./FormControlLabel-e49dd1e5.js";import"./componentStyles-df94248d.js";import"./TableRow-bee40746.js";import"./TextArea-a0cc14f3.js";import"./SelectComponent-bfde3322.js";import"./DialogContent-3bf4ff27.js";import"./DialogTitle-248b1818.js";import"./DialogContentText-a6ab23a2.js";import"./Grid2-713975b3.js";import"./isMuiElement-7be61a21.js";import"./DialogActions-49286e71.js";import"./TableContainer-3d0f0f18.js";import"./TableHead-c19aff48.js";import"./TablePagination-faf46d98.js";import"./KeyboardArrowRight-605c8352.js";import"./Toolbar-1cf142b4.js";import"./MenuItem-9737e3d9.js";import"./listItemTextClasses-e85f7ff0.js";const se=()=>{const a=G(),[j,g]=p.useState(!1);p.useState("");const o=H(),[u,x]=p.useState(null),S=!!u,[c,I]=p.useState(null),{city:{cityList:v,pageParams:i,loading:D,cityCount:z,searchValue:ht,masterValue:b,masterEditId:M},system:{userAccessList:s}}=J(t=>({city:K(t),system:Q(t)})),T=[{title:"S.No",width:100},{title:"Code",width:100},{title:"Name",width:100},{title:"State",width:100},{title:"Actions",width:100}];function _(t,r,d,h,l){return{index:t,code:r,name:d,state:h,actions:l}}let P=it({search:rt()});const{control:gt,handleSubmit:B,register:E,reset:O}=st({resolver:ot(P),values:{search:i.search}}),F=(t,r)=>{I(r),x(t.currentTarget)},m=()=>{x(null)},V=t=>{a(tt({id:t,clearDataFn:()=>{},navigate:r=>{},pageParams:i})),a(n({...i,search:"",page:1,page_size:10})),m()},k=v.map((t,r)=>{var l;const d=(i.page-1)*i.page_size+(r+1),h=e.jsxs(U,{justifyContent:"center",alignItems:"center",sx:{display:"flex",gap:2},children:[(s==null?void 0:s.indexOf("DynamicDjango.change_city"))!==-1&&e.jsx("img",{src:pt,alt:"edit",style:{cursor:"pointer",width:"15px",height:"15px"},onClick:()=>{a(W({id:t==null?void 0:t.id})),y(!0),a(f(t==null?void 0:t.id))}}),(s==null?void 0:s.indexOf("DynamicDjango.delete_city"))!==-1&&e.jsxs(e.Fragment,{children:[e.jsx("img",{src:nt,alt:"edit",style:{cursor:"pointer",width:"15px",height:"15px"},onClick:q=>F(q,t==null?void 0:t.id)}),e.jsx(ct,{id:c?String(c):void 0,open:S,anchorEl:u,onClose:m,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:e.jsxs("div",{style:{padding:"15px"},children:[e.jsx(X,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),e.jsx(C,{variant:"contained",type:"submit",color:"primary",onClick:()=>V(c),autoFocus:!0,children:"Yes"}),e.jsx(C,{variant:"outlined",size:"small",onClick:m,style:{marginLeft:"20px"},children:"No"})]})})]})]});return _(d,t.code,t.name,(l=t.state)==null?void 0:l.name,h)}),A=({search:t})=>{a(n({...i,search:t||"",page:1,page_size:10}))},N=(t,r)=>{a(n({...i,search:"",page:r+1}))},R=t=>{a(n({...i,search:"",page:1,page_size:parseInt(t.target.value)}))};p.useEffect(()=>{a(n({...i,search:"",page:1,page_size:10})),o==null||o.setTitle("City"),o==null||o.setSubtitle("Masters"),O({search:""})},[]);const y=t=>{a(Z({})),a(f(0)),g(t),a(L(t))},$=()=>{g(!1)},Y=t=>{const r=t.target.value;a(n({...i,search:r||"",page:1,page_size:10}))};return e.jsxs(e.Fragment,{children:[e.jsx(et,{prefix:"DynamicDjango",postfix:"City",pageTitle:"City",goBack:!0,addModelTile:(s==null?void 0:s.indexOf("DynamicDjango.add_city"))!==-1?"Add City":void 0,modalVisible:!0,setIsModalVisible:y,pageText:"",searchComponent:e.jsx("form",{onSubmit:B(A),children:e.jsx(mt,{type:"text",sx:{width:"300px"},...E("search"),size:"small",InputProps:{startAdornment:e.jsx(dt,{position:"start",children:e.jsx(w,{size:16})})},variant:"outlined",placeholder:"Search",onChange:Y})}),children:e.jsx(lt,{count:z,columns:T,rows:k,loading:D,page:i.page,pageSize:i.page_size,handleChangePage:N,handleChangeRowsPerPage:R,showPagination:!0})}),e.jsx(at,{modal:j,closeModal:$,mastersName:"City",edit_Id:M,mastersValue:b})]})};export{se as default};
