Conversation
Klakurka
left a comment
There was a problem hiding this comment.
Filter isn't apply to CSV generation.
pages/api/payments/count/index.ts
Outdated
| amount: { gt: 0 } | ||
| } | ||
|
|
||
| const totalCount = await prisma.transaction.count({ |
There was a problem hiding this comment.
this logic should be in the service layer
| const orderDescString: Prisma.SortOrder = orderDesc ? 'desc' : 'asc' | ||
|
|
||
| if (orderBy === 'buttonDisplayDataList') { | ||
| return await getPaymentsByUserIdOrderedByButtonName( |
There was a problem hiding this comment.
filter by buttons in getPaymentsByUserIdOrderedByButtonName is missing, this way filters will not work in the order by button
|
Okay think I got those sorted |
pages/api/payments/count/index.ts
Outdated
| buttonIds = (req.query.buttonIds as string).split(',') | ||
| } | ||
|
|
||
| if ((buttonIds != null) && buttonIds.length > 0) { |
There was a problem hiding this comment.
Should be !== undefined, not != null.
!= null works but leads the reader to consider that the variable can be null OR undefined, which is not the case, since it can only be undefined.
services/transactionService.ts
Outdated
| }, | ||
| amount: { | ||
| gt: 0 | ||
| // Build the base where clause |
There was a problem hiding this comment.
I don't think any of these comments are useful
services/transactionService.ts
Outdated
| } | ||
|
|
||
| // If buttonIds is provided, add a nested filter on address.paybuttons | ||
| if ((buttonIds != null) && buttonIds.length > 0) { |
services/transactionService.ts
Outdated
| networkId: { | ||
| in: networkIds ?? Object.values(NETWORK_IDS) | ||
| } | ||
| const whereClause: any = { |
There was a problem hiding this comment.
Prisma.TransactionWhereInput
services/transactionService.ts
Outdated
| amount: { | ||
| gt: 0 | ||
| // Build the base where clause | ||
| const whereClause: any = { |
There was a problem hiding this comment.
Better to use Prisma.TransactionWhereInput instead of any.
services/transactionService.ts
Outdated
| } | ||
| } | ||
|
|
||
| if (Array.isArray(buttonIds) && buttonIds.length > 0) { |
There was a problem hiding this comment.
In the function above we had similar code but with if ((buttonIds != null), which was basically checking if buttonIds !== undefined. This Array.isArray(buttonIds) achieves the same result but with in a different way, which makes what it is doing a little less obvious and harder to read.
services/transactionService.ts
Outdated
| userId: string, | ||
| buttonIds: string[] | ||
| ): Promise<number> => { | ||
| const whereClause: any = { |
There was a problem hiding this comment.
No need to create this constant
chedieck
left a comment
There was a problem hiding this comment.
Had some minor code complaints, but I decided to fix them myself.
I noticed that changing the filtered buttons makes the order reset to "by Date": would be nice to have it stay in place (e.g. "by Amount" ascendent, if that was selected)
|
Cool thanks for fixing those. Sorting should be persistent now when filtering |
chedieck
left a comment
There was a problem hiding this comment.
Now indeed the order is maintained after changing the paybuttons to filter with, but the page is not reset.
Meaning if I select two buttons: one with a lot of txs and one with only a few, and go to page 25 of payments, and then unselect the one with a lot of txs leaving only the one with a few, the page stays in 25 (which doesn't exist)
Would be nice if it would go back to the first one when some change is made to the paybuttons to filter with.
|
ah yes good catch, should be good now |
Klakurka
left a comment
There was a problem hiding this comment.
- Let's change "Filter by PayButton" to "Filter by Button" to keep the wording consistent in the UI.
- Maybe we can make a new task for improving the CSV export filename when exporting a filtered set of buttons.
Looks good to me otherwise.
|
Okay updated that label |
|
Actually think I got it |
|
@chedieck any updates here? |
|
Since I can't seem to reproduce this error, I left a commit with some logs to understand better what is erroring. So far I can't tell if this would happen in prod or not since I am not being able to reproduce. |
Klakurka
left a comment
There was a problem hiding this comment.
Let's just go ahead with this and if there's issues in prod then we can tackle them separately.



Related to #972
Description
Add a multi select button filter on the payments page that will only show payments from those buttons
Test plan
Run the app and check out the payments page and mess with the filters