-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Add Reporting tab to investor view and dry out into PoolRep…
…ortPage
- Loading branch information
Showing
5 changed files
with
54 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Pool } from '@centrifuge/centrifuge-js' | ||
import * as React from 'react' | ||
import { useParams } from 'react-router' | ||
import { ReportComponent } from '.' | ||
import { usePool } from '../../utils/usePools' | ||
import { LoadBoundary } from '../LoadBoundary' | ||
import { PageWithSideBar } from '../PageWithSideBar' | ||
import { Spinner } from '../Spinner' | ||
import { ReportContextProvider } from './ReportContext' | ||
import { ReportFilter } from './ReportFilter' | ||
|
||
export function PoolReportPage({ header }: { header: React.ReactNode }) { | ||
const { pid: poolId } = useParams<{ pid: string }>() | ||
const pool = usePool(poolId) as Pool | ||
|
||
return ( | ||
<ReportContextProvider> | ||
<PageWithSideBar> | ||
{header} | ||
|
||
{pool && <ReportFilter pool={pool} />} | ||
|
||
<LoadBoundary> | ||
<PoolDetailReporting pool={pool} /> | ||
</LoadBoundary> | ||
</PageWithSideBar> | ||
</ReportContextProvider> | ||
) | ||
} | ||
|
||
function PoolDetailReporting({ pool }: { pool: Pool }) { | ||
if (!pool) { | ||
return <Spinner mt={2} /> | ||
} | ||
|
||
return ( | ||
<React.Suspense fallback={<Spinner mt={2} />}> | ||
<ReportComponent pool={pool} /> | ||
</React.Suspense> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import * as React from 'react' | ||
import { PoolReportPage } from '../../../components/Report/PoolReportPage' | ||
import { IssuerPoolHeader } from '../Header' | ||
|
||
export function IssuerPoolReportingPage() { | ||
return <PoolReportPage header={<IssuerPoolHeader />} /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,7 @@ | ||
import { Pool } from '@centrifuge/centrifuge-js' | ||
import * as React from 'react' | ||
import { useParams } from 'react-router' | ||
import { LoadBoundary } from '../../../components/LoadBoundary' | ||
import { PageWithSideBar } from '../../../components/PageWithSideBar' | ||
import { ReportComponent } from '../../../components/Report' | ||
import { ReportContextProvider } from '../../../components/Report/ReportContext' | ||
import { ReportFilter } from '../../../components/Report/ReportFilter' | ||
import { Spinner } from '../../../components/Spinner' | ||
import { usePool } from '../../../utils/usePools' | ||
import { PoolReportPage } from '../../../components/Report/PoolReportPage' | ||
import { PoolDetailHeader } from '../Header' | ||
|
||
export type GroupBy = 'day' | 'month' | ||
|
||
export type Report = 'pool-balance' | 'asset-list' | 'investor-tx' | 'borrower-tx' | ||
|
||
const titleByReport: { [key: string]: string } = { | ||
'pool-balance': 'Pool balance', | ||
'asset-list': 'Asset list', | ||
'investor-tx': 'Investor transactions', | ||
'borrower-tx': 'Borrower transactions', | ||
} | ||
|
||
export function PoolDetailReportingTab() { | ||
const { pid: poolId } = useParams<{ pid: string }>() | ||
const pool = usePool(poolId) as Pool | ||
|
||
return ( | ||
<ReportContextProvider> | ||
<PageWithSideBar> | ||
<PoolDetailHeader /> | ||
|
||
{pool && <ReportFilter pool={pool} />} | ||
|
||
<LoadBoundary> | ||
<PoolDetailReporting pool={pool} /> | ||
</LoadBoundary> | ||
</PageWithSideBar> | ||
</ReportContextProvider> | ||
) | ||
} | ||
|
||
export function PoolDetailReporting({ pool }: { pool: Pool }) { | ||
if (!pool) { | ||
return <Spinner mt={2} /> | ||
} | ||
|
||
return ( | ||
<React.Suspense fallback={<Spinner mt={2} />}> | ||
<ReportComponent pool={pool} /> | ||
</React.Suspense> | ||
) | ||
return <PoolReportPage header={<PoolDetailHeader />} /> | ||
} |