diff --git a/centrifuge-app/src/components/IssuerSection.tsx b/centrifuge-app/src/components/IssuerSection.tsx index 1388461e0..b5238987d 100644 --- a/centrifuge-app/src/components/IssuerSection.tsx +++ b/centrifuge-app/src/components/IssuerSection.tsx @@ -28,9 +28,9 @@ type IssuerSectionProps = { } const reportLinks = [ - { label: 'Balance sheet', href: '/balance-sheet', icon: }, - { label: 'Profit & loss', href: '/profit-and-loss', icon: }, - { label: 'Cashflow statement', href: '/cash-flow-statement', icon: }, + { label: 'Balance sheet', href: '/balance-sheet', icon: }, + { label: 'Profit & loss', href: '/profit-and-loss', icon: }, + { label: 'Cashflow statement', href: '/cash-flow-statement', icon: }, ] const StyledRouterTextLink = styled(RouterTextLink)` @@ -78,7 +78,7 @@ export function ReportDetails({ metadata }: IssuerSectionProps) { {link.label} - + ))} diff --git a/centrifuge-app/src/components/Report/DataFilter.tsx b/centrifuge-app/src/components/Report/DataFilter.tsx new file mode 100644 index 000000000..c856ad847 --- /dev/null +++ b/centrifuge-app/src/components/Report/DataFilter.tsx @@ -0,0 +1,385 @@ +import { Loan, Pool } from '@centrifuge/centrifuge-js' +import { useGetNetworkName } from '@centrifuge/centrifuge-react' +import { + AnchorButton, + Box, + Button, + DateInput, + IconBalanceSheet, + IconCashflow, + IconDownload, + IconProfitAndLoss, + SearchInput, + Select, + Shelf, +} from '@centrifuge/fabric' +import * as React from 'react' +import { useNavigate } from 'react-router' +import { nftMetadataSchema } from '../../schemas' +import { useBasePath } from '../../utils/useBasePath' +import { useActiveDomains } from '../../utils/useLiquidityPools' +import { useLoans } from '../../utils/useLoans' +import { useMetadata } from '../../utils/useMetadata' +import { useCentNFT } from '../../utils/useNFTs' +import { useDebugFlags } from '../DebugFlags' +import { GroupBy, Report, ReportContext } from './ReportContext' +import { formatPoolFeeTransactionType } from './utils' + +type ReportFilterProps = { + pool: Pool +} + +export function ReportFilter({ pool }: ReportFilterProps) { + const { + csvData, + setStartDate, + startDate, + endDate, + setEndDate, + report, + loanStatus, + setLoanStatus, + txType, + setTxType, + groupBy, + setGroupBy, + activeTranche, + setActiveTranche, + address, + setAddress, + network, + setNetwork, + loan, + setLoan, + } = React.useContext(ReportContext) + const navigate = useNavigate() + const basePath = useBasePath() + + const { data: domains } = useActiveDomains(pool.id) + const getNetworkName = useGetNetworkName() + const loans = useLoans(pool.id) as Loan[] | undefined + + const { showOracleTx } = useDebugFlags() + + const reportOptions: { label: string; value: Report }[] = [ + { label: 'Balance sheet', value: 'balance-sheet' }, + { label: 'Profit & loss', value: 'profit-and-loss' }, + { label: 'Cash flow statement', value: 'cash-flow-statement' }, + { label: 'Investor transactions', value: 'investor-tx' }, + { label: 'Asset transactions', value: 'asset-tx' }, + { label: 'Fee transactions', value: 'fee-tx' }, + ...(showOracleTx === true ? [{ label: 'Oracle transactions', value: 'oracle-tx' as Report }] : []), + // { label: 'Pool balance', value: 'pool-balance' }, + { label: 'Token price', value: 'token-price' }, + { label: 'Asset list', value: 'asset-list' }, + { label: 'Investor list', value: 'investor-list' }, + ] + + return ( + + + + + + {!['investor-list', 'asset-list', 'balance-sheet', 'cash-flow-statement', 'profit-and-loss'].includes(report) && ( + <> + setStartDate(e.target.value)} /> + setEndDate(e.target.value)} /> + + )} + + {['pool-balance', 'token-price'].includes(report) && ( + { + setLoanStatus(event.target.value) + }} + /> + setStartDate(e.target.value)} /> + + )} + + {(report === 'investor-list' || report === 'investor-tx') && ( + { + setLoan(event.target.value) + }} + value={loan} + options={[ + { label: 'All', value: 'all' }, + ...(loans?.map((l) => ({ value: l.id, label: })) ?? []), + ]} + /> + )} + + {['balance-sheet', 'cash-flow-statement', 'profit-and-loss'].includes(report) && ( + <> + { + if (event.target.value) { + setTxType(event.target.value) + } + }} + /> + )} + {['investor-tx', 'investor-list'].includes(report) && ( + <> + { - if (event.target.value) { - navigate(`${basePath}/${pool.id}/reporting/${event.target.value}`) - } - }} - /> - - {!['investor-list', 'asset-list', 'balance-sheet', 'cash-flow-statement', 'profit-and-loss'].includes(report) && ( - <> - setStartDate(e.target.value)} /> - setEndDate(e.target.value)} /> - - )} - - {['pool-balance', 'token-price'].includes(report) && ( - { - setLoanStatus(event.target.value) - }} - /> - setStartDate(e.target.value)} /> - - )} - - {(report === 'investor-list' || report === 'investor-tx') && ( - { - setLoan(event.target.value) - }} - value={loan} - options={[ - { label: 'All', value: 'all' }, - ...(loans?.map((l) => ({ value: l.id, label: })) ?? []), - ]} - /> - )} + + } + onClick={() => navigate(`${basePath}/${pool.id}/reporting/balance-sheet`)} + > + Balance sheet + + } + onClick={() => navigate(`${basePath}/${pool.id}/reporting/profit-and-loss`)} + > + Profit & loss + + } + onClick={() => navigate(`${basePath}/${pool.id}/reporting/cash-flow-statement`)} + > + Cash flow + + - {['balance-sheet', 'cash-flow-statement', 'profit-and-loss'].includes(report) && ( - <> + + { - if (event.target.value) { - setTxType(event.target.value) - } - }} - /> - )} - {['investor-tx', 'investor-list'].includes(report) && ( - <> -