diff --git a/nym-wallet/src/pages/bonding/node-settings/general-settings/InfoSettings.tsx b/nym-wallet/src/pages/bonding/node-settings/general-settings/InfoSettings.tsx index fc9f4a3b32..60999e9cd4 100644 --- a/nym-wallet/src/pages/bonding/node-settings/general-settings/InfoSettings.tsx +++ b/nym-wallet/src/pages/bonding/node-settings/general-settings/InfoSettings.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import { useEffect, useState } from 'react'; import { Box, Button, Divider, Typography, TextField, Grid } from '@mui/material'; type TSettingItem = { @@ -10,6 +10,7 @@ type TSettingItem = { const portRegex = /^\d{4}$/; const ipRegex = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/; +// TODO: only accept valid nym wallet versions const appVersionRegex = /^\d+(?:\.\d+){2}$/gm; const currentMixPort: TSettingItem = { id: 'mixPort', title: 'Mix port', value: '1789' }; @@ -28,7 +29,6 @@ export const InfoSettings = ({ onSaveChanges }: { onSaveChanges: () => void }) = const [version, setVersion] = useState(currentVersion); useEffect(() => { - console.log('host.value.match(ipRegex)', Boolean(host.value.match(ipRegex))); if (valueChanged) { if ( Boolean(mixPort.value.match(portRegex)) && @@ -60,7 +60,7 @@ export const InfoSettings = ({ onSaveChanges }: { onSaveChanges: () => void }) = - + void }) = fullWidth /> - + void }) = fullWidth /> - + void }) = - + void }) = - + void }) => { - const [valueChanged, setValueChanged] = useState(false); - const [mixPortValue, setMixPortValue] = useState('1789'); + const [buttonActive, setButtonActive] = useState(false); + const [profitMargin, setProfitMargin] = useState(currentProfitMargin); + const [operatorCost, setOperatorCost] = useState(currentOperatorCost); - const profitMarginSettings = [{ id: 'profit-margin', title: 'Profit margin', value: '10%' }]; - const operatorCostSettings = [{ id: 'operator-cost', title: 'Operator cost', value: '40 NYM' }]; + useEffect(() => { + if (!profitMargin.value || !operatorCost.value) { + setButtonActive(false); + } + }, [profitMargin, operatorCost]); return ( - Port + Profit Margin (t.palette.mode === 'light' ? t.palette.nym.text.muted : 'text.primary'), }} > - Change profit margin of your node + Profit margin can be changed once a month - {profitMarginSettings.map((item) => ( - - console.log(`Field ${item.id} has change`, e.target.value)} - autoFocus - fullWidth - /> - - ))} + + { + console.log('parseInt(e.target.value)', { ...profitMargin, value: parseInt(e.target.value) }); + setProfitMargin({ ...profitMargin, value: parseInt(e.target.value) || '' }); + setButtonActive(true); + }} + fullWidth + InputProps={{ + endAdornment: ( + + NYM + + ), + }} + /> + - Host + Operator cost (t.palette.mode === 'light' ? t.palette.nym.text.muted : 'text.primary'), }} > - Lock wallet after certain time + Lock Wallet after a certain time - {operatorCostSettings.map((item) => ( - - console.log(`Field ${item.id} has change`, e.target.value)} - autoFocus - fullWidth - /> - - ))} + + { + console.log('nym', { ...operatorCost, value: parseInt(e.target.value) }); + setOperatorCost({ ...operatorCost, value: parseInt(e.target.value) || '' }); + setButtonActive(true); + }} + fullWidth + InputProps={{ + endAdornment: ( + + % + + ), + }} + /> + @@ -71,7 +100,7 @@ export const ParametersSettings = ({ onSaveChanges }: { onSaveChanges: () => voi