Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/components/Configure/Configure.js
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | import { | ||||
ThemedCopySolid, | ThemedCopySolid, | ||||
} from 'components/Common/CustomIcons'; | } from 'components/Common/CustomIcons'; | ||||
import { ReactComponent as Trashcan } from 'assets/trashcan.svg'; | import { ReactComponent as Trashcan } from 'assets/trashcan.svg'; | ||||
import { ReactComponent as Edit } from 'assets/edit.svg'; | import { ReactComponent as Edit } from 'assets/edit.svg'; | ||||
import { Event } from 'utils/GoogleAnalytics'; | import { Event } from 'utils/GoogleAnalytics'; | ||||
import ApiError from 'components/Common/ApiError'; | import ApiError from 'components/Common/ApiError'; | ||||
import CopyToClipboard from 'components/Common/CopyToClipboard'; | import CopyToClipboard from 'components/Common/CopyToClipboard'; | ||||
import { formatSavedBalance } from 'utils/formatting'; | import { formatSavedBalance } from 'utils/formatting'; | ||||
import { isValidXecAddress } from 'utils/validation'; | import { | ||||
isValidXecAddress, | |||||
isValidNewWalletNameLength, | |||||
} from 'utils/validation'; | |||||
import { convertToEcashPrefix } from 'utils/cashMethods'; | import { convertToEcashPrefix } from 'utils/cashMethods'; | ||||
import useWindowDimensions from 'hooks/useWindowDimensions'; | import useWindowDimensions from 'hooks/useWindowDimensions'; | ||||
import { isMobile, isIOS, isSafari } from 'react-device-detect'; | import { isMobile, isIOS, isSafari } from 'react-device-detect'; | ||||
import { currency } from 'components/Common/Ticker.js'; | import { currency } from 'components/Common/Ticker.js'; | ||||
const { Panel } = Collapse; | const { Panel } = Collapse; | ||||
const SettingsLinkCtn = styled.div` | const SettingsLinkCtn = styled.div` | ||||
color: ${props => props.theme.lightWhite}; | color: ${props => props.theme.lightWhite}; | ||||
▲ Show 20 Lines • Show All 680 Lines • ▼ Show 20 Lines | const handleChange = e => { | ||||
// Validate mnemonic on change | // Validate mnemonic on change | ||||
// Import button should be disabled unless mnemonic is valid | // Import button should be disabled unless mnemonic is valid | ||||
setIsValidMnemonic(validateMnemonic(value)); | setIsValidMnemonic(validateMnemonic(value)); | ||||
setFormData(p => ({ ...p, [name]: value })); | setFormData(p => ({ ...p, [name]: value })); | ||||
}; | }; | ||||
const changeWalletName = async () => { | const changeWalletName = async () => { | ||||
if ( | if (!isValidNewWalletNameLength(newWalletName)) { | ||||
newWalletName === '' || | |||||
newWalletName.length > currency.localStorageMaxCharacters | |||||
) { | |||||
setNewWalletNameIsValid(false); | setNewWalletNameIsValid(false); | ||||
return; | return; | ||||
} | } | ||||
// Hide modal | // Hide modal | ||||
setShowRenameWalletModal(false); | setShowRenameWalletModal(false); | ||||
// Change wallet name | // Change wallet name | ||||
console.log( | console.log( | ||||
`Changing wallet ${walletToBeRenamed.name} name to ${newWalletName}`, | `Changing wallet ${walletToBeRenamed.name} name to ${newWalletName}`, | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | const deleteSelectedWallet = async () => { | ||||
await updateSavedWallets(wallet); | await updateSavedWallets(wallet); | ||||
// Clear wallet delete confirmation from form | // Clear wallet delete confirmation from form | ||||
setConfirmationOfWalletToBeDeleted(''); | setConfirmationOfWalletToBeDeleted(''); | ||||
}; | }; | ||||
const handleWalletNameInput = e => { | const handleWalletNameInput = e => { | ||||
const { value } = e.target; | const { value } = e.target; | ||||
// validation | // validation | ||||
if ( | if (value && isValidNewWalletNameLength(value)) { | ||||
value && | |||||
value.length && | |||||
value.length <= currency.localStorageMaxCharacters | |||||
) { | |||||
setNewWalletNameIsValid(true); | setNewWalletNameIsValid(true); | ||||
} else { | } else { | ||||
setNewWalletNameIsValid(false); | setNewWalletNameIsValid(false); | ||||
} | } | ||||
setNewWalletName(value); | setNewWalletName(value); | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 1,053 Lines • Show Last 20 Lines |