import{d as G,r as p,b4 as H,a as J,nT as K,b as Q,j as e,B as U,s2 as W,s3 as f,T as X,R as C,s4 as n,s5 as Z,s6 as L,_ as w,s7 as tt}from"./index-83d9c1e2.js";import{M as et}from"./MasterPageTitle-9ab56f94.js";import{A as at}from"./add.city-8a23bea0.js";import{c as it,b as st,u as rt}from"./index.esm-82874186.js";import{o as ot}from"./yup-dfe9f223.js";import{d as nt}from"./Delete-5ebded29.js";import{e as pt}from"./Edit-abad5e84.js";import{C as lt}from"./index-ffc92880.js";import{P as ct}from"./Select-1505055e.js";import{T as mt}from"./TextField-39c52322.js";import{I as dt}from"./InputAdornment-4b0a9854.js";import"./index.esm-316fec71.js";import"./Divider-71865361.js";import"./dividerClasses-f18f0f93.js";import"./FilterFilled-eb3492a9.js";import"./AntdIcon-f9724de9.js";import"./objectSpread2-e5f2d908.js";import"./index-1ceef347.js";import"./GenericThumbnailView-ceecb14e.js";import"./popper-f3391c26.js";import"./Grow-6cc6748b.js";import"./ScrollableList-2bb71a63.js";import"./CircularProgress-3ce9da74.js";import"./FormInput-03b7722e.js";import"./FormControlLabel-af5c9791.js";import"./Checkbox-fe0b2cdb.js";import"./SwitchBase-ad42caec.js";import"./componentStyles-7858e543.js";import"./TableRow-1c35ea2a.js";import"./TextArea-7d949f4d.js";import"./SelectComponent-aff7b03c.js";import"./DialogContent-a75c4d06.js";import"./DialogTitle-3c642f58.js";import"./DialogContentText-ab545101.js";import"./Grid2-78565a55.js";import"./isMuiElement-5c2699ea.js";import"./DialogActions-3c3ab24c.js";import"./TableContainer-98997305.js";import"./TableHead-95baa189.js";import"./TablePagination-81b30c1b.js";import"./KeyboardArrowRight-b7bab219.js";import"./Toolbar-25a41873.js";import"./MenuItem-26e66f0f.js";import"./listItemTextClasses-fcd068d2.js";import"./index-e5978b8b.js";const oe=()=>{const a=G(),[j,g]=p.useState(!1);p.useState("");const o=H(),[u,x]=p.useState(null),S=!!u,[c,v]=p.useState(null),{city:{cityList:I,pageParams:i,loading:D,cityCount:b,searchValue:ht,masterValue:z,masterEditId:T},system:{userAccessList:r}}=J(t=>({city:K(t),system:Q(t)})),_=[{title:"S.No",width:100},{title:"Code",width:100},{title:"Name",width:100},{title:"State",width:100},{title:"Actions",width:100}];function M(t,s,d,h,l){return{index:t,code:s,name:d,state:h,actions:l}}let P=it({search:st()});const{control:gt,handleSubmit:O,register:B,reset:E}=rt({resolver:ot(P),values:{search:i.search}}),k=(t,s)=>{v(s),x(t.currentTarget)},m=()=>{x(null)},F=t=>{a(tt({id:t,clearDataFn:()=>{},navigate:s=>{},pageParams:i})),a(n({...i,search:"",page:1,page_size:10})),m()},V=I.map((t,s)=>{var l;const d=(i.page-1)*i.page_size+(s+1),h=e.jsxs(U,{justifyContent:"center",alignItems:"center",sx:{display:"flex",gap:2},children:[(r==null?void 0:r.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))}}),(r==null?void 0:r.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=>k(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:()=>F(c),autoFocus:!0,children:"Yes"}),e.jsx(C,{variant:"outlined",size:"small",onClick:m,style:{marginLeft:"20px"},children:"No"})]})})]})]});return M(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,s)=>{a(n({...i,search:"",page:s+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"),E({search:""})},[]);const y=t=>{a(Z({})),a(f(0)),g(t),a(L(t))},$=()=>{g(!1)},Y=t=>{const s=t.target.value;a(n({...i,search:s||"",page:1,page_size:10}))};return e.jsxs(e.Fragment,{children:[e.jsx(et,{prefix:"DynamicDjango",postfix:"City",pageTitle:"City",goBack:!0,addModelTile:(r==null?void 0:r.indexOf("DynamicDjango.add_city"))!==-1?"Add City":void 0,modalVisible:!0,setIsModalVisible:y,pageText:"",searchComponent:e.jsx("form",{onSubmit:O(A),children:e.jsx(mt,{type:"text",sx:{width:"300px"},...B("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:b,columns:_,rows:V,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:T,mastersValue:z})]})};export{oe as default};
