Skip to content

Commit

Permalink
feat: ✨ add price column inside csv
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideSegullo committed Jun 18, 2024
1 parent 13eb5a4 commit ffa7574
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions src/views/ExportHistoryDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ export const ExportHistoryDropdown = (props: ExportHistoryDropdownProps) => {
group: LOCALE_GROUP_SEPARATOR,
});

const { formattedString: priceString } = formatNumber({
type: OutputType.Fiat,
value: fill.price,
decimal: LOCALE_DECIMAL_SEPARATOR,
group: LOCALE_GROUP_SEPARATOR,
});

const { sign: totalSign, formattedString: totalString } = formatNumber({
type: OutputType.Fiat,
value: MustBigNumber(fill.price).times(fill.size),
Expand All @@ -75,6 +82,7 @@ export const ExportHistoryDropdown = (props: ExportHistoryDropdownProps) => {
timeStyle: 'short',
}),
amount: fill.size,
price: priceString,
fee: feeSign ? `${feeSign}${feeString}` : feeString,
total: totalSign ? `${totalSign}${totalString}` : totalString,
market: fill.market,
Expand Down Expand Up @@ -105,6 +113,10 @@ export const ExportHistoryDropdown = (props: ExportHistoryDropdownProps) => {
key: 'amount',
displayLabel: stringGetter({ key: STRING_KEYS.AMOUNT }),
},
{
key: 'price',
displayLabel: stringGetter({ key: STRING_KEYS.PRICE }),
},
{
key: 'total',
displayLabel: stringGetter({ key: STRING_KEYS.TOTAL }),
Expand All @@ -124,7 +136,15 @@ export const ExportHistoryDropdown = (props: ExportHistoryDropdownProps) => {
],
});
}
}, [dydxAddress, subaccountNumber, selectedLocale, stringGetter]);
}, [
dydxAddress,
subaccountNumber,
requestAllAccountFills,
stringGetter,
LOCALE_DECIMAL_SEPARATOR,
LOCALE_GROUP_SEPARATOR,
selectedLocale,
]);

const exportTransfers = useCallback(async () => {
if (dydxAddress && subaccountNumber !== undefined) {
Expand Down Expand Up @@ -181,7 +201,15 @@ export const ExportHistoryDropdown = (props: ExportHistoryDropdownProps) => {
],
});
}
}, [dydxAddress, subaccountNumber, selectedLocale, stringGetter]);
}, [
dydxAddress,
subaccountNumber,
requestAllAccountTransfers,
stringGetter,
LOCALE_DECIMAL_SEPARATOR,
LOCALE_GROUP_SEPARATOR,
selectedLocale,
]);

const { mutate: mutateExportTrades, isPending: isPendingExportTrades } = useMutation({
mutationFn: exportTrades,
Expand All @@ -208,7 +236,7 @@ export const ExportHistoryDropdown = (props: ExportHistoryDropdownProps) => {
transfers: checkedTransfers,
});
},
[checkedTrades, checkedTransfers, exportTrades, exportTransfers]
[checkedTrades, checkedTransfers, mutateExportTrades, mutateExportTransfers]
);

return (
Expand Down

0 comments on commit ffa7574

Please sign in to comment.