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-d895656a.js";import{M as et}from"./MasterPageTitle-a3ec39dd.js";import{A as at}from"./add.city-712e1e05.js";import{c as it,b as rt,u as st}from"./index.esm-1087b2f3.js";import{o as ot}from"./yup-9573aa79.js";import{d as nt}from"./Delete-5ebded29.js";import{e as pt}from"./Edit-abad5e84.js";import{C as lt}from"./index-a3f5b318.js";import{P as ct}from"./Menu-1728e1dd.js";import{T as mt}from"./TextField-6f73e19a.js";import{I as dt}from"./InputAdornment-36977269.js";import"./index.esm-44fedea2.js";import"./Divider-cb9ba1b0.js";import"./dividerClasses-f4dcf412.js";import"./FilterFilled-9d5acdc3.js";import"./AntdIcon-19e16777.js";import"./objectSpread2-c21546fe.js";import"./index-45bf15b6.js";import"./GenericThumbnailView-532ea2d7.js";import"./popper-f3391c26.js";import"./Select-6d425a72.js";import"./index-e5978b8b.js";import"./Grow-d4be81a5.js";import"./ScrollableList-e2b22048.js";import"./CircularProgress-1f3ca34c.js";import"./FormInput-9b5da280.js";import"./FormControlLabel-2fb7bcfb.js";import"./componentStyles-866300fe.js";import"./TableRow-5557ab84.js";import"./TextArea-fb0d0821.js";import"./SelectComponent-32c91e44.js";import"./DialogContent-4ce43512.js";import"./DialogTitle-738ca272.js";import"./DialogContentText-8b9b0e0c.js";import"./Grid2-5bd460ea.js";import"./isMuiElement-424c145f.js";import"./DialogActions-7b82f6f6.js";import"./TableContainer-a89da0a1.js";import"./TableHead-1b575958.js";import"./TablePagination-582dd1d9.js";import"./KeyboardArrowRight-5067dfe9.js";import"./Toolbar-adca1e0f.js";import"./MenuItem-f1f55b7e.js";import"./listItemTextClasses-1ed38b44.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};
