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-ba11e6ab.js";import{M as et}from"./MasterPageTitle-6247bce5.js";import{A as at}from"./add.city-d5246723.js";import{c as it,b as st,u as rt}from"./index.esm-39ef576a.js";import{o as ot}from"./yup-902af9ab.js";import{d as nt}from"./Delete-5ebded29.js";import{e as pt}from"./Edit-abad5e84.js";import{C as lt}from"./index-5081f854.js";import{P as ct}from"./Select-f9434f8a.js";import{T as mt}from"./TextField-16337ecc.js";import{I as dt}from"./InputAdornment-0f07311f.js";import"./index.esm-c4573c1c.js";import"./Divider-7b675f59.js";import"./dividerClasses-ab944802.js";import"./FilterFilled-94a9d775.js";import"./AntdIcon-d49f53d6.js";import"./objectSpread2-d72b34ab.js";import"./index-33824b7d.js";import"./GenericThumbnailView-511a7e33.js";import"./popper-f3391c26.js";import"./Grow-1038181b.js";import"./ScrollableList-b4fc4d99.js";import"./CircularProgress-509803a6.js";import"./FormInput-3e62ad24.js";import"./FormControlLabel-8048035a.js";import"./Checkbox-3e187368.js";import"./SwitchBase-7d4e0bc8.js";import"./componentStyles-cc6f218d.js";import"./TableRow-e1616615.js";import"./TextArea-1c46e0e4.js";import"./SelectComponent-b2bed2ac.js";import"./DialogContent-af77e042.js";import"./DialogTitle-dc43931f.js";import"./DialogContentText-990aa19e.js";import"./Grid2-12794a3c.js";import"./isMuiElement-f8265807.js";import"./DialogActions-3fe54b4c.js";import"./TableContainer-9178cc85.js";import"./TableHead-5a0d8cfc.js";import"./TablePagination-3b5112dd.js";import"./KeyboardArrowRight-36117cc9.js";import"./Toolbar-c7a1b81e.js";import"./MenuItem-e4578955.js";import"./listItemTextClasses-a4497781.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};
