feat: create and use copy function for utilities

This commit is contained in:
RadoslavDimchev 2024-01-18 17:25:58 +02:00
parent 0dd85010cd
commit 8dca2e7595
4 changed files with 10 additions and 5 deletions

View File

@ -2,7 +2,7 @@ import { Text } from '@status-im/components'
import { XStack, YStack } from 'tamagui'
import { CopyIcon, VerifiedIcon, ContactIcon } from '@status-im/icons'
import { getFormattedValidatorAddress } from '../../utilities'
import { copyFunction, getFormattedValidatorAddress } from '../../utilities'
type ValidatorNameAddressProps = {
name: string
@ -18,7 +18,7 @@ const ValidatorNameAddress = ({
isAvatarChipIncluded,
}: ValidatorNameAddressProps) => {
const onCopyAddress = () => {
navigator.clipboard.writeText(address)
copyFunction(address)
}
return (

View File

@ -7,6 +7,7 @@ import { Separator, YStack } from 'tamagui'
import { v4 as uuidv4 } from 'uuid'
import styles from './pairDevice.module.css'
import { copyFunction } from '../../utilities'
type GenerateIdProps = {
isAwaitingPairing: boolean
@ -24,7 +25,7 @@ const GenerateId = ({ isAwaitingPairing }: GenerateIdProps) => {
}
const copyGeneratedIdHandler = () => {
navigator.clipboard.writeText(generatedId)
copyFunction(generatedId)
}
return (

View File

@ -9,6 +9,7 @@ import wordlist from 'web-bip39/wordlists/english'
import { RootState } from '../../../redux/store'
import { setGeneratedMnemonic } from '../../../redux/ValidatorOnboarding/KeyGeneration/slice'
import styles from './index.module.css'
import { copyFunction } from '../../../utilities'
type RecoveryPhraseProps = {
isKeystoreFiles: boolean
@ -39,8 +40,7 @@ const RecoveryPhrase = ({ isKeystoreFiles }: RecoveryPhraseProps) => {
}
const copyRecoveryPhraseHandler = () => {
const text = generatedMnemonic.join(' ')
navigator.clipboard.writeText(text)
copyFunction(generatedMnemonic.join(' '))
if (!isTimeoutActive) {
setIsCopied(true)

View File

@ -68,3 +68,7 @@ export const getHeightPercentages = (amountOfElements: number) => {
return `${percentages}%`
}
export const copyFunction = (text: string) => {
navigator.clipboard.writeText(text)
}