Skip to content

Feat/export csv payments#926

Merged
Klakurka merged 7 commits intomasterfrom
feat/export-csv-payments
Jan 27, 2025
Merged

Feat/export csv payments#926
Klakurka merged 7 commits intomasterfrom
feat/export-csv-payments

Conversation

@lissavxo
Copy link
Collaborator

Related to #740

Description

Added export csv functionality to payments page

Test plan

Run the server with docker compose up
Go to payments page click Export as CSV button it should download the payments in a csv

@lissavxo lissavxo requested review from Klakurka and chedieck January 18, 2025 21:14
@lissavxo lissavxo force-pushed the feat/export-csv-payments branch from d1389fd to ee415cf Compare January 18, 2025 21:19
Copy link
Member

@Klakurka Klakurka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs to change to the dropdown when there's more than 1 currency involved - same behaviour as on the existing transactions one.

@lissavxo lissavxo requested a review from Klakurka January 20, 2025 19:08
Klakurka
Klakurka approved these changes Jan 20, 2025
Copy link
Member

@Klakurka Klakurka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exported CSV filename should be the same format as the transaction page ones but without the button name on the front.

@lissavxo lissavxo requested a review from Klakurka January 20, 2025 22:30
Klakurka
Klakurka previously approved these changes Jan 20, 2025
Copy link
Collaborator

@chedieck chedieck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a minor request, but my biggest concern is:

Is it necessary to mantain both API endpoints pages/api/payments/download/index.ts and pages/api/paybutton/download/transactions/[paybuttonId].ts?

They have some differences but most code is repeated. My concern is because this separation may make future maintenance harder. In any case, I think they share some utility functions which could be imported from utils/index.ts, like isNetworkValid

A less obvious example is: sortPaymentsByNetworkId, which in the other view is called sortTransactionsByNetworkId and it does exactly the same thing, except that it takes Transactions, not Payments.

Couldn't both just take payments? In the end payments are what are used to generate the CSV anyway.

It's an honest question, I haven't dug that deep into it, maybe there is a good reason to keep it separate like this but seeing this amount of really similar but not identical code being repeated does strike me as something odd.

const getDataAndSetUpCurrencyCSV = async (): Promise<void> => {
const paybuttons = await fetchPaybuttons()
const networkIds: number[] = []
paybuttons.forEach((p: { addresses: any[] }) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use new Set here already and down where this array is used with .includes just use the Set method .has which does the same

@lissavxo lissavxo force-pushed the feat/export-csv-payments branch from f754178 to d81ff00 Compare January 24, 2025 18:14
@lissavxo lissavxo requested a review from Klakurka January 27, 2025 14:02
@Klakurka Klakurka merged commit 0599903 into master Jan 27, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments