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-c5c88b67.js";import{M as et}from"./MasterPageTitle-405781d7.js";import{A as at}from"./add.city-e79b140b.js";import{c as it,b as rt,u as st}from"./index.esm-81620445.js";import{o as ot}from"./yup-41605283.js";import{d as nt}from"./Delete-5ebded29.js";import{e as pt}from"./Edit-abad5e84.js";import{C as lt}from"./index-e101df4a.js";import{P as ct}from"./Menu-e7d2b2ee.js";import{T as mt}from"./TextField-78388962.js";import{I as dt}from"./InputAdornment-d66117f3.js";import"./index.esm-0ad88c35.js";import"./Divider-0dc41916.js";import"./dividerClasses-6bc0ca72.js";import"./FilterFilled-9066fadd.js";import"./AntdIcon-1a0d7a6b.js";import"./objectSpread2-65a0d991.js";import"./index-c98d1d89.js";import"./GenericThumbnailView-43782201.js";import"./createClass-fb49042e.js";import"./popper-f3391c26.js";import"./Select-4ed8db5d.js";import"./index-e5978b8b.js";import"./Grow-7345f8ea.js";import"./ScrollableList-21ab2b9c.js";import"./CircularProgress-13afa056.js";import"./FormInput-86f14880.js";import"./FormControlLabel-d6955dc8.js";import"./componentStyles-a5e5a830.js";import"./TableRow-2b359fa8.js";import"./TextArea-aad9dffe.js";import"./SelectComponent-8c888daa.js";import"./DialogContent-1350b249.js";import"./DialogTitle-da236dcc.js";import"./DialogContentText-659ecbc3.js";import"./Grid2-0ff60c92.js";import"./isMuiElement-b3c21f38.js";import"./DialogActions-1232a7fa.js";import"./TableContainer-c31f204a.js";import"./TableHead-c2c21491.js";import"./TablePagination-0147f84a.js";import"./KeyboardArrowRight-261f4f43.js";import"./Toolbar-f8d4b0c4.js";import"./MenuItem-81e44793.js";import"./listItemTextClasses-88792089.js";const oe=()=>{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{oe as default};
