Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
kattylucy committed Jan 27, 2025
1 parent b2cb773 commit 53a9371
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
8 changes: 4 additions & 4 deletions centrifuge-app/src/components/Report/CashflowStatement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ export function CashflowStatement({ pool }: { pool: Pool }) {
setReportData(data)
}, [data])

Check warning on line 31 in centrifuge-app/src/components/Report/CashflowStatement.tsx

View workflow job for this annotation

GitHub Actions / build-app

React Hook React.useEffect has a missing dependency: 'setReportData'. Either include it or remove the dependency array

Check warning on line 31 in centrifuge-app/src/components/Report/CashflowStatement.tsx

View workflow job for this annotation

GitHub Actions / ff-prod / build-app

React Hook React.useEffect has a missing dependency: 'setReportData'. Either include it or remove the dependency array

if (isLoading) {
return <Spinner mt={2} />
}

const columns = React.useMemo(() => {
if (!data.length && !isLoading) {
return []
Expand Down Expand Up @@ -254,6 +250,10 @@ export function CashflowStatement({ pool }: { pool: Pool }) {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [grossCashflowRecords, netCashflowRecords])

if (isLoading) {
return <Spinner mt={2} />
}

return data?.length > 0 ? (
<DataTableGroup>
<DataTable data={grossCashflowRecords} columns={columns} hoverable />
Expand Down
16 changes: 9 additions & 7 deletions centrifuge-app/src/components/Report/ReportFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ export function ReportFilter({ poolId }: ReportFilterProps) {
yAxis: data.totalProfitAndLoss?.toDecimal(),
}))
} else {
return (reportData as CashflowReport[]).map((data) => {
return {
name: data.timestamp,
yAxis: data.totalCashflow?.toDecimal(),
}
})
return (reportData as CashflowReport[])
.filter((data) => !data.totalCashflow?.isZero())
.map((data) => {
return {
name: data.timestamp,
yAxis: data.totalCashflow?.toDecimal(),
}
})
}
}, [report, reportData])

Expand Down Expand Up @@ -167,7 +169,7 @@ export function ReportFilter({ poolId }: ReportFilterProps) {
</AnchorButton>
</Shelf>
</Shelf>
{transformDataChart?.length && (
{!!transformDataChart?.length && (
<Box mt={4} width="100%" height={200} marginLeft="-50px">
<SimpleBarChart data={transformDataChart} currency={pool.currency} />
</Box>
Expand Down
6 changes: 3 additions & 3 deletions centrifuge-app/src/components/Report/useReportsQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export function useReport<T extends ReportsType>(
() =>
getAdjustedDates(
groupBy || undefined,
startDate ? new Date(startDate) : undefined,
endDate ? new Date(endDate) : undefined,
startDate ?? undefined,
endDate ?? undefined,
pool.createdAt ? new Date(pool.createdAt) : undefined
),
[groupBy, startDate, endDate, pool.createdAt]
Expand All @@ -71,7 +71,7 @@ export function useReport<T extends ReportsType>(
const group = groupBy === 'day' || groupBy === 'daily' ? 'day' : groupBy

const rawReport = await sdkPool.reports[reportType]({
from: startDate?.toISOString(),
from: adjustedStartDate?.toISOString(),
to: adjustedEndDate?.toISOString(),
groupBy: group,
...filters,
Expand Down
2 changes: 1 addition & 1 deletion centrifuge-app/src/utils/formatting.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CurrencyBalance, CurrencyMetadata, Perquintill, Price, Rate, TokenBalance } from '@centrifuge/centrifuge-js'
import Decimal from 'decimal.js'
import Decimal from 'decimal.js-light'

export function formatBalance(
amount: CurrencyBalance | TokenBalance | Price | Rate | Decimal | number,
Expand Down

0 comments on commit 53a9371

Please # to comment.