diff --git a/ts/screens/wallet/TransactionsScreen.tsx b/ts/screens/wallet/TransactionsScreen.tsx index 6671a6c9862..b6d70b81838 100644 --- a/ts/screens/wallet/TransactionsScreen.tsx +++ b/ts/screens/wallet/TransactionsScreen.tsx @@ -3,9 +3,8 @@ * from a specific credit card */ import * as pot from "italia-ts-commons/lib/pot"; -import { Content, Text, View } from "native-base"; +import { View } from "native-base"; import * as React from "react"; -import { RefreshControl, StyleSheet } from "react-native"; import { NavigationInjectedProps } from "react-navigation"; import { connect } from "react-redux"; import { IOStyles } from "../../components/core/variables/IOStyles"; @@ -13,42 +12,29 @@ import ItemSeparatorComponent from "../../components/ItemSeparatorComponent"; import { ContextualHelpPropsMarkdown } from "../../components/screens/BaseScreenComponent"; import { EdgeBorderComponent } from "../../components/screens/EdgeBorderComponent"; -import H5 from "../../components/ui/H5"; import CardComponent from "../../components/wallet/card/CardComponent"; -import TransactionsList from "../../components/wallet/TransactionsList"; import WalletLayout from "../../components/wallet/WalletLayout"; import PaymentMethodCapabilities from "../../features/wallet/component/PaymentMethodCapabilities"; import I18n from "../../i18n"; import { - navigateToTransactionDetailsScreen, navigateToWalletHome, navigateToWalletList } from "../../store/actions/navigation"; import { Dispatch } from "../../store/actions/types"; -import { - fetchTransactionsRequest, - readTransaction -} from "../../store/actions/wallet/transactions"; import { deleteWalletRequest, setFavouriteWalletRequest } from "../../store/actions/wallet/wallets"; -import { paymentsHistorySelector } from "../../store/reducers/payments/history"; import { GlobalState } from "../../store/reducers/types"; -import { - areMoreTransactionsAvailable, - getTransactions, - getTransactionsLoadedLength -} from "../../store/reducers/wallet/transactions"; import { getFavoriteWalletId, paymentMethodsSelector } from "../../store/reducers/wallet/wallets"; -import variables from "../../theme/variables"; -import { Transaction, Wallet } from "../../types/pagopa"; +import { Wallet } from "../../types/pagopa"; import { showToast } from "../../utils/showToast"; import { handleSetFavourite } from "../../utils/wallet"; + type NavigationParams = Readonly<{ selectedWallet: Wallet; }>; @@ -59,44 +45,11 @@ type Props = OwnProps & ReturnType & ReturnType; -const styles = StyleSheet.create({ - walletBannerText: { - alignItems: "flex-end", - flexDirection: "row" - }, - - noBottomPadding: { - padding: variables.contentPadding, - paddingBottom: 0 - }, - - whiteBg: { - backgroundColor: variables.colorWhite - }, - - brandDarkGray: { - color: variables.brandDarkGray - } -}); - const contextualHelpMarkdown: ContextualHelpPropsMarkdown = { title: "wallet.walletCardTransaction.contextualHelpTitle", body: "wallet.walletCardTransaction.contextualHelpContent" }; -const ListEmptyComponent = ( - -
{I18n.t("wallet.noneTransactions")}
- - {I18n.t("wallet.noTransactionsInTransactionsScreen")} - - -
-); - const HEADER_HEIGHT = 250; class TransactionsScreen extends React.Component { @@ -123,17 +76,8 @@ class TransactionsScreen extends React.Component { ); } - private handleLoadMoreTransactions = () => { - this.props.loadTransactions(this.props.transactionsLoadedLength); - }; - public render(): React.ReactNode { const selectedWallet = this.props.navigation.getParam("selectedWallet"); - const transactions = pot.map(this.props.transactions, tsx => - tsx - .filter(t => t.idWallet === selectedWallet.idWallet) - .sort((a, b) => b.created.getTime() - a.created.getTime()) - ); const isFavorite = pot.map( this.props.favoriteWallet, @@ -148,19 +92,6 @@ class TransactionsScreen extends React.Component { undefined ); - const transactionsRefreshControl = ( - { - this.props.loadTransactions(this.props.transactionsLoadedLength); - }} - // The refresh control spinner is displayed only at pull-to-refresh - // while, during the transactions reload, it is displayed the custom transaction - // list spinner - refreshing={false} - tintColor={"transparent"} - /> - ); - return ( { hideHeader={true} hasDynamicSubHeader={true} topContentHeight={HEADER_HEIGHT} - refreshControl={transactionsRefreshControl} contextualHelpMarkdown={contextualHelpMarkdown} faqCategories={["wallet_transaction"]} > {pm && ( - - - - - - + <> + + + + + + + + + )} - ); } } const mapStateToProps = (state: GlobalState) => ({ - transactions: getTransactions(state), - potPayments: paymentsHistorySelector(state), - transactionsLoadedLength: getTransactionsLoadedLength(state), favoriteWallet: getFavoriteWalletId(state), - readTransactions: state.entities.transactionsRead, - areMoreTransactionsAvailable: areMoreTransactionsAvailable(state), paymentMethods: paymentMethodsSelector(state) }); const mapDispatchToProps = (dispatch: Dispatch) => ({ - loadTransactions: (start: number) => - dispatch(fetchTransactionsRequest({ start })), - navigateToTransactionDetailsScreen: (transaction: Transaction) => { - dispatch(readTransaction(transaction)); - dispatch( - navigateToTransactionDetailsScreen({ - transaction, - isPaymentCompletedTransaction: false - }) - ); - }, setFavoriteWallet: (walletId?: number) => dispatch(setFavouriteWalletRequest(walletId)), deleteWallet: (walletId: number) =>