From 498dbb8ba3e7b104f8adc7101561deaecb3ae68d Mon Sep 17 00:00:00 2001 From: fmtabbara Date: Fri, 20 Aug 2021 12:24:04 +0100 Subject: [PATCH] add balance page --- tauri-wallet/package.json | 1 + tauri-wallet/src/components/Confirmation.tsx | 43 +++++++++++++++++ tauri-wallet/src/components/Layout.tsx | 5 ++ tauri-wallet/src/components/NoClientError.tsx | 13 +++++ tauri-wallet/src/context/main.tsx | 20 ++++++++ tauri-wallet/src/index.tsx | 5 +- tauri-wallet/src/routes/balance.tsx | 48 +++++++++++++++++++ tauri-wallet/src/routes/index.tsx | 4 ++ tauri-wallet/src/routes/receive.tsx | 9 ++-- tauri-wallet/yarn.lock | 20 +++++--- 10 files changed, 157 insertions(+), 11 deletions(-) create mode 100644 tauri-wallet/src/components/Confirmation.tsx create mode 100644 tauri-wallet/src/components/NoClientError.tsx create mode 100644 tauri-wallet/src/context/main.tsx diff --git a/tauri-wallet/package.json b/tauri-wallet/package.json index 1719c1bf86..a6864d6a52 100644 --- a/tauri-wallet/package.json +++ b/tauri-wallet/package.json @@ -12,6 +12,7 @@ "@babel/preset-typescript": "^7.15.0", "@material-ui/core": "^4.12.3", "@material-ui/icons": "^4.11.2", + "@material-ui/lab": "^4.0.0-alpha.60", "@material-ui/styles": "^4.11.4", "@types/react-dom": "^17.0.9", "clsx": "^1.1.1", diff --git a/tauri-wallet/src/components/Confirmation.tsx b/tauri-wallet/src/components/Confirmation.tsx new file mode 100644 index 0000000000..23736d8878 --- /dev/null +++ b/tauri-wallet/src/components/Confirmation.tsx @@ -0,0 +1,43 @@ +import React from 'react' +import Typography from '@material-ui/core/Typography' +import Grid from '@material-ui/core/Grid' +import { CircularProgress } from '@material-ui/core' +import { Alert, AlertTitle } from '@material-ui/lab' + +type ConfirmationProps = { + isLoading: boolean + progressMessage: string + successMessage: string + failureMessage: string + error: Error +} + +export const Confirmation = ({ + isLoading, + progressMessage, + successMessage, + failureMessage, + error, +}: ConfirmationProps) => { + return isLoading ? ( + <> + + {progressMessage} + + + + + + ) : ( + <> + {error === null ? ( + {successMessage} + ) : ( + + {error.name} + {failureMessage} - {error.message} + + )} + + ) +} diff --git a/tauri-wallet/src/components/Layout.tsx b/tauri-wallet/src/components/Layout.tsx index 38246285d6..1eeff7acad 100644 --- a/tauri-wallet/src/components/Layout.tsx +++ b/tauri-wallet/src/components/Layout.tsx @@ -8,6 +8,11 @@ export const Layout = ({ children }: { children: React.ReactElement }) => {
diff --git a/tauri-wallet/src/components/NoClientError.tsx b/tauri-wallet/src/components/NoClientError.tsx new file mode 100644 index 0000000000..9e1022babb --- /dev/null +++ b/tauri-wallet/src/components/NoClientError.tsx @@ -0,0 +1,13 @@ +import React from 'react' +import { Link } from 'react-router-dom' +import { Alert, AlertTitle } from '@material-ui/lab' + +export const NoClientError = () => { + return ( + + No client detected + Have you signed in? Try to go back to{' '} + the main page and try again + + ) +} diff --git a/tauri-wallet/src/context/main.tsx b/tauri-wallet/src/context/main.tsx new file mode 100644 index 0000000000..0999ab6840 --- /dev/null +++ b/tauri-wallet/src/context/main.tsx @@ -0,0 +1,20 @@ +import React, { createContext } from 'react' + +type TClientContext = { + client: {} +} + +export const ClientContext = createContext({} as TClientContext) + +export const ClientContextProvider = ({ + children, +}: { + children: React.ReactNode +}) => { + const client = {} + return ( + + {children} + + ) +} diff --git a/tauri-wallet/src/index.tsx b/tauri-wallet/src/index.tsx index 9d1eb07fe9..1399b3b150 100644 --- a/tauri-wallet/src/index.tsx +++ b/tauri-wallet/src/index.tsx @@ -3,11 +3,14 @@ import ReactDOM from 'react-dom' import { CssBaseline, ThemeProvider } from '@material-ui/core' import { Routes } from './routes' import { theme } from './theme' +import { ClientContextProvider } from './context/main' const App = () => ( - + + + ) diff --git a/tauri-wallet/src/routes/balance.tsx b/tauri-wallet/src/routes/balance.tsx index e69de29bb2..136d91fff4 100644 --- a/tauri-wallet/src/routes/balance.tsx +++ b/tauri-wallet/src/routes/balance.tsx @@ -0,0 +1,48 @@ +import React, { useContext } from 'react' +import { Button, Grid } from '@material-ui/core' +import { Refresh } from '@material-ui/icons' +import { Layout, NymCard, Page } from '../components' +import { NoClientError } from '../components/NoClientError' +import { Confirmation } from '../components/Confirmation' +import { ClientContext } from '../context/main' + +export const Balance = () => { + const { client } = useContext(ClientContext) + return ( + + + + {client === null ? ( + + ) : ( + + + + + +
+ +
+
+
+ )} +
+
+
+ ) +} diff --git a/tauri-wallet/src/routes/index.tsx b/tauri-wallet/src/routes/index.tsx index df0ff02899..d462bd3919 100644 --- a/tauri-wallet/src/routes/index.tsx +++ b/tauri-wallet/src/routes/index.tsx @@ -2,6 +2,7 @@ import React from 'react' import { Switch, Route } from 'react-router-dom' import { BrowserRouter as Router } from 'react-router-dom' import { NotFound } from './404' +import { Balance } from './balance' import { Receive } from './receive' import { Send } from './send' import { SignIn } from './sign-in' @@ -12,6 +13,9 @@ export const Routes = () => ( + + + diff --git a/tauri-wallet/src/routes/receive.tsx b/tauri-wallet/src/routes/receive.tsx index b3103fcd03..578d9e0941 100644 --- a/tauri-wallet/src/routes/receive.tsx +++ b/tauri-wallet/src/routes/receive.tsx @@ -1,7 +1,9 @@ import React from 'react' import { Card, CardContent, Grid, Typography } from '@material-ui/core' +import { Alert } from '@material-ui/lab' import { CopyToClipboard, Layout, NymCard, Page } from '../components' import { useMediaQuery } from '@material-ui/core' +import { theme } from '../theme' export const Receive = () => { const matches = useMediaQuery('(min-width:769px)') @@ -13,18 +15,19 @@ export const Receive = () => { - + You can receive tokens by providing this address to the sender - + - +