only display general settings for mixnodes (#1700)
* only display general settings for mixnodes
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import * as Yup from 'yup';
|
||||
import {
|
||||
isLessThan,
|
||||
isValidHostname,
|
||||
validateAmount,
|
||||
validateKey,
|
||||
@@ -56,4 +57,15 @@ export const amountSchema = Yup.object().shape({
|
||||
return true;
|
||||
}),
|
||||
}),
|
||||
operatorCost: Yup.object().shape({
|
||||
amount: Yup.string()
|
||||
.required('An operating cost is required')
|
||||
.test('valid-operating-cost', 'A valid amount is required (min 40)', async function isValidAmount(this, value) {
|
||||
if (value && (!Number(value) || isLessThan(+value, 40))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}),
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -24,7 +24,7 @@ const defaultGatewayValues: GatewayData = {
|
||||
|
||||
const defaultAmountValues = (denom: CurrencyDenom) => ({
|
||||
amount: { amount: '100', denom },
|
||||
operatorCost: { amount: '0', denom },
|
||||
operatorCost: { amount: '40', denom },
|
||||
tokenPool: 'balance',
|
||||
});
|
||||
|
||||
|
||||
@@ -15,7 +15,8 @@ import { AppContext, urls } from 'src/context/main';
|
||||
|
||||
import { NodeGeneralSettings } from './settings-pages/general-settings';
|
||||
import { NodeUnbondPage } from './settings-pages/NodeUnbondPage';
|
||||
import { navItems, NodeSettingsNav } from './node-settings.constant';
|
||||
import { createNavItems } from './node-settings.constant';
|
||||
import { isMixnode } from 'src/types';
|
||||
|
||||
export const NodeSettings = () => {
|
||||
const theme = useTheme();
|
||||
@@ -25,9 +26,9 @@ export const NodeSettings = () => {
|
||||
const location = useLocation();
|
||||
|
||||
const [confirmationDetails, setConfirmationDetails] = useState<ConfirmationDetailProps>();
|
||||
const [value, setValue] = React.useState<NodeSettingsNav>('General');
|
||||
const [value, setValue] = React.useState('General');
|
||||
const handleChange = (event: React.SyntheticEvent, tab: string) => {
|
||||
setValue(tab as NodeSettingsNav);
|
||||
setValue(tab);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
@@ -53,6 +54,10 @@ export const NodeSettings = () => {
|
||||
});
|
||||
};
|
||||
|
||||
if (!bondedNode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<PageLayout>
|
||||
<NymCard
|
||||
@@ -76,7 +81,7 @@ export const NodeSettings = () => {
|
||||
</Box>
|
||||
<Box sx={{ width: '100%' }}>
|
||||
<Tabs
|
||||
tabs={navItems}
|
||||
tabs={createNavItems(isMixnode(bondedNode))}
|
||||
selectedTab={value}
|
||||
onChange={handleChange}
|
||||
tabSx={{
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
export const navItems = ['General', 'Unbond'] as const;
|
||||
|
||||
export type NodeSettingsNav = typeof navItems[number]; // type NodeSettingsNav = 'General' | 'Unbond';
|
||||
export const createNavItems = (isMixnode: boolean) => {
|
||||
const navItems = ['Unbond'];
|
||||
if (isMixnode) return ['General', ...navItems];
|
||||
return navItems;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user