Skip to content

Commit

Permalink
Merge pull request #15 from stellar/SDP-901_fix-payment-status-histor…
Browse files Browse the repository at this point in the history
…y-sort

change the payment status history sort to descending order
  • Loading branch information
CaioTeixeira95 authored Oct 2, 2023
2 parents c4b20ab + 1358fd4 commit d13cf63
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
15 changes: 10 additions & 5 deletions src/helpers/formatDisbursements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,14 @@ export const formatDisbursement = (
name: disbursement.wallet.name,
},
fileName: disbursement.file_name,
statusHistory: disbursement.status_history.map((h) => ({
status: h.status,
timestamp: h.timestamp,
userId: h.user_id,
})),
statusHistory: disbursement.status_history
.sort(
(a, b) =>
new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime(),
)
.map((h) => ({
status: h.status,
timestamp: h.timestamp,
userId: h.user_id,
})),
});
19 changes: 12 additions & 7 deletions src/helpers/formatPaymentDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@ export const formatPaymentDetails = (payment: ApiPayment): PaymentDetails => {
senderAddress: payment.stellar_address,
totalAmount: payment.amount,
assetCode: payment.asset.code,
statusHistory: payment?.status_history.map((h) => {
return {
updatedAt: h.timestamp,
message: h.status_message,
status: h.status,
};
}),
statusHistory: payment?.status_history
.sort(
(a, b) =>
new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime(),
)
.map((h) => {
return {
updatedAt: h.timestamp,
message: h.status_message,
status: h.status,
};
}),
};
};

0 comments on commit d13cf63

Please sign in to comment.