-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [IOBP-801] Add transactions category tab filters (#6353)
## Short description This PR implements category filters for the receipt list, allowing users to view receipts "paid by me," "addressed to me," or both. The selected filter is applied directly to the backend request, enhancing result customization. Additionally, this PR improves list performance by leveraging React memoization, reducing unnecessary re-renders and significantly enhancing overall efficiency. ## List of changes proposed in this pull request - Added a new component `PaymentsBizEventsFilterTabs` that handles the tabs filter; - Added `noticeCategory` attribute to the `getPaymentsBizEventsTransactionsAction` that can be "all", "payer" or "debtor". Based on the type of the value it will send to the backend request `is_debtor` or `is_payer` flag; - Wrapped the `PaymentsBizEventsListItemTransaction` component inside a `React.memo` to avoid unnecessary re-rendering and allow the re-rendering only if the new attributes are different. ## How to test - Open the "Payments" screen; - Tap on the "See all" CTA on the top-right of the latest transactions to open the transactions list; - You can see three tabs to filter the elements backend-side; - If you're testing it on dev-server please check that the request populate the right query parameter; - If you're testing it on UAT env. you can see the right result returned in the list; ## Preview https://github.com/user-attachments/assets/26007dce-1631-48cb-8ce8-f1220eeca6aa --------- Co-authored-by: Emanuele Dall'Ara <71103219+LeleDallas@users.noreply.github.com>
- Loading branch information
1 parent
c57f072
commit c14925b
Showing
12 changed files
with
270 additions
and
94 deletions.
There are no files selected for viewing
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
16 changes: 16 additions & 0 deletions
16
...ures/payments/bizEventsTransaction/components/PaymentsBizEventsFadeInOutAnimationView.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,16 @@ | ||
import React from "react"; | ||
import { IOStyles } from "@pagopa/io-app-design-system"; | ||
import Animated, { FadeIn, FadeOut } from "react-native-reanimated"; | ||
|
||
export const PaymentsBizEventsFadeInOutAnimationView = React.memo( | ||
({ children }: { children: React.ReactNode }) => ( | ||
<Animated.View | ||
style={IOStyles.flex} | ||
exiting={FadeOut.duration(200)} | ||
entering={FadeIn.duration(200)} | ||
> | ||
{children} | ||
</Animated.View> | ||
), | ||
() => true | ||
); |
64 changes: 64 additions & 0 deletions
64
ts/features/payments/bizEventsTransaction/components/PaymentsBizEventsFilterTabs.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,64 @@ | ||
import { | ||
IOVisualCostants, | ||
TabItem, | ||
TabNavigation, | ||
VSpacer | ||
} from "@pagopa/io-app-design-system"; | ||
import React from "react"; | ||
import { StyleSheet, View } from "react-native"; | ||
import { | ||
PaymentBizEventsCategoryFilter, | ||
paymentsBizEventsCategoryFilters | ||
} from "../types"; | ||
import I18n from "../../../../i18n"; | ||
|
||
type PaymentsBizEventsFilterTabsProps = { | ||
selectedCategory: PaymentBizEventsCategoryFilter; | ||
onCategorySelected?: (category: PaymentBizEventsCategoryFilter) => void; | ||
}; | ||
|
||
const PaymentsBizEventsFilterTabs = ({ | ||
selectedCategory, | ||
onCategorySelected | ||
}: PaymentsBizEventsFilterTabsProps) => { | ||
const selectedIndexOfCategory = | ||
paymentsBizEventsCategoryFilters.indexOf(selectedCategory); | ||
|
||
const handleFilterSelected = (index: number) => { | ||
const categoryByIndex = paymentsBizEventsCategoryFilters[index]; | ||
onCategorySelected?.(categoryByIndex); | ||
}; | ||
|
||
return ( | ||
<View style={styles.container}> | ||
<TabNavigation | ||
tabAlignment="start" | ||
onItemPress={handleFilterSelected} | ||
selectedIndex={selectedIndexOfCategory} | ||
> | ||
{paymentsBizEventsCategoryFilters.map(category => ( | ||
<TabItem | ||
testID={`CategoryTabTestID-${category}`} | ||
key={category} | ||
label={I18n.t( | ||
`features.payments.transactions.filters.tabs.${category}` | ||
)} | ||
accessibilityLabel={I18n.t( | ||
`features.payments.transactions.filters.tabs.${category}` | ||
)} | ||
/> | ||
))} | ||
</TabNavigation> | ||
<VSpacer size={16} /> | ||
</View> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
marginHorizontal: -IOVisualCostants.appMarginDefault * 2, | ||
paddingHorizontal: IOVisualCostants.appMarginDefault | ||
} | ||
}); | ||
|
||
export { PaymentsBizEventsFilterTabs }; |
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
34 changes: 34 additions & 0 deletions
34
...ures/payments/bizEventsTransaction/components/PaymentsBizEventsTransactionLoadingList.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,34 @@ | ||
import { ListItemTransaction, VSpacer } from "@pagopa/io-app-design-system"; | ||
import * as React from "react"; | ||
import Placeholder from "rn-placeholder"; | ||
import { PaymentsBizEventsFadeInOutAnimationView } from "./PaymentsBizEventsFadeInOutAnimationView"; | ||
|
||
export type PaymentsBizEventsTransactionLoadingListProps = { | ||
showSectionTitleSkeleton?: boolean; | ||
}; | ||
|
||
export const PaymentsBizEventsTransactionLoadingList = ({ | ||
showSectionTitleSkeleton | ||
}: PaymentsBizEventsTransactionLoadingListProps) => ( | ||
<> | ||
{showSectionTitleSkeleton && ( | ||
<> | ||
<VSpacer size={16} /> | ||
<Placeholder.Box animate="fade" radius={8} width={62} height={16} /> | ||
<VSpacer size={16} /> | ||
</> | ||
)} | ||
|
||
{Array.from({ length: 5 }).map((_, index) => ( | ||
<PaymentsBizEventsFadeInOutAnimationView key={index}> | ||
<ListItemTransaction | ||
isLoading={true} | ||
transactionStatus="success" | ||
transactionAmount="" | ||
title="" | ||
subtitle="" | ||
/> | ||
</PaymentsBizEventsFadeInOutAnimationView> | ||
))} | ||
</> | ||
); |
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
Oops, something went wrong.