text: /* @flow */
  import React, { useCallback } from "react";
  import { View, StyleSheet } from "react-native";
  import { useSelector } from "react-redux";
  import { Trans } from "react-i18next";
  import type { Operation } from "@ledgerhq/live-common/lib/types";
  import { useTheme } from "@react-navigation/native";
  import { accountScreenSelector } from "../../reducers/accounts";
  import { TrackScreen } from "../../analytics";
  import { ScreenName } from "../../const";
  import PreventNativeBack from "../../components/PreventNativeBack";
  import ValidateSuccess from "../../components/ValidateSuccess";
  
  type Props = {
    navigation: any,
    route: { params: RouteParams },
  };
  
  type RouteParams = {
    accountId: string,
    deviceId: string,
    transaction: any,
    result: Operation,
  };
  
  export default function ValidationSuccess({ navigation, route }: Props) {
    const { colors } = useTheme();
    const { account } = useSelector(accountScreenSelector(route));
    const transaction = route.params.transaction;
    const resource = transaction.resource || "";
  
    const onClose = useCallback(() => {
      navigation.dangerouslyGetParent().pop();
    }, [navigation]);
  
    const goToOperationDetails = useCallback(() => {
      if (!account) return;
      const result = route.params.result;
      if (!result) return;
      navigation.navigate(ScreenName.OperationDetails, {
        accountId: account.id,
        operation: result,
      });
    }, [navigation, account, route.params.result]);
  
    return (
      <View style={[styles.root, { backgroundColor: colors.background }]}>
        <TrackScreen category="UnfreezeFunds" name="ValidationSuccess" />
        <PreventNativeBack />
        <ValidateSuccess
          onClose={onClose}
          onViewDetails={goToOperationDetails}
          title={<Trans i18nKey="unfreeze.validation.success" />}
          description={
            <Trans
              i18nKey="unfreeze.validation.info"
              values={{ resource: resource.toLowerCase() }}
            />
          }
        />
      </View>
    );
  }
  
  const styles = StyleSheet.create({
    root: {
      flex: 1,
    },
  });
  