import{j as a,d as D,a as B,lo as z,b as P,r as C,lp as b,I as _,k9 as y,z as l,lq as Y,lr as I,f as A,k as M,ls as f,w as N,B as R,R as U,T as k,bi as G,lt as H}from"./index-c5c88b67.js";import{c as L}from"./index.esm-0ad88c35.js";import{D as W,a as $}from"./DialogContent-1350b249.js";import{D as q}from"./DialogTitle-da236dcc.js";import{T as J}from"./TextField-78388962.js";import{D as K}from"./DialogActions-1232a7fa.js";import{C as Q}from"./CircularProgress-13afa056.js";import{T as X}from"./index-f0b37835.js";import{T as Z,t as v}from"./TableRow-2b359fa8.js";import{c as aa}from"./Grow-7345f8ea.js";import{C as ea}from"./CardContent-5f043396.js";import{P as ta}from"./Menu-e7d2b2ee.js";import{D as sa}from"./Divider-0dc41916.js";import{G as oa}from"./Grid2-0ff60c92.js";import"./isMuiElement-b3c21f38.js";import"./Select-4ed8db5d.js";import"./index-e5978b8b.js";import"./useMediaQuery-fe3ce37c.js";import"./TableContainer-c31f204a.js";import"./TableHead-c2c21491.js";import"./TablePagination-0147f84a.js";import"./KeyboardArrowRight-261f4f43.js";import"./Toolbar-f8d4b0c4.js";import"./MenuItem-81e44793.js";import"./dividerClasses-6bc0ca72.js";import"./listItemTextClasses-88792089.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=D(),{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(Y({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(_,{onClick:p,style:{position:"absolute",right:8,top:8},children:a.jsx(L,{})})]}),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"})]})]})};A(Z)(({theme:t})=>({[`&.${v.head}`]:{backgroundColor:t.palette.grey[100],color:t.palette.primary},[`&.${v.body}`]:{fontSize:14}}));const Fa=()=>{const t=D(),r=M(),[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,V){return{index:e,code:m,name:g,createdon:x,databasefile:V}}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,N(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}))},O=e=>{t(f({...o,search:"",page:1,page_size:parseInt(e.target.value)}))};return a.jsx(a.Fragment,{children:a.jsxs(R,{children:[a.jsxs(U,{children:[a.jsxs(ea,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[a.jsxs(k,{variant:"h4",sx:{display:"flex",alignItems:"center",gap:2,cursor:"pointer"},onClick:()=>{r("/pages/settings",{relative:"path"})},children:[a.jsx(G,{}),"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(k,{variant:"subtitle1",gutterBottom:!0,children:"Are you sure to Create Database Backup?"}),a.jsx(l,{variant:"contained",type:"submit",color:"primary",onClick:()=>{t(H())},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:O})}),a.jsx(ia,{open:!1})]})})};export{Fa as default};
