-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: [IOBP-368] Revamp wallet transaction detail page (#5282)
## Short description This PR integrates the revamp of the new wallet transaction detail page ## List of changes proposed in this pull request - Added into `walletV3` feature folder structure the `transaction` folder - Added the redux flow and saga mock (that doesn't make a real API request until we switch from actual PM to BIZ Event); - Added two new screens: `WalletTransactionDetailsScreen` and `WalletTransactionOperationDetailsScreen` - Added Skeletons showing up while loading some API requests; - Connected redux flow & sagas to the `walletV3` feature store; - Added translation locales; - Edited the current `navigateToTransactionDetailsScreen` redirecting to the new screen; ## How to test - Go into the transactions list from the wallet home; - Select any transaction from the list; - You should be able to see the new transaction screen; ## Revamp design https://www.figma.com/file/SDaOSTsQnJUxmoPQEfz3bJ/Ricevuta-di-pagamento-pagoPA?type=design&node-id=520-10951&mode=design&t=KSENC2iM2XXGMJaT-4 ## Preview |Before|After| |-|-| | <video src="https://github.com/pagopa/io-app/assets/34343582/a9b8d7c6-4e1b-408a-a4bd-3d64c0d36cf2" /> |<video src="https://github.com/pagopa/io-app/assets/34343582/cf17a14f-ed57-4796-93b5-dcf4c8d71b07" /> **NB:** In the new transaction preview video there is a 2-second forced loading to show up skeletons to showcase how the loading page looks when it is loading
- Loading branch information
Showing
22 changed files
with
869 additions
and
16 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
import { WalletDetailsActions } from "../../../details/store/actions"; | ||
import { WalletOnboardingActions } from "../../../onboarding/store/actions"; | ||
import { WalletTransactionActions } from "../../../transaction/store/actions"; | ||
|
||
export type WalletV3Actions = WalletOnboardingActions | WalletDetailsActions; | ||
export type WalletV3Actions = | ||
| WalletOnboardingActions | ||
| WalletDetailsActions | ||
| WalletTransactionActions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
ts/features/walletV3/transaction/components/WalletTransactionDetailsList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React from "react"; | ||
import { pipe } from "fp-ts/lib/function"; | ||
import * as O from "fp-ts/lib/Option"; | ||
import { View } from "react-native"; | ||
import Placeholder from "rn-placeholder"; | ||
import { | ||
Divider, | ||
HSpacer, | ||
IOStyles, | ||
ListItemTransaction, | ||
VSpacer | ||
} from "@pagopa/io-app-design-system"; | ||
import { Transaction } from "../../../../types/pagopa"; | ||
import { formatNumberCentsToAmount } from "../../../../utils/stringBuilder"; | ||
import { Dettaglio } from "../../../../../definitions/pagopa/Dettaglio"; | ||
import { | ||
cleanTransactionDescription, | ||
getTransactionIUV | ||
} from "../../../../utils/payment"; | ||
|
||
type Props = { | ||
transaction?: Transaction | null; | ||
loading: boolean; | ||
onPress: (operationDetails: Dettaglio) => void; | ||
}; | ||
|
||
/** | ||
* This component renders a list of transaction details which currently is just a single item | ||
* TODO: Using the actual information, this component is already arranged to handle a list that will be implemented from the BIZ Event implementation (https://pagopa.atlassian.net/browse/IOBP-440) | ||
*/ | ||
export const WalletTransactionDetailsList = ({ | ||
transaction, | ||
loading, | ||
onPress | ||
}: Props) => { | ||
if (loading) { | ||
return <SkeletonTransactionDetailsList />; | ||
} | ||
if (!transaction) { | ||
return <></>; | ||
} | ||
|
||
const operationDetails: Dettaglio = { | ||
importo: transaction.amount.amount, | ||
enteBeneficiario: transaction.merchant, | ||
IUV: pipe(getTransactionIUV(transaction.description), O.toUndefined) | ||
}; | ||
|
||
return ( | ||
<> | ||
<ListItemTransaction | ||
title={cleanTransactionDescription(transaction.description)} | ||
subtitle={transaction.merchant} | ||
transactionStatus="success" | ||
transactionAmount={formatNumberCentsToAmount( | ||
transaction.amount.amount, | ||
true, | ||
"right" | ||
)} | ||
hasChevronRight | ||
onPress={() => onPress?.(operationDetails)} | ||
/> | ||
<Divider /> | ||
</> | ||
); | ||
}; | ||
|
||
const SkeletonTransactionDetailsList = () => ( | ||
<View style={[IOStyles.flex, IOStyles.rowSpaceBetween, IOStyles.alignCenter]}> | ||
<View style={[IOStyles.flex, { paddingVertical: 12 }]}> | ||
<Placeholder.Box height={16} width="90%" radius={4} /> | ||
<VSpacer size={8} /> | ||
<Placeholder.Box height={16} width="30%" radius={4} /> | ||
</View> | ||
<Placeholder.Box height={16} width={48} radius={4} /> | ||
<HSpacer size={16} /> | ||
<Placeholder.Box height={16} width={16} radius={4} /> | ||
</View> | ||
); |
93 changes: 93 additions & 0 deletions
93
ts/features/walletV3/transaction/components/WalletTransactionHeadingSection.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { useNavigation } from "@react-navigation/native"; | ||
import Placeholder from "rn-placeholder"; | ||
import React from "react"; | ||
import { View } from "react-native"; | ||
import { Body, IOStyles, VSpacer } from "@pagopa/io-app-design-system"; | ||
import { Psp, Transaction } from "../../../../types/pagopa"; | ||
import { Dettaglio } from "../../../../../definitions/pagopa/Dettaglio"; | ||
import { formatNumberCentsToAmount } from "../../../../utils/stringBuilder"; | ||
import I18n from "../../../../i18n"; | ||
import { | ||
WalletTransactionRoutes, | ||
WalletTransactionStackNavigation | ||
} from "../navigation/navigator"; | ||
|
||
import { WalletTransactionTotalAmount } from "./WalletTransactionTotalAmount"; | ||
import { WalletTransactionDetailsList } from "./WalletTransactionDetailsList"; | ||
|
||
type Props = { | ||
transaction?: Transaction; | ||
psp?: Psp; | ||
loading: boolean; | ||
}; | ||
|
||
export const WalletTransactionHeadingSection = ({ | ||
transaction, | ||
psp, | ||
loading | ||
}: Props) => { | ||
const navigation = useNavigation<WalletTransactionStackNavigation>(); | ||
|
||
const handlePressTransactionDetails = (operationDetails: Dettaglio) => { | ||
if (transaction) { | ||
navigation.navigate( | ||
WalletTransactionRoutes.WALLET_TRANSACTION_OPERATION_DETAILS, | ||
{ | ||
operationDetails, | ||
operationSubject: transaction.description, | ||
operationName: transaction.description | ||
} | ||
); | ||
} | ||
}; | ||
|
||
const FeeAmountSection = () => { | ||
if (psp && transaction?.fee && !loading) { | ||
const formattedFee = formatNumberCentsToAmount( | ||
transaction.fee.amount, | ||
true, | ||
"right" | ||
); | ||
return ( | ||
<Body> | ||
{I18n.t("transaction.details.totalFee")}{" "} | ||
<Body weight="Medium">{formattedFee}</Body>{" "} | ||
{I18n.t("transaction.details.totalFeePsp", { | ||
pspName: psp.businessName || "" | ||
})} | ||
. | ||
</Body> | ||
); | ||
} | ||
if (loading) { | ||
return ( | ||
<View style={IOStyles.flex}> | ||
<VSpacer size={4} /> | ||
<Placeholder.Line width="100%" animate="fade" /> | ||
<VSpacer size={8} /> | ||
<Placeholder.Line width="50%" animate="fade" /> | ||
</View> | ||
); | ||
} | ||
return <></>; | ||
}; | ||
|
||
return ( | ||
<View style={[IOStyles.horizontalContentPadding, IOStyles.bgWhite]}> | ||
<VSpacer size={16} /> | ||
<WalletTransactionDetailsList | ||
transaction={transaction} | ||
loading={loading} | ||
onPress={handlePressTransactionDetails} | ||
/> | ||
<VSpacer size={8} /> | ||
<WalletTransactionTotalAmount | ||
loading={loading} | ||
totalAmount={transaction?.grandTotal.amount} | ||
/> | ||
<VSpacer size={8} /> | ||
<FeeAmountSection /> | ||
<VSpacer size={8} /> | ||
</View> | ||
); | ||
}; |
Oops, something went wrong.