import{j as a,d as k,a as B,lG as z,b as P,r as C,lH as b,I as _,kr as y,R as l,lI as M,lJ as I,f as Y,z as A,lK as f,M as G,B as H,a2 as L,T as v,bv as N,lL as R}from"./index-dc933734.js";import{c as U}from"./index.esm-cd80da5b.js";import{D as W,a as $}from"./DialogContent-d9f48895.js";import{D as q}from"./DialogTitle-4ec33ac0.js";import{T as J}from"./TextField-a8016ff3.js";import{D as K}from"./DialogActions-9dacec58.js";import{C as Q}from"./CircularProgress-b8ef250f.js";import{T as X}from"./index-ad373baf.js";import{T as Z,t as D}from"./TableRow-f425a931.js";import{c as aa}from"./Grow-3459ea54.js";import{C as ea}from"./CardContent-06dac9b3.js";import{P as ta}from"./Select-e75c6695.js";import{D as sa}from"./Divider-b8be3c1c.js";import{G as ra}from"./Grid2-9337452f.js";import"./isMuiElement-f75ebb7c.js";import"./useMediaQuery-c00165e7.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"./dividerClasses-75377d2f.js";import"./listItemTextClasses-436d31bc.js";import"./index-e5978b8b.js";const oa=aa(a.jsx("path",{d:"M19 9h-4V3H9v6H5l7 7zm-8 2V5h2v6h1.17L12 13.17 9.83 11zm-6 7h14v2H5z"}),"DownloadOutlined"),ia=({open:t})=>{const o=k(),{backupDatabase:{backupData:i,dataBaseId:u,verifyPwdloading:c},system:{userAccessList:h}}=B(s=>({backupDatabase:z(s),system:P(s)})),d=s=>{o(b({key:s.target.name,value:s.target.value}))},r=()=>{const s={password:i.password};o(M({obj:s,dataBaseId:u}))},p=()=>{o(I(!1))};return C.useEffect(()=>{o(b({key:"password",value:i.password}))},[i.password,o]),a.jsxs(W,{open:t,onClose:p,maxWidth:"sm",fullWidth:!0,children:[a.jsxs(q,{children:["Verify Password",a.jsx(_,{onClick:p,style:{position:"absolute",right:8,top:8},children:a.jsx(U,{})})]}),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:r,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(),o=A(),[i,u]=C.useState(null),c=!!i,h=c?"simple-popover":void 0,{backupDatabase:{backUpDataBaselist:d,backUpDataBaseParams:r,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,V){return{index:e,code:m,name:g,createdon:x,databasefile:V}}const w=d==null?void 0:d.map((e,m)=>{const g=(r.page-1)*r.page_size+(m+1),x=a.jsx(l,{variant:"contained",color:"primary",size:"small",startIcon:a.jsx(oa,{}),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,G(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({...r,search:"",page:m+1}))},O=e=>{t(f({...r,search:"",page:1,page_size:parseInt(e.target.value)}))};return a.jsx(a.Fragment,{children:a.jsxs(H,{children:[a.jsxs(L,{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:()=>{o("/pages/settings",{relative:"path"})},children:[a.jsx(N,{}),"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(R())},autoFocus:!0,children:"Yes"}),a.jsx(l,{variant:"outlined",size:"small",onClick:j,style:{marginLeft:"20px"},children:"No"})]})})]})]}),a.jsx(sa,{})]}),a.jsx(ra,{size:{xs:12},sx:{mt:3},children:a.jsx(X,{count:s,columns:S,rows:w,loading:p,page:r.page,pageSize:r.page_size,handleChangePage:F,handleChangeRowsPerPage:O})}),a.jsx(ia,{open:!1})]})})};export{Ea as default};
