import{d as G,r as p,b4 as H,a as J,nS as K,b as Q,j as t,B as U,s1 as W,s2 as f,T as X,R as C,s3 as n,s4 as Z,s5 as L,_ as w,s6 as ee}from"./index-dc933734.js";import{M as te}from"./MasterPageTitle-7544e586.js";import{A as ae}from"./add.city-63b2e0a6.js";import{c as ie,b as se,u as re}from"./index.esm-288e984c.js";import{o as oe}from"./yup-5b2e0cf9.js";import{d as ne}from"./Delete-5ebded29.js";import{e as pe}from"./Edit-abad5e84.js";import{C as le}from"./index-fd772b91.js";import{P as ce}from"./Select-e75c6695.js";import{T as me}from"./TextField-a8016ff3.js";import{I as de}from"./InputAdornment-a4d846b9.js";import"./index.esm-cd80da5b.js";import"./Divider-b8be3c1c.js";import"./dividerClasses-75377d2f.js";import"./FilterFilled-5453348f.js";import"./AntdIcon-bb02d05f.js";import"./objectSpread2-d52818a5.js";import"./index-9b86adbc.js";import"./GenericThumbnailView-69a8725b.js";import"./popper-f3391c26.js";import"./Grow-3459ea54.js";import"./ScrollableList-c8354e44.js";import"./CircularProgress-b8ef250f.js";import"./FormInput-58d4b01b.js";import"./FormControlLabel-476fd96c.js";import"./componentStyles-4df963a1.js";import"./TableRow-f425a931.js";import"./TextArea-80ac5c9b.js";import"./SelectComponent-9cd23c63.js";import"./DialogContent-d9f48895.js";import"./DialogTitle-4ec33ac0.js";import"./DialogContentText-e0ace713.js";import"./Grid2-9337452f.js";import"./isMuiElement-f75ebb7c.js";import"./DialogActions-9dacec58.js";import"./TableContainer-dd105b51.js";import"./TableHead-2909bf19.js";import"./TablePagination-4ad2d9ff.js";import"./KeyboardArrowRight-e096ea37.js";import"./Toolbar-e48cc4d1.js";import"./MenuItem-03911a3a.js";import"./listItemTextClasses-436d31bc.js";import"./index-e5978b8b.js";const st=()=>{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:he,masterValue:z,masterEditId:_},system:{userAccessList:r}}=J(e=>({city:K(e),system:Q(e)})),T=[{title:"S.No",width:100},{title:"Code",width:100},{title:"Name",width:100},{title:"State",width:100},{title:"Actions",width:100}];function M(e,s,d,h,l){return{index:e,code:s,name:d,state:h,actions:l}}let P=ie({search:se()});const{control:ge,handleSubmit:O,register:B,reset:E}=re({resolver:oe(P),values:{search:i.search}}),k=(e,s)=>{v(s),x(e.currentTarget)},m=()=>{x(null)},F=e=>{a(ee({id:e,clearDataFn:()=>{},navigate:s=>{},pageParams:i})),a(n({...i,search:"",page:1,page_size:10})),m()},V=I.map((e,s)=>{var l;const d=(i.page-1)*i.page_size+(s+1),h=t.jsxs(U,{justifyContent:"center",alignItems:"center",sx:{display:"flex",gap:2},children:[(r==null?void 0:r.indexOf("DynamicDjango.change_city"))!==-1&&t.jsx("img",{src:pe,alt:"edit",style:{cursor:"pointer",width:"15px",height:"15px"},onClick:()=>{a(W({id:e==null?void 0:e.id})),y(!0),a(f(e==null?void 0:e.id))}}),(r==null?void 0:r.indexOf("DynamicDjango.delete_city"))!==-1&&t.jsxs(t.Fragment,{children:[t.jsx("img",{src:ne,alt:"edit",style:{cursor:"pointer",width:"15px",height:"15px"},onClick:q=>k(q,e==null?void 0:e.id)}),t.jsx(ce,{id:c?String(c):void 0,open:S,anchorEl:u,onClose:m,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:t.jsxs("div",{style:{padding:"15px"},children:[t.jsx(X,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to delete this Record?"}),t.jsx(C,{variant:"contained",type:"submit",color:"primary",onClick:()=>F(c),autoFocus:!0,children:"Yes"}),t.jsx(C,{variant:"outlined",size:"small",onClick:m,style:{marginLeft:"20px"},children:"No"})]})})]})]});return M(d,e.code,e.name,(l=e.state)==null?void 0:l.name,h)}),A=({search:e})=>{a(n({...i,search:e||"",page:1,page_size:10}))},N=(e,s)=>{a(n({...i,search:"",page:s+1}))},R=e=>{a(n({...i,search:"",page:1,page_size:parseInt(e.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=e=>{a(Z({})),a(f(0)),g(e),a(L(e))},$=()=>{g(!1)},Y=e=>{const s=e.target.value;a(n({...i,search:s||"",page:1,page_size:10}))};return t.jsxs(t.Fragment,{children:[t.jsx(te,{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:t.jsx("form",{onSubmit:O(A),children:t.jsx(me,{type:"text",sx:{width:"300px"},...B("search"),size:"small",InputProps:{startAdornment:t.jsx(de,{position:"start",children:t.jsx(w,{size:16})})},variant:"outlined",placeholder:"Search",onChange:Y})}),children:t.jsx(le,{count:b,columns:T,rows:V,loading:D,page:i.page,pageSize:i.page_size,handleChangePage:N,handleChangeRowsPerPage:R,showPagination:!0})}),t.jsx(ae,{modal:j,closeModal:$,mastersName:"City",edit_Id:_,mastersValue:z})]})};export{st as default};
