From abcb0cbf5e8a1abb5ec4216a2bea584557b312da Mon Sep 17 00:00:00 2001 From: gala1234 Date: Mon, 4 Apr 2022 12:30:11 +0200 Subject: [PATCH] wip display validators settings on a modal --- nym-wallet/src/components/AppBar.tsx | 4 +- nym-wallet/src/context/main.tsx | 10 ++- nym-wallet/src/index.tsx | 3 +- nym-wallet/src/pages/balance/index.tsx | 3 - nym-wallet/src/pages/index.ts | 1 + .../pages/validators/ValidatorSelector.tsx | 9 ++- nym-wallet/src/pages/validators/index.tsx | 76 +++++++++++++++++-- 7 files changed, 88 insertions(+), 18 deletions(-) diff --git a/nym-wallet/src/components/AppBar.tsx b/nym-wallet/src/components/AppBar.tsx index 3d37378416..090bd7603e 100644 --- a/nym-wallet/src/components/AppBar.tsx +++ b/nym-wallet/src/components/AppBar.tsx @@ -8,7 +8,7 @@ import { Delegate as DelegateIcon } from '../svg-icons'; export const AppBar = () => { - const { showSettings, logOut, handleShowSettings, handleShowValidatorSettings } = useContext(ClientContext); + const { showSettings, showValidatorSettings, logOut, handleShowSettings, handleShowValidatorSettings } = useContext(ClientContext); return ( @@ -21,7 +21,7 @@ export const AppBar = () => { diff --git a/nym-wallet/src/context/main.tsx b/nym-wallet/src/context/main.tsx index ecd0b58331..ec4c16c542 100644 --- a/nym-wallet/src/context/main.tsx +++ b/nym-wallet/src/context/main.tsx @@ -119,8 +119,14 @@ export const ClientContextProvider = ({ children }: { children: React.ReactNode }; const handleShowAdmin = () => setShowAdmin((show) => !show); - const handleShowSettings = () => setShowSettings((show) => !show); - const handleShowValidatorSettings = () => setShowValidatorSettings((show) => !show); + const handleShowSettings = () => { + setShowSettings((show) => !show) + setShowValidatorSettings(false); + }; + const handleShowValidatorSettings = () => { + setShowValidatorSettings((show) => !show) + setShowSettings(false); + }; const switchNetwork = (_network: Network) => setNetwork(_network); const memoizedValue = useMemo( diff --git a/nym-wallet/src/index.tsx b/nym-wallet/src/index.tsx index f05b529d07..616ca2eac2 100644 --- a/nym-wallet/src/index.tsx +++ b/nym-wallet/src/index.tsx @@ -6,7 +6,7 @@ import { SnackbarProvider } from 'notistack'; import { Routes } from './routes'; import { ClientContext, ClientContextProvider } from './context/main'; import { ApplicationLayout } from './layouts'; -import { Admin, Welcome, Settings } from './pages'; +import { Admin, Welcome, Settings, ValidatorSettings } from './pages'; import { ErrorFallback } from './components'; import { NymWalletTheme, WelcomeTheme } from './theme'; import { maximizeWindow } from './utils'; @@ -26,6 +26,7 @@ const App = () => { + diff --git a/nym-wallet/src/pages/balance/index.tsx b/nym-wallet/src/pages/balance/index.tsx index 852ff59da1..54144f439f 100644 --- a/nym-wallet/src/pages/balance/index.tsx +++ b/nym-wallet/src/pages/balance/index.tsx @@ -19,9 +19,6 @@ export const Balance = () => { {userBalance.originalVesting && } - console.log('selectedValidator:', selectedValidator)} - /> ); }; diff --git a/nym-wallet/src/pages/index.ts b/nym-wallet/src/pages/index.ts index dc00ac2bb2..290d500ac8 100644 --- a/nym-wallet/src/pages/index.ts +++ b/nym-wallet/src/pages/index.ts @@ -9,3 +9,4 @@ export * from './welcome'; export * from './settings'; export * from './unbond'; export * from './undelegate'; +export * from './validators'; \ No newline at end of file diff --git a/nym-wallet/src/pages/validators/ValidatorSelector.tsx b/nym-wallet/src/pages/validators/ValidatorSelector.tsx index 16aac7481d..a7fcb748af 100644 --- a/nym-wallet/src/pages/validators/ValidatorSelector.tsx +++ b/nym-wallet/src/pages/validators/ValidatorSelector.tsx @@ -6,8 +6,8 @@ import { validatorUrls } from '../../utils'; type TValidatorUrl = string; -export const ValidatorSelector: React.FC<{ onChangeValidatorSelection: (validator: TValidatorUrl) => void }> = ({ - onChangeValidatorSelection, +export const ValidatorSelector: React.FC<{ onChangeValidatorSelection: (validator: TValidatorUrl) => void, type: string }> = ({ + onChangeValidatorSelection, type, }) => { const [validators, setValidators] = useState(); const [selectedValidator, setSelectedValidator] = useState(''); @@ -15,7 +15,7 @@ export const ValidatorSelector: React.FC<{ onChangeValidatorSelection: (validato const resetState = () => { setValidators(undefined); }; - + const { network } = useContext(ClientContext); @@ -29,6 +29,7 @@ export const ValidatorSelector: React.FC<{ onChangeValidatorSelection: (validato setValidators(validator?.urls); } })(); + console.log('type', type); // will unmount return () => resetState(); @@ -40,7 +41,7 @@ export const ValidatorSelector: React.FC<{ onChangeValidatorSelection: (validato return ( - Choose a Validator + {type}