feat: create and use copy function for utilities
This commit is contained in:
parent
0dd85010cd
commit
8dca2e7595
|
@ -2,7 +2,7 @@ import { Text } from '@status-im/components'
|
||||||
import { XStack, YStack } from 'tamagui'
|
import { XStack, YStack } from 'tamagui'
|
||||||
import { CopyIcon, VerifiedIcon, ContactIcon } from '@status-im/icons'
|
import { CopyIcon, VerifiedIcon, ContactIcon } from '@status-im/icons'
|
||||||
|
|
||||||
import { getFormattedValidatorAddress } from '../../utilities'
|
import { copyFunction, getFormattedValidatorAddress } from '../../utilities'
|
||||||
|
|
||||||
type ValidatorNameAddressProps = {
|
type ValidatorNameAddressProps = {
|
||||||
name: string
|
name: string
|
||||||
|
@ -18,7 +18,7 @@ const ValidatorNameAddress = ({
|
||||||
isAvatarChipIncluded,
|
isAvatarChipIncluded,
|
||||||
}: ValidatorNameAddressProps) => {
|
}: ValidatorNameAddressProps) => {
|
||||||
const onCopyAddress = () => {
|
const onCopyAddress = () => {
|
||||||
navigator.clipboard.writeText(address)
|
copyFunction(address)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { Separator, YStack } from 'tamagui'
|
||||||
import { v4 as uuidv4 } from 'uuid'
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
|
|
||||||
import styles from './pairDevice.module.css'
|
import styles from './pairDevice.module.css'
|
||||||
|
import { copyFunction } from '../../utilities'
|
||||||
|
|
||||||
type GenerateIdProps = {
|
type GenerateIdProps = {
|
||||||
isAwaitingPairing: boolean
|
isAwaitingPairing: boolean
|
||||||
|
@ -24,7 +25,7 @@ const GenerateId = ({ isAwaitingPairing }: GenerateIdProps) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const copyGeneratedIdHandler = () => {
|
const copyGeneratedIdHandler = () => {
|
||||||
navigator.clipboard.writeText(generatedId)
|
copyFunction(generatedId)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -9,6 +9,7 @@ import wordlist from 'web-bip39/wordlists/english'
|
||||||
import { RootState } from '../../../redux/store'
|
import { RootState } from '../../../redux/store'
|
||||||
import { setGeneratedMnemonic } from '../../../redux/ValidatorOnboarding/KeyGeneration/slice'
|
import { setGeneratedMnemonic } from '../../../redux/ValidatorOnboarding/KeyGeneration/slice'
|
||||||
import styles from './index.module.css'
|
import styles from './index.module.css'
|
||||||
|
import { copyFunction } from '../../../utilities'
|
||||||
|
|
||||||
type RecoveryPhraseProps = {
|
type RecoveryPhraseProps = {
|
||||||
isKeystoreFiles: boolean
|
isKeystoreFiles: boolean
|
||||||
|
@ -39,8 +40,7 @@ const RecoveryPhrase = ({ isKeystoreFiles }: RecoveryPhraseProps) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const copyRecoveryPhraseHandler = () => {
|
const copyRecoveryPhraseHandler = () => {
|
||||||
const text = generatedMnemonic.join(' ')
|
copyFunction(generatedMnemonic.join(' '))
|
||||||
navigator.clipboard.writeText(text)
|
|
||||||
|
|
||||||
if (!isTimeoutActive) {
|
if (!isTimeoutActive) {
|
||||||
setIsCopied(true)
|
setIsCopied(true)
|
||||||
|
|
|
@ -68,3 +68,7 @@ export const getHeightPercentages = (amountOfElements: number) => {
|
||||||
|
|
||||||
return `${percentages}%`
|
return `${percentages}%`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const copyFunction = (text: string) => {
|
||||||
|
navigator.clipboard.writeText(text)
|
||||||
|
}
|
Loading…
Reference in New Issue