import{j as a,d as k,a as B,lH as z,b as P,r as C,lI as b,I as V,ks as y,R as l,lJ as _,lK as I,f as Y,z as A,lL as f,M as H,B as L,a2 as N,T as v,bv as R,lM as U}from"./index-3141de2d.js";import{c as G}from"./index.esm-8b587a7a.js";import{D as W,a as $}from"./DialogContent-17781b67.js";import{D as q}from"./DialogTitle-16416764.js";import{T as J}from"./TextField-ec161c03.js";import{D as K}from"./DialogActions-37bf04e2.js";import{C as Q}from"./CircularProgress-a64e9e1b.js";import{T as X}from"./index-a22dce01.js";import{T as Z,t as D}from"./TableRow-e26106d8.js";import{c as aa}from"./Grow-e0aea29d.js";import{C as ea}from"./CardContent-97006932.js";import{P as ta}from"./Select-369b8a03.js";import{D as sa}from"./Divider-e779ddd3.js";import{G as oa}from"./Grid2-488bb30d.js";import"./isMuiElement-2bebf9f1.js";import"./useMediaQuery-aa4be5c2.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"./dividerClasses-752b2dd5.js";import"./listItemTextClasses-5f5f8755.js";import"./index-e5978b8b.js";const ra=aa(a.jsx("path",{d:"M19 9h-4V3H9v6H5l7 7zm-8 2V5h2v6h1.17L12 13.17 9.83 11zm-6 7h14v2H5z"}),"DownloadOutlined"),ia=({open:t})=>{const r=k(),{backupDatabase:{backupData:i,dataBaseId:u,verifyPwdloading:c},system:{userAccessList:h}}=B(s=>({backupDatabase:z(s),system:P(s)})),d=s=>{r(b({key:s.target.name,value:s.target.value}))},o=()=>{const s={password:i.password};r(_({obj:s,dataBaseId:u}))},p=()=>{r(I(!1))};return C.useEffect(()=>{r(b({key:"password",value:i.password}))},[i.password,r]),a.jsxs(W,{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(G,{})})]}),a.jsx($,{children:a.jsx(y,{container:!0,spacing:2,children:a.jsx(y,{item:!0,xs:12,children:a.jsx(J,{fullWidth:!0,label:"Password",name:"password",type:"password",variant:"outlined",placeholder:"Enter Password",value:i.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(Q,{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=A(),[i,u]=C.useState(null),c=!!i,h=c?"simple-popover":void 0,{backupDatabase:{backUpDataBaselist:d,backUpDataBaseParams:o,loading:p,listCount:s},system:{userAccessList:n}}=B(e=>({backupDatabase:z(e),system:P(e)}));C.useEffect(()=>{t(f({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,O){return{index:e,code:m,name:g,createdon:x,databasefile:O}}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:!(n!=null&&n.includes("System.export_backup")),children:"Download"});return T(g,e==null?void 0:e.code,e==null?void 0:e.name,H(e==null?void 0:e.createdon).format("DD-MM-YYYY, h:mm:ss a"),x)}),E=e=>{u(e.currentTarget)},j=()=>{u(null)},F=(e,m)=>{t(f({...o,search:"",page:m+1}))},M=e=>{t(f({...o,search:"",page:1,page_size:parseInt(e.target.value)}))};return a.jsx(a.Fragment,{children:a.jsxs(L,{children:[a.jsxs(N,{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(R,{}),"Database Backup"]}),(n==null?void 0:n.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:i,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(U())},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:F,handleChangeRowsPerPage:M})}),a.jsx(ia,{open:!1})]})})};export{Ea as default};
