From 068126994e5dc32ef86999a3b558ca8dbd49abcf Mon Sep 17 00:00:00 2001 From: katty barroso Date: Tue, 14 Jan 2025 16:37:03 +0100 Subject: [PATCH] Fix format and add date header --- centrifuge-app/src/components/Report/Orders.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/centrifuge-app/src/components/Report/Orders.tsx b/centrifuge-app/src/components/Report/Orders.tsx index 81bd154cb..56ffc48fc 100644 --- a/centrifuge-app/src/components/Report/Orders.tsx +++ b/centrifuge-app/src/components/Report/Orders.tsx @@ -13,9 +13,17 @@ import { convertCSV } from './utils' const noop = (v: any) => v const Orders = ({ pool }: { pool: Pool }) => { - const { setCsvData } = useContext(ReportContext) + const { setCsvData, setStartDate } = useContext(ReportContext) const orders = usePoolOrdersByPoolId(pool.id) + useEffect(() => { + if (!orders?.length) return + const dateStrings = orders?.map((order) => order.closedAt).filter(Boolean) + const oldestTimestamp = Math.min(...dateStrings.map((date) => new Date(date).getTime())) + const oldestDate = new Date(oldestTimestamp).toISOString().split('T')[0] + setStartDate(oldestDate) + }, []) + const columnsConfig = [ { align: 'left', @@ -34,13 +42,13 @@ const Orders = ({ pool }: { pool: Pool }) => { align: 'left', header: 'NAV', sortable: true, - formatter: (v: any) => (v ? formatBalance(v) : '-'), + formatter: (v: any) => (v ? formatBalance(v, pool.currency.symbol) : '-'), }, { align: 'left', header: 'Nav per share', sortable: true, - formatter: (v: any) => (v ? formatBalance(v, undefined, 5, 5) : '-'), + formatter: (v: any) => (v ? formatBalance(v, pool.currency.symbol, 6, 6) : '-'), }, { align: 'left',