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-3141de2d.js";import{M as et}from"./MasterPageTitle-e75bb457.js";import{A as at}from"./add.city-1e26e204.js";import{c as it,b as st,u as rt}from"./index.esm-8b0c9a99.js";import{o as ot}from"./yup-c2fea6fa.js";import{d as nt}from"./Delete-5ebded29.js";import{e as pt}from"./Edit-abad5e84.js";import{C as lt}from"./index-f90cb72f.js";import{P as ct}from"./Select-369b8a03.js";import{T as mt}from"./TextField-ec161c03.js";import{I as dt}from"./InputAdornment-1680248d.js";import"./index.esm-8b587a7a.js";import"./Divider-e779ddd3.js";import"./dividerClasses-752b2dd5.js";import"./FilterFilled-94ea2c05.js";import"./AntdIcon-eb0da2c9.js";import"./objectSpread2-41b8b8d3.js";import"./index-a3f870f6.js";import"./GenericThumbnailView-c2621934.js";import"./popper-f3391c26.js";import"./Grow-e0aea29d.js";import"./ScrollableList-fa62971d.js";import"./CircularProgress-a64e9e1b.js";import"./FormInput-abff9e70.js";import"./FormControlLabel-c4983ca8.js";import"./Checkbox-8808455f.js";import"./SwitchBase-416973c8.js";import"./componentStyles-24f97919.js";import"./TableRow-e26106d8.js";import"./TextArea-ceaff311.js";import"./SelectComponent-90299b7f.js";import"./DialogContent-17781b67.js";import"./DialogTitle-16416764.js";import"./DialogContentText-c64ca110.js";import"./Grid2-488bb30d.js";import"./isMuiElement-2bebf9f1.js";import"./DialogActions-37bf04e2.js";import"./TableContainer-e4a79220.js";import"./TableHead-6dad4842.js";import"./TablePagination-377a84d4.js";import"./KeyboardArrowRight-d5826f7e.js";import"./Toolbar-c1e97401.js";import"./MenuItem-d41bf2e5.js";import"./listItemTextClasses-5f5f8755.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};
