From bb4bcc911535169ba47cd68b90c6ffa66ee6b5e7 Mon Sep 17 00:00:00 2001 From: zzggo Date: Thu, 19 Dec 2024 16:52:41 +1100 Subject: [PATCH] fixed: add googlebackup component --- .../LandingPages/GoogleBackup.tsx | 176 ++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100644 src/ui/FRWComponent/LandingPages/GoogleBackup.tsx diff --git a/src/ui/FRWComponent/LandingPages/GoogleBackup.tsx b/src/ui/FRWComponent/LandingPages/GoogleBackup.tsx new file mode 100644 index 00000000..23eef0ee --- /dev/null +++ b/src/ui/FRWComponent/LandingPages/GoogleBackup.tsx @@ -0,0 +1,176 @@ +import InfoIcon from '@mui/icons-material/Info'; +import { Button, Typography } from '@mui/material'; +import { Box } from '@mui/system'; +import React, { useState } from 'react'; + +import SlideRelative from '@/ui/FRWComponent/SlideRelative'; +import { LLSpinner } from 'ui/FRWComponent'; +import { useWallet } from 'ui/utils'; + +import IconGoogleDrive from '../../../components/iconfont/IconGoogleDrive'; + +interface GoogleBackupProps { + handleSwitchTab: () => void; + mnemonic: string; + username: string; + password: string; +} + +const GoogleBackup: React.FC = ({ + handleSwitchTab, + mnemonic, + username, + password, +}) => { + const wallets = useWallet(); + const [loading, setLoading] = useState(false); + const [backupErr, setBackupErr] = useState(false); + + const handleBackup = () => { + try { + setLoading(true); + setBackupErr(false); + wallets + .uploadMnemonicToGoogleDrive(mnemonic, username, password) + .then(() => { + setLoading(false); + handleSwitchTab(); + }) + .catch(() => { + setLoading(false); + setBackupErr(true); + }); + } catch (e) { + console.error(e); + setLoading(false); + } + }; + + return ( + + + {chrome.i18n.getMessage('Create')} + + {chrome.i18n.getMessage('Back_up')} + + + + {chrome.i18n.getMessage('Back_up_your_wallet_to_Google_Drive_for_easy_access')} + + + + + {chrome.i18n.getMessage('Recommend')} + + + + + {chrome.i18n.getMessage('Connect__To')} + + {chrome.i18n.getMessage('Google__Drive')} + + {chrome.i18n.getMessage('to_back_up_your_wallet')} + + + + + + + + + + {chrome.i18n.getMessage('Backup_failed_you_may_still_conduct_backup_inside_extension')} + + + + + + + + + ); +}; + +export default GoogleBackup;