-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: [IOBP-838] Remove receipt from list #6334
base: master
Are you sure you want to change the base?
Conversation
…m/pagopa/io-app into IOBP-838-remove-receipt-from-list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Just some improvements and suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need this component screen?
type CancelTransactionRecord = NoticeListItem & { | ||
index: number; | ||
cancelType: string; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about adding this type definition inside a separate file that contains all the utils type definition? For example in one of my PR I've created a file in the following folder ts/features/payments/bizEventsTransaction/types/index.ts
const filterTransactionsByIdAndGetIndex = ( | ||
transactions: pot.Pot<ReadonlyArray<NoticeListItem>, NetworkError>, | ||
transactionId: string | ||
): { | ||
filteredTransactions: Array<NoticeListItem>; | ||
removedIndex: number; | ||
} => { | ||
const transactionList = pot.getOrElse(transactions, []); | ||
const removedIndex = transactionList.findIndex( | ||
transaction => transaction.eventId === transactionId | ||
); | ||
const filteredTransactions = transactionList.filter( | ||
transaction => transaction.eventId !== transactionId | ||
); | ||
return { filteredTransactions, removedIndex }; | ||
}; | ||
|
||
const getTransactionByIndex = ( | ||
transactions: pot.Pot<ReadonlyArray<NoticeListItem>, NetworkError>, | ||
index: number | ||
): NoticeListItem => pot.getOrElse(transactions, [])[index]; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could extracting these two utils functions in the utils index.ts file and adding some tests be useful?
|
||
type CancelTransactionRecord = NoticeListItem & { | ||
index: number; | ||
cancelType: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about setting static values to the cancelType
instead of string
? Something like the following:
cancelType: string; | |
cancelType: 'transactions' | 'latestTransactions'; |
or even setting the type as an enumerator could also be a good way to implement it.
const dispatch = useDispatch(); | ||
const navigation = useIONavigation(); | ||
|
||
const optimisticLoading = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's more understandable the purpose of this function renaming it
const optimisticLoading = () => { | |
const showOptimisticLoading = () => { |
<Stack.Screen | ||
name={ | ||
PaymentsTransactionBizEventsRoutes.PAYMENT_TRANSACTION_BIZ_EVENTS_LOADING_SCREEN | ||
} | ||
options={{ gestureEnabled: isGestureEnabled, headerShown: false }} | ||
component={PaymentsLoaderScreen} | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need this screen?
transactions: !isLatestTransaction | ||
? pot.map(state.transactions, transactions => [ | ||
...transactions.slice(0, index), | ||
restoreItem, | ||
...transactions.slice(index) | ||
]) | ||
: state.transactions, | ||
latestTransactions: isLatestTransaction | ||
? pot.map(state.latestTransactions, latestTransactions => [ | ||
...latestTransactions.slice(0, index), | ||
restoreItem, | ||
...latestTransactions.slice(index) | ||
]) | ||
: state.latestTransactions | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that the calculation of the attribute transactions
and latestTransactions
is the same and what changes is only the variable where to restore the transaction.
What do you think about adding an helper function something like this:
const restoreTransactionAtIndex = (transactionPot, restoreItem, index: number) =>
pot.map(transactionPot, transactions => [
...transactions.slice(0, index),
restoreItem,
...transactions.slice(index)
]);
And then this block of code become:
transactions: cancelType !== "latestTransactions"
? restoreTransactionAtIndex(state.transactions, restoreItem, index)
: state.transactions,
latestTransactions: cancelType === "latestTransactions"
? restoreTransactionAtIndex(state.latestTransactions, restoreItem, index)
: state.latestTransactions
This PR depends on
Short description
This pull request introduces a new feature to hide receipts from the list
List of changes proposed in this pull request
PaymentsTransactionBizEventsDetailsScreen
How to test
Dev-server
config.ts
set a delay and edit thehideReceiptResponseCode
propertyNascondi dalla lista
Preview
Screen.Recording.2024-10-29.at.11.37.44.mov
Screen.Recording.2024-10-29.at.11.39.53.mov
Screen.Recording.2024-10-29.at.11.40.58.mov
@thisisjp would it make sense to set a minimum delay before displaying the Loading component? This could help avoid the component flashing on screen for very short loading times, leading to a smoother user experience.