import { NativeStackScreenProps } from '@react-navigation/native-stack' import React, { useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' import { ActivityIndicator, SafeAreaView, StyleSheet, Text, View } from 'react-native' import AppAnalytics from 'src/analytics/AppAnalytics' import { FiatExchangeEvents } from 'src/analytics/Events' import BackButton from 'src/components/BackButton' import Button, { BtnSizes, BtnTypes } from 'src/components/Button' import TextButton from 'src/components/TextButton' import Touchable from 'src/components/Touchable' import FiatConnectQuote from 'src/fiatExchanges/quotes/FiatConnectQuote' import { SettlementEstimation, SettlementTime } from 'src/fiatExchanges/quotes/constants' import { getSettlementTimeString } from 'src/fiatExchanges/quotes/utils' import { CICOFlow } from 'src/fiatExchanges/types' import { fiatConnectTransferSelector } from 'src/fiatconnect/selectors' import { FiatAccount, SendingTransferStatus } from 'src/fiatconnect/slice' import Checkmark from 'src/icons/Checkmark' import CircledIcon from 'src/icons/CircledIcon' import ClockIcon from 'src/icons/ClockIcon' import OpenLinkIcon from 'src/icons/OpenLinkIcon' import { emptyHeader } from 'src/navigator/Headers' import { navigate, navigateHome } from 'src/navigator/NavigationService' import { Screens } from 'src/navigator/Screens' import { StackParamList } from 'src/navigator/types' import { useSelector } from 'src/redux/hooks' import appTheme from 'src/styles/appTheme' import Colors from 'src/styles/colors' import { typeScale } from 'src/styles/fonts' import { Spacing } from 'src/styles/styles' import variables from 'src/styles/variables' import networkConfig, { blockExplorerUrls } from 'src/web3/networkConfig' import { walletAddressSelector } from 'src/web3/selectors' const LOADING_DESCRIPTION_TIMEOUT_MS = 8000 const DESCRIPTION_STRINGS: Record = { [SettlementTime.LESS_THAN_ONE_HOUR]: 'fiatConnectStatusScreen.success.descriptionWithin1Hour', [SettlementTime.LESS_THAN_X_HOURS]: 'fiatConnectStatusScreen.success.descriptionWithinXHours', [SettlementTime.X_TO_Y_HOURS]: 'fiatConnectStatusScreen.success.descriptionInXtoYHours', [SettlementTime.LESS_THAN_X_DAYS]: 'fiatConnectStatusScreen.success.descriptionWithinXDays', [SettlementTime.X_TO_Y_DAYS]: 'fiatConnectStatusScreen.success.descriptionXtoYDays', } type Props = NativeStackScreenProps function onBack(flow: CICOFlow, normalizedQuote: FiatConnectQuote, fiatAccount: FiatAccount) { AppAnalytics.track(FiatExchangeEvents.cico_fc_transfer_error_retry, { flow, provider: normalizedQuote.getProviderId(), }) navigate(Screens.FiatConnectReview, { flow, normalizedQuote, fiatAccount, shouldRefetchQuote: true, }) } function FailureSection({ normalizedQuote, flow, fiatAccount, }: { normalizedQuote: FiatConnectQuote flow: CICOFlow fiatAccount: FiatAccount }) { const { t } = useTranslation() const provider = normalizedQuote.getProviderId() const onPressSupport = () => { AppAnalytics.track(FiatExchangeEvents.cico_fc_transfer_error_contact_support, { flow, provider, }) navigate(Screens.SupportContact, { prefilledText: flow === CICOFlow.CashIn ? t('fiatConnectStatusScreen.cashIn.contactSupportPrefill') : t('fiatConnectStatusScreen.cashOut.contactSupportPrefill'), }) } return ( {t('fiatConnectStatusScreen.requestNotCompleted.title')} {t('fiatConnectStatusScreen.requestNotCompleted.description')}