import{j as a,d as k,a as B,nP as z,b as P,r as f,nQ as y,I as V,my as b,U as l,cH as _,nR as A,nS as I,f as Y,A as H,nT as C,O as M,B as N,a3 as R,T as v,bC as G,nU as L}from"./index-60657852.js";import{c as W}from"./index.esm-5fae0aa9.js";import{D as $,a as q}from"./DialogContent-d5183bd6.js";import{D as Q}from"./DialogTitle-66c21479.js";import{T as J}from"./TextField-6b778b78.js";import{D as K}from"./DialogActions-1dfa5a01.js";import{T as X}from"./index-bcfba32e.js";import{T as Z,t as D}from"./TableRow-0ab1e69a.js";import{c as aa}from"./Grow-a21bdd26.js";import{C as ea}from"./CardContent-f8a5d460.js";import{P as ta}from"./Select-7d2a5359.js";import{D as sa}from"./Divider-6555f8d4.js";import{G as oa}from"./Grid2-09163d35.js";import"./isMuiElement-82a67859.js";import"./index-c6051076.js";import"./TableContainer-c3087864.js";import"./TableHead-1ba4d27d.js";import"./TablePagination-dd506b19.js";import"./KeyboardArrowRight-5039311c.js";import"./LastPage-c4cc7e5b.js";import"./Toolbar-e6f520d9.js";import"./MenuItem-64348b57.js";import"./dividerClasses-590294d7.js";import"./listItemTextClasses-81f8effc.js";import"./listItemIconClasses-39f47a05.js";const ra=aa(a.jsx("path",{d:"M19 9h-4V3H9v6H5l7 7zm-8 2V5h2v6h1.17L12 13.17 9.83 11zm-6 7h14v2H5z"}),"DownloadOutlined"),na=({open:t})=>{const r=k(),{backupDatabase:{backupData:n,dataBaseId:u,verifyPwdloading:c},system:{userAccessList:h}}=B(s=>({backupDatabase:z(s),system:P(s)})),d=s=>{r(y({key:s.target.name,value:s.target.value}))},o=()=>{const s={password:n.password};r(A({obj:s,dataBaseId:u}))},p=()=>{r(I(!1))};return f.useEffect(()=>{r(y({key:"password",value:n.password}))},[n.password,r]),a.jsxs($,{open:t,onClose:p,maxWidth:"sm",fullWidth:!0,children:[a.jsxs(Q,{children:["Verify Password",a.jsx(V,{onClick:p,style:{position:"absolute",right:8,top:8},children:a.jsx(W,{})})]}),a.jsx(q,{children:a.jsx(b,{container:!0,spacing:2,children:a.jsx(b,{item:!0,xs:12,children:a.jsx(J,{fullWidth:!0,label:"Password",name:"password",type:"password",variant:"outlined",placeholder:"Enter Password",value:n.password||"",onChange:d,required:!0})})})}),a.jsxs(K,{children:[a.jsx(l,{onClick:p,color:"secondary",variant:"outlined",children:"Cancel"}),a.jsx(l,{onClick:o,color:"primary",variant:"contained",disabled:c,endIcon:c?a.jsx(_,{size:20}):null,children:"Verify"})]})]})};Y(Z)(({theme:t})=>({[`&.${D.head}`]:{backgroundColor:t.palette.grey[100],color:t.palette.primary},[`&.${D.body}`]:{fontSize:14}}));const Ea=()=>{const t=k(),r=H(),[n,u]=f.useState(null),c=!!n,h=c?"simple-popover":void 0,{backupDatabase:{backUpDataBaselist:d,backUpDataBaseParams:o,loading:p,listCount:s},system:{userAccessList:i}}=B(e=>({backupDatabase:z(e),system:P(e)}));f.useEffect(()=>{t(C({page:1,search:"",page_size:10}))},[]);const S=[{title:"S.No",width:100},{title:"Code",width:100},{title:"Name",width:100},{title:"Created On",width:100},{title:"Database File",width:100}];function T(e,m,g,x,U){return{index:e,code:m,name:g,createdon:x,databasefile:U}}const w=d==null?void 0:d.map((e,m)=>{const g=(o.page-1)*o.page_size+(m+1),x=a.jsx(l,{variant:"contained",color:"primary",size:"small",startIcon:a.jsx(ra,{}),onClick:()=>t(I({model:!0,Id:e==null?void 0:e.id})),disabled:!(i!=null&&i.includes("System.export_backup")),children:"Download"});return T(g,e==null?void 0:e.code,e==null?void 0:e.name,M(e==null?void 0:e.createdon).format("DD-MM-YYYY, h:mm:ss a"),x)}),E=e=>{u(e.currentTarget)},j=()=>{u(null)},O=(e,m)=>{t(C({...o,search:"",page:m+1}))},F=e=>{t(C({...o,search:"",page:1,page_size:parseInt(e.target.value)}))};return a.jsx(a.Fragment,{children:a.jsxs(N,{children:[a.jsxs(R,{children:[a.jsxs(ea,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsxs(v,{variant:"h4",sx:{display:"flex",alignItems:"center",gap:2,cursor:"pointer"},onClick:()=>{r("/pages/settings",{relative:"path"})},children:[a.jsx(G,{}),"Database Backup"]}),(i==null?void 0:i.indexOf("System.add_backup"))!==-1&&a.jsxs(a.Fragment,{children:[a.jsx(l,{"aria-describedby":h,variant:"contained",onClick:E,color:"primary",style:{marginBottom:"15px"},size:"large",children:"Create Database Backup"}),a.jsx(ta,{id:h,open:c,anchorEl:n,onClose:j,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"bottom",horizontal:"left"},children:a.jsxs("div",{style:{padding:"15px"},children:[a.jsx(v,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to Create Database Backup?"}),a.jsx(l,{variant:"contained",type:"submit",color:"primary",onClick:()=>{t(L())},autoFocus:!0,children:"Yes"}),a.jsx(l,{variant:"outlined",size:"small",onClick:j,style:{marginLeft:"20px"},children:"No"})]})})]})]}),a.jsx(sa,{})]}),a.jsx(oa,{size:{xs:12},sx:{mt:3},children:a.jsx(X,{count:s,columns:S,rows:w,loading:p,page:o.page,pageSize:o.page_size,handleChangePage:O,handleChangeRowsPerPage:F})}),a.jsx(na,{open:!1})]})})};export{Ea as default};
