From 2049b40185e3de50c1d69db7c87ac9105884901d Mon Sep 17 00:00:00 2001 From: RadoslavDimchev Date: Thu, 17 Aug 2023 18:02:35 +0300 Subject: [PATCH] fix: add setter and give props --- src/pages/PairDevice/SyncStatus.tsx | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/pages/PairDevice/SyncStatus.tsx b/src/pages/PairDevice/SyncStatus.tsx index 2f54fde2..17efae46 100644 --- a/src/pages/PairDevice/SyncStatus.tsx +++ b/src/pages/PairDevice/SyncStatus.tsx @@ -1,23 +1,32 @@ +import { useEffect, useState } from 'react' import { XStack, YStack } from 'tamagui' import { Button, IconButton, InformationBox, Text } from '@status-im/components' + import Icon from '../../components/General/Icon' import RefreshBlackIcon from '/icons/refresh-black.svg' import RefreshIcon from '/icons/refresh.svg' import BlockIcon from '/icons/block.svg' import ConnectionIcon from '/icons/connection.svg' import { convertSecondsToTimerFormat } from '../../utilities' -import { useEffect, useState } from 'react' + type SyncStatusProps = { isPairing: boolean isPairedSuccessfully: boolean + isAwaitingPairing?: boolean + changeSetIsAwaitingPairing: (isAwaitingPairing: boolean) => void } -const SyncStatus = ({ isPairing, isPairedSuccessfully }: SyncStatusProps) => { + +const SyncStatus = ({ + isPairing, + isAwaitingPairing, + changeSetIsAwaitingPairing, + isPairedSuccessfully +}: SyncStatusProps) => { const [elapsedTime, setElapsedTime] = useState(0) - const [isAwaitingPairing, setIsAwaitingPairing] = useState(false) const resetTimer = () => { setElapsedTime(0) - setIsAwaitingPairing(false) + changeSetIsAwaitingPairing(false) } useEffect(() => { let timer: ReturnType @@ -26,11 +35,11 @@ const SyncStatus = ({ isPairing, isPairedSuccessfully }: SyncStatusProps) => { timer = setInterval(() => { setElapsedTime(prevTime => prevTime + 65) if (elapsedTime >= 180) { - setIsAwaitingPairing(true) + changeSetIsAwaitingPairing(true) } }, 1000) } else { - setIsAwaitingPairing(false) + changeSetIsAwaitingPairing(false) } return () => clearInterval(timer)